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

@@ -348,11 +348,3 @@ HoldState DisplayDriverTFT::updateHold(unsigned long holdMs) {
} }
return h; return h;
} }
void DisplayDriverTFT::updateHint(int x, int y, bool active) {
float period = active ? 500.0f : 2000.0f;
float t = fmodf(millis(), period) / period;
uint8_t v = static_cast<uint8_t>(30.0f + 30.0f * sinf(t * 2.0f * PI));
uint16_t col = _tft.color565(v, v, v);
_tft.drawRect(x - 40, y - 20, 80, 40, col);
}

View File

@@ -12,7 +12,6 @@ public:
void render(const ScreenState& state) override; void render(const ScreenState& state) override;
TouchEvent readTouch() override; TouchEvent readTouch() override;
HoldState updateHold(unsigned long holdMs) override; HoldState updateHold(unsigned long holdMs) override;
void updateHint(int x, int y, bool active) override;
int width() override { return _tft.width(); } int width() override { return _tft.width(); }
int height() override { return _tft.height(); } int height() override { return _tft.height(); }

View File

@@ -326,11 +326,3 @@ HoldState DisplayDriverTFT::updateHold(unsigned long holdMs) {
} }
return h; return h;
} }
void DisplayDriverTFT::updateHint(int x, int y, bool active) {
float period = active ? 500.0f : 2000.0f;
float t = fmodf(millis(), period) / period;
uint8_t v = static_cast<uint8_t>(30.0f + 30.0f * sinf(t * 2.0f * PI));
uint16_t col = _tft.color565(v, v, v);
_tft.drawRect(x - 40, y - 20, 80, 40, col);
}

View File

@@ -13,7 +13,6 @@ public:
TouchEvent readTouch() override; TouchEvent readTouch() override;
int dashboardTouch(int x, int y); int dashboardTouch(int x, int y);
HoldState updateHold(unsigned long holdMs) override; HoldState updateHold(unsigned long holdMs) override;
void updateHint(int x, int y, bool active) override;
int width() override { return DISPLAY_WIDTH; } int width() override { return DISPLAY_WIDTH; }
int height() override { return DISPLAY_HEIGHT; } int height() override { return DISPLAY_HEIGHT; }

View File

@@ -433,21 +433,11 @@ void DisplayDriverGFX::drawDashboard(const ScreenState& state) {
} }
} }
void DisplayDriverGFX::updateHint(int x, int y, bool active) { void DisplayDriverGFX::drawDebugTouch(int x, int y) {
if(!_gfx) if(!_gfx)
return; return;
static uint32_t lastTime = 0; const int size = 20;
uint32_t now = millis(); _gfx->drawLine(x - size, y, x + size, y, TFT_RED);
if(now - lastTime < 100) _gfx->drawLine(x, y - size, x, y + size, TFT_RED);
return;
lastTime = now;
// active=true: faster pulse (500ms), active=false: slower pulse (2000ms)
float period = active ? 500.0f : 2000.0f;
float t = fmodf(now, period) / period;
uint8_t v = static_cast<uint8_t>(30.0f + 30.0f * sinf(t * 2.0f * 3.14159f));
uint16_t col = _gfx->color565(v, v, v);
_gfx->drawCircle(x, y, 50, col);
} }

View File

@@ -13,7 +13,7 @@ public:
TouchEvent readTouch() override; TouchEvent readTouch() override;
HoldState updateHold(unsigned long holdMs) override; HoldState updateHold(unsigned long holdMs) override;
void updateHint(int x, int y, bool active) override; void drawDebugTouch(int x, int y) override;
int width() override; int width() override;
int height() override; int height() override;

View File

@@ -139,51 +139,9 @@ public:
HoldState updateHold(unsigned long ms) { return _drv ? _drv->updateHold(ms) : HoldState {}; } 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) if(_drv)
_drv->updateHint(x, y, active); _drv->drawDebugTouch(x, y);
}
/// 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
} }
/// Check if current position is still in same tile as touch-down /// 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; return -1;
} }
// Show touch feedback on press // Draw debug crosshair at touch point
#ifdef DEBUG_MODE
if(_state.screen == ScreenID::DASHBOARD) { if(_state.screen == ScreenID::DASHBOARD) {
_display->showTouchFeedback(evt.x, evt.y); _display->drawDebugTouch(evt.x, evt.y);
} }
#endif
return -1; return -1;
} }
// Handle release - fire action if same tile // Handle release - fire action if same tile
if(evt.released) { if(evt.released) {
// Clear feedback
_display->clearTouchFeedback();
if(_state.screen == ScreenID::DASHBOARD) { if(_state.screen == ScreenID::DASHBOARD) {
// Only fire action if finger stayed on same tile // Only fire action if finger stayed on same tile
if(evt.downX >= 0 && _display->isSameTile(evt.downX, evt.downY, evt.x, evt.y)) { 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; holdStartY = evt.y;
} }
if(holdStartX >= 0) {
_display->updateHint(holdStartX, holdStartY, h.active);
}
return false; return false;
} }

View File

@@ -32,7 +32,7 @@ public:
// ── Touch ── // ── Touch ──
virtual TouchEvent readTouch() = 0; virtual TouchEvent readTouch() = 0;
virtual HoldState updateHold(unsigned long holdMs) = 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 width() = 0;
virtual int height() = 0; virtual int height() = 0;

View File

@@ -28,10 +28,10 @@ arduino-cli compile --fqbn "$FQBN" --libraries ./libraries $LIBS --build-propert
[tasks.upload] [tasks.upload]
description = "Upload (uses BOARD env var)" description = "Upload (uses BOARD env var)"
depends = ["compile", "kill"] depends = ["kill"]
run = """ run = """
source ./boards/$BOARD/board-config.sh source ./boards/$BOARD/board-config.sh
arduino-cli upload --fqbn $FQBN --port $PORT ./boards/$BOARD arduino-cli upload --fqbn "$FQBN" --port "$PORT" ./boards/$BOARD
""" """
[tasks.monitor-raw] [tasks.monitor-raw]
@@ -86,7 +86,7 @@ exit 0
description = "Monitor agent with JSON log + command pipe (Python-based)" description = "Monitor agent with JSON log + command pipe (Python-based)"
depends = ["kill"] depends = ["kill"]
run = """ run = """
python3 ./scripts/monitor-agent.py "$BOARD" python3 ./scripts/monitor-agent.py "$BOARD" &
""" """
[tasks.log-tail] [tasks.log-tail]
@@ -215,4 +215,4 @@ echo "[OK] Generated .crush.json with FQBN: $FQBN"
run = "git add .; lumen draft | git commit -F - " run = "git add .; lumen draft | git commit -F - "
[env] [env]
BOARD = "esp32-32e" BOARD = "esp32-s3-lcd-43"