refactor(DisplayManager): add hitTestRaw() and remove touch coordinate filtering

This commit is contained in:
2026-02-22 18:43:54 -08:00
parent 4030048401
commit 3d17e7bab9
3 changed files with 38 additions and 16 deletions

View File

@@ -378,18 +378,12 @@ TouchEvent DisplayDriverTFT::readTouch() {
uint16_t tx, ty;
uint8_t touched = _tft.getTouch(&tx, &ty, 100);
// Filter out invalid coordinates (touch panel can return garbage on release)
// Check against actual display dimensions (320x480 for this board)
bool validCoords = !(tx > 320 || ty > 480);
if(touched && !validCoords) {
touched = 0;
return evt;
}
// Debug: log touch state changes
// Debug: log touch state changes with transformed coords
if(touched != _touchWasPressed) {
Serial.printf("[TOUCH] raw touched=%d wasPressed=%d (x=%d,y=%d)\n", touched,
_touchWasPressed, tx, ty);
int tx_form = tx, ty_form = ty;
transformTouch(&tx_form, &ty_form);
Serial.printf("[TOUCH] raw touched=%d wasPressed=%d (raw=%d,%d trans=%d,%d)\n", touched,
_touchWasPressed, tx, ty, tx_form, ty_form);
}
// Detect transitions (press/release)
@@ -431,7 +425,9 @@ TouchEvent DisplayDriverTFT::readTouch() {
}
void DisplayDriverTFT::transformTouch(int* x, int* y) {
// Resistive touch panel is rotated 90° vs display - swap coordinates
// Resistive touch panel is rotated 90° vs display - swap and adjust
// Touch panel: 320x480 (portrait), Display: 480x320 (landscape)
// This was the original working transform
int temp = *x;
*x = *y;
*y = temp;