From dd1c13fbbc8ade1353d66c98b68ad9bf7d202676 Mon Sep 17 00:00:00 2001 From: David Gwilliam Date: Thu, 19 Feb 2026 15:12:02 -0800 Subject: [PATCH] refactor: replace hint feedback with debug crosshair --- boards/esp32-32e-4/DisplayDriverTFT.cpp | 8 ---- boards/esp32-32e-4/DisplayDriverTFT.h | 1 - boards/esp32-32e/DisplayDriverTFT.cpp | 8 ---- boards/esp32-32e/DisplayDriverTFT.h | 1 - boards/esp32-s3-lcd-43/DisplayDriverGFX.cpp | 18 ++------ boards/esp32-s3-lcd-43/DisplayDriverGFX.h | 2 +- libraries/KlubhausCore/src/DisplayManager.h | 46 +------------------- libraries/KlubhausCore/src/DoorbellLogic.cpp | 13 ++---- libraries/KlubhausCore/src/IDisplayDriver.h | 2 +- mise.toml | 8 ++-- 10 files changed, 16 insertions(+), 91 deletions(-) diff --git a/boards/esp32-32e-4/DisplayDriverTFT.cpp b/boards/esp32-32e-4/DisplayDriverTFT.cpp index 44e1dd4..5fcf64d 100644 --- a/boards/esp32-32e-4/DisplayDriverTFT.cpp +++ b/boards/esp32-32e-4/DisplayDriverTFT.cpp @@ -348,11 +348,3 @@ HoldState DisplayDriverTFT::updateHold(unsigned long holdMs) { } 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(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); -} diff --git a/boards/esp32-32e-4/DisplayDriverTFT.h b/boards/esp32-32e-4/DisplayDriverTFT.h index 46468c7..bfaa807 100644 --- a/boards/esp32-32e-4/DisplayDriverTFT.h +++ b/boards/esp32-32e-4/DisplayDriverTFT.h @@ -12,7 +12,6 @@ public: void render(const ScreenState& state) override; TouchEvent readTouch() override; HoldState updateHold(unsigned long holdMs) override; - void updateHint(int x, int y, bool active) override; int width() override { return _tft.width(); } int height() override { return _tft.height(); } diff --git a/boards/esp32-32e/DisplayDriverTFT.cpp b/boards/esp32-32e/DisplayDriverTFT.cpp index 91cbced..b6aa745 100644 --- a/boards/esp32-32e/DisplayDriverTFT.cpp +++ b/boards/esp32-32e/DisplayDriverTFT.cpp @@ -326,11 +326,3 @@ HoldState DisplayDriverTFT::updateHold(unsigned long holdMs) { } 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(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); -} diff --git a/boards/esp32-32e/DisplayDriverTFT.h b/boards/esp32-32e/DisplayDriverTFT.h index b8a24ab..8739ff4 100644 --- a/boards/esp32-32e/DisplayDriverTFT.h +++ b/boards/esp32-32e/DisplayDriverTFT.h @@ -13,7 +13,6 @@ public: TouchEvent readTouch() override; int dashboardTouch(int x, int y); HoldState updateHold(unsigned long holdMs) override; - void updateHint(int x, int y, bool active) override; int width() override { return DISPLAY_WIDTH; } int height() override { return DISPLAY_HEIGHT; } diff --git a/boards/esp32-s3-lcd-43/DisplayDriverGFX.cpp b/boards/esp32-s3-lcd-43/DisplayDriverGFX.cpp index 0f6a4e3..937fd76 100644 --- a/boards/esp32-s3-lcd-43/DisplayDriverGFX.cpp +++ b/boards/esp32-s3-lcd-43/DisplayDriverGFX.cpp @@ -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) return; - static uint32_t lastTime = 0; - uint32_t now = millis(); - if(now - lastTime < 100) - 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(30.0f + 30.0f * sinf(t * 2.0f * 3.14159f)); - uint16_t col = _gfx->color565(v, v, v); - - _gfx->drawCircle(x, y, 50, col); + const int size = 20; + _gfx->drawLine(x - size, y, x + size, y, TFT_RED); + _gfx->drawLine(x, y - size, x, y + size, TFT_RED); } diff --git a/boards/esp32-s3-lcd-43/DisplayDriverGFX.h b/boards/esp32-s3-lcd-43/DisplayDriverGFX.h index 9a65942..5572d4c 100644 --- a/boards/esp32-s3-lcd-43/DisplayDriverGFX.h +++ b/boards/esp32-s3-lcd-43/DisplayDriverGFX.h @@ -13,7 +13,7 @@ public: TouchEvent readTouch() 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 height() override; diff --git a/libraries/KlubhausCore/src/DisplayManager.h b/libraries/KlubhausCore/src/DisplayManager.h index 159f377..93e12c1 100644 --- a/libraries/KlubhausCore/src/DisplayManager.h +++ b/libraries/KlubhausCore/src/DisplayManager.h @@ -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 diff --git a/libraries/KlubhausCore/src/DoorbellLogic.cpp b/libraries/KlubhausCore/src/DoorbellLogic.cpp index 3bb5060..f46d7da 100644 --- a/libraries/KlubhausCore/src/DoorbellLogic.cpp +++ b/libraries/KlubhausCore/src/DoorbellLogic.cpp @@ -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; } diff --git a/libraries/KlubhausCore/src/IDisplayDriver.h b/libraries/KlubhausCore/src/IDisplayDriver.h index 123fdbe..5210e40 100644 --- a/libraries/KlubhausCore/src/IDisplayDriver.h +++ b/libraries/KlubhausCore/src/IDisplayDriver.h @@ -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; diff --git a/mise.toml b/mise.toml index 9beebfb..2fcc49d 100644 --- a/mise.toml +++ b/mise.toml @@ -28,10 +28,10 @@ arduino-cli compile --fqbn "$FQBN" --libraries ./libraries $LIBS --build-propert [tasks.upload] description = "Upload (uses BOARD env var)" -depends = ["compile", "kill"] +depends = ["kill"] run = """ 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] @@ -86,7 +86,7 @@ exit 0 description = "Monitor agent with JSON log + command pipe (Python-based)" depends = ["kill"] run = """ -python3 ./scripts/monitor-agent.py "$BOARD" +python3 ./scripts/monitor-agent.py "$BOARD" & """ [tasks.log-tail] @@ -215,4 +215,4 @@ echo "[OK] Generated .crush.json with FQBN: $FQBN" run = "git add .; lumen draft | git commit -F - " [env] -BOARD = "esp32-32e" +BOARD = "esp32-s3-lcd-43"