refactor(doorbell): unify 2x2 grid touch logic and add progress bar
This commit is contained in:
@@ -116,11 +116,16 @@ TouchEvent DisplayDriverTFT::readTouch() {
|
||||
}
|
||||
|
||||
int DisplayDriverTFT::dashboardTouch(int x, int y) {
|
||||
// 2-column, 4-row
|
||||
int col = x / (DISPLAY_WIDTH / 2);
|
||||
int row = (y - 30) / 40;
|
||||
if (row < 0 || row > 3) return -1;
|
||||
return row * 2 + col;
|
||||
// Unified 2x2 grid (matching GFX)
|
||||
int col = (x * 2) / DISPLAY_WIDTH; // 0 or 1
|
||||
int row = (y * 2) / DISPLAY_HEIGHT; // 0 or 1
|
||||
|
||||
// Adjust for header offset (y starts at 30 in drawDashboard)
|
||||
if (y < 30) return -1;
|
||||
row = ((y - 30) * 2) / (DISPLAY_HEIGHT - 30);
|
||||
if (row < 0 || row > 1) return -1;
|
||||
|
||||
return row * 2 + col; // 0, 1, 2, or 3
|
||||
}
|
||||
|
||||
HoldState DisplayDriverTFT::updateHold(unsigned long holdMs) {
|
||||
@@ -142,6 +147,10 @@ HoldState DisplayDriverTFT::updateHold(unsigned long holdMs) {
|
||||
_tft.fillRect(0, DISPLAY_HEIGHT - 8, barW, 8, TFT_WHITE);
|
||||
_tft.fillRect(barW, DISPLAY_HEIGHT - 8, DISPLAY_WIDTH - barW, 8, TFT_DARKGREY);
|
||||
} else {
|
||||
if (_ // Clear theholdActive) {
|
||||
progress bar when released
|
||||
_tft.fillRect(0, DISPLAY_HEIGHT - 8, DISPLAY_WIDTH, 8, TFT_DARKGREY);
|
||||
}
|
||||
_holdActive = false;
|
||||
}
|
||||
return h;
|
||||
|
||||
Reference in New Issue
Block a user