feat(touch): add continuous touch polling and debug logging

This commit is contained in:
2026-02-17 23:20:42 -08:00
parent bc47200e38
commit c9232ee477
4 changed files with 26 additions and 0 deletions

View File

@@ -10,15 +10,18 @@ void DisplayDriverTFT::begin() {
_tft.fillScreen(TFT_BLACK);
Serial.printf("[GFX] Display OK: %dx%d\n", DISPLAY_WIDTH, DISPLAY_HEIGHT);
Serial.flush();
// Debug: check if touch controller is responding
uint16_t z = _tft.getTouchRawZ();
Serial.printf("[TOUCH] Raw Z=%d (non-zero = controller detected)\n", z);
Serial.flush();
drawBoot();
digitalWrite(PIN_LCD_BL, HIGH);
Serial.println("[GFX] Backlight ON");
Serial.flush();
}
void DisplayDriverTFT::setBacklight(bool on) { digitalWrite(PIN_LCD_BL, on ? HIGH : LOW); }
@@ -132,6 +135,10 @@ TouchEvent DisplayDriverTFT::readTouch() {
return evt;
}
uint16_t DisplayDriverTFT::getRawTouchZ() {
return _tft.getTouchRawZ();
}
int DisplayDriverTFT::dashboardTouch(int x, int y) {
// 2x2 grid, accounting for 30px header
if(y < 30)

View File

@@ -11,6 +11,7 @@ public:
void setBacklight(bool on) override;
void render(const ScreenState& state) override;
TouchEvent readTouch() override;
uint16_t getRawTouchZ();
int dashboardTouch(int x, int y) override;
HoldState updateHold(unsigned long holdMs) override;
void updateHint(int x, int y, bool active) override;

View File

@@ -21,6 +21,20 @@ void setup() {
}
void loop() {
// ── Touch debug: poll continuously ──
TouchEvent evt = display.readTouch();
if(evt.pressed) {
Serial.printf("[TOUCH] pressed: x=%d, y=%d\n", evt.x, evt.y);
} else {
// Debug: print raw Z even when not touched, to see controller state
static uint32_t lastDebug = 0;
if(millis() - lastDebug > 2000) {
lastDebug = millis();
uint16_t z = tftDriver.getRawTouchZ();
Serial.printf("[TOUCH] Raw Z=%d\n", z);
}
}
// ── State machine tick ──
logic.update();
@@ -68,4 +82,7 @@ void loop() {
if(cmd.length() > 0)
logic.onSerialCommand(cmd);
}
// Yield to WiFi/BT stack (prevents Task Watchdog timeout)
delay(10);
}

View File

@@ -27,6 +27,7 @@
// ── Touch (XPT2046 resistive) ──
#define TOUCH_CS 33
#define TOUCH_IRQ 36
// ── SPI speed ──
#define SPI_FREQUENCY 40000000