refactor: replace hint feedback with debug crosshair

This commit is contained in:
2026-02-19 15:12:02 -08:00
parent ec8ec4cd18
commit dd1c13fbbc
10 changed files with 16 additions and 91 deletions

View File

@@ -139,51 +139,9 @@ public:
HoldState updateHold(unsigned long ms) { return _drv ? _drv->updateHold(ms) : HoldState {}; }
void updateHint(int x, int y, bool active) {
void drawDebugTouch(int x, int y) {
if(_drv)
_drv->updateHint(x, y, active);
}
/// Show touch feedback - highlights the tile at given coordinates
/// Returns true if a valid tile is being touched
bool showTouchFeedback(int x, int y) {
if(!_drv || _gridCols <= 0)
return false;
// Transform touch coordinates
_drv->transformTouch(&x, &y);
int headerH = 30;
if(y < headerH)
return false;
// Calculate which cell
int cellW = _drv->width() / _gridCols;
int cellH = (_drv->height() - headerH) / _gridRows;
int col = x / cellW;
int row = (y - headerH) / cellH;
if(col < 0 || col >= _gridCols || row < 0 || row >= _gridRows)
return false;
// Find which tile is at this position
for(int i = 0; i < _tileCount; i++) {
const TileLayout& lay = _layouts[i];
if(lay.col <= col && col < lay.col + lay.cols && lay.row <= row
&& lay.row + lay.rows > row) {
// Found the tile - draw highlight via driver
_drv->updateHint(lay.x, lay.y, true); // active=true means show feedback
return true;
}
}
return false;
}
/// Clear touch feedback
void clearTouchFeedback() {
if(_drv)
_drv->updateHint(0, 0, false); // active=false means clear
_drv->drawDebugTouch(x, y);
}
/// Check if current position is still in same tile as touch-down

View File

@@ -330,18 +330,17 @@ int DoorbellLogic::handleTouch(const TouchEvent& evt) {
return -1;
}
// Show touch feedback on press
// Draw debug crosshair at touch point
#ifdef DEBUG_MODE
if(_state.screen == ScreenID::DASHBOARD) {
_display->showTouchFeedback(evt.x, evt.y);
_display->drawDebugTouch(evt.x, evt.y);
}
#endif
return -1;
}
// Handle release - fire action if same tile
if(evt.released) {
// Clear feedback
_display->clearTouchFeedback();
if(_state.screen == ScreenID::DASHBOARD) {
// Only fire action if finger stayed on same tile
if(evt.downX >= 0 && _display->isSameTile(evt.downX, evt.downY, evt.x, evt.y)) {
@@ -405,10 +404,6 @@ bool DoorbellLogic::updateHold(const TouchEvent& evt) {
holdStartY = evt.y;
}
if(holdStartX >= 0) {
_display->updateHint(holdStartX, holdStartY, h.active);
}
return false;
}

View File

@@ -32,7 +32,7 @@ public:
// ── Touch ──
virtual TouchEvent readTouch() = 0;
virtual HoldState updateHold(unsigned long holdMs) = 0;
virtual void updateHint(int x, int y, bool active) = 0;
virtual void drawDebugTouch(int x, int y) { /* default: no-op */ }
virtual int width() = 0;
virtual int height() = 0;