feat(touch): add continuous touch polling and debug logging
This commit is contained in:
@@ -10,15 +10,18 @@ void DisplayDriverTFT::begin() {
|
|||||||
_tft.fillScreen(TFT_BLACK);
|
_tft.fillScreen(TFT_BLACK);
|
||||||
|
|
||||||
Serial.printf("[GFX] Display OK: %dx%d\n", DISPLAY_WIDTH, DISPLAY_HEIGHT);
|
Serial.printf("[GFX] Display OK: %dx%d\n", DISPLAY_WIDTH, DISPLAY_HEIGHT);
|
||||||
|
Serial.flush();
|
||||||
|
|
||||||
// Debug: check if touch controller is responding
|
// Debug: check if touch controller is responding
|
||||||
uint16_t z = _tft.getTouchRawZ();
|
uint16_t z = _tft.getTouchRawZ();
|
||||||
Serial.printf("[TOUCH] Raw Z=%d (non-zero = controller detected)\n", z);
|
Serial.printf("[TOUCH] Raw Z=%d (non-zero = controller detected)\n", z);
|
||||||
|
Serial.flush();
|
||||||
|
|
||||||
drawBoot();
|
drawBoot();
|
||||||
|
|
||||||
digitalWrite(PIN_LCD_BL, HIGH);
|
digitalWrite(PIN_LCD_BL, HIGH);
|
||||||
Serial.println("[GFX] Backlight ON");
|
Serial.println("[GFX] Backlight ON");
|
||||||
|
Serial.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayDriverTFT::setBacklight(bool on) { digitalWrite(PIN_LCD_BL, on ? HIGH : LOW); }
|
void DisplayDriverTFT::setBacklight(bool on) { digitalWrite(PIN_LCD_BL, on ? HIGH : LOW); }
|
||||||
@@ -132,6 +135,10 @@ TouchEvent DisplayDriverTFT::readTouch() {
|
|||||||
return evt;
|
return evt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t DisplayDriverTFT::getRawTouchZ() {
|
||||||
|
return _tft.getTouchRawZ();
|
||||||
|
}
|
||||||
|
|
||||||
int DisplayDriverTFT::dashboardTouch(int x, int y) {
|
int DisplayDriverTFT::dashboardTouch(int x, int y) {
|
||||||
// 2x2 grid, accounting for 30px header
|
// 2x2 grid, accounting for 30px header
|
||||||
if(y < 30)
|
if(y < 30)
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ public:
|
|||||||
void setBacklight(bool on) override;
|
void setBacklight(bool on) override;
|
||||||
void render(const ScreenState& state) override;
|
void render(const ScreenState& state) override;
|
||||||
TouchEvent readTouch() override;
|
TouchEvent readTouch() override;
|
||||||
|
uint16_t getRawTouchZ();
|
||||||
int dashboardTouch(int x, int y) override;
|
int dashboardTouch(int x, int y) override;
|
||||||
HoldState updateHold(unsigned long holdMs) override;
|
HoldState updateHold(unsigned long holdMs) override;
|
||||||
void updateHint(int x, int y, bool active) override;
|
void updateHint(int x, int y, bool active) override;
|
||||||
|
|||||||
@@ -21,6 +21,20 @@ void setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
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 ──
|
// ── State machine tick ──
|
||||||
logic.update();
|
logic.update();
|
||||||
|
|
||||||
@@ -68,4 +82,7 @@ void loop() {
|
|||||||
if(cmd.length() > 0)
|
if(cmd.length() > 0)
|
||||||
logic.onSerialCommand(cmd);
|
logic.onSerialCommand(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Yield to WiFi/BT stack (prevents Task Watchdog timeout)
|
||||||
|
delay(10);
|
||||||
}
|
}
|
||||||
@@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
// ── Touch (XPT2046 resistive) ──
|
// ── Touch (XPT2046 resistive) ──
|
||||||
#define TOUCH_CS 33
|
#define TOUCH_CS 33
|
||||||
|
#define TOUCH_IRQ 36
|
||||||
|
|
||||||
// ── SPI speed ──
|
// ── SPI speed ──
|
||||||
#define SPI_FREQUENCY 40000000
|
#define SPI_FREQUENCY 40000000
|
||||||
|
|||||||
Reference in New Issue
Block a user