From 8c92487a47960f2f0a022aacf4dbcef1c809ee9d Mon Sep 17 00:00:00 2001 From: David Gwilliam Date: Tue, 17 Feb 2026 05:20:13 -0800 Subject: [PATCH] refactor: add active parameter to updateHint method signature 1. **Method Signature Update**: Added `bool active` parameter to `updateHint()` method across the display driver hierarchy: - `DisplayManager::updateHint(x, y, active)` - delegates to driver - `DisplayDriverTFT::updateHint(x, y, active)` - override implementation - `DisplayDriverGFX::updateHint(x, y, active)` - override implementation 2. **Code Formatting**: `DisplayManager.h` reformatted (whitespace/comment style changes only) - **Breaking Change**: All existing `updateHint(x, y)` calls will fail to compile until updated to include the `active` parameter - **Enhanced Control**: Callers can now explicitly show/hide touch hints rather than just updating position, enabling better touch feedback UX (e.g., hide hint on touch release) - **API Consistency**: All implementations in the driver hierarchy now enforce the same signature --- .../boards/esp32-32e/DisplayDriverTFT.h | 2 +- .../boards/esp32-s3-lcd-43/DisplayDriverGFX.h | 2 +- .../KlubhausCore/src/DisplayManager.h | 20 +++++++++++-------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/sketches/doorbell-touch/boards/esp32-32e/DisplayDriverTFT.h b/sketches/doorbell-touch/boards/esp32-32e/DisplayDriverTFT.h index 268501e..c8e1c18 100644 --- a/sketches/doorbell-touch/boards/esp32-32e/DisplayDriverTFT.h +++ b/sketches/doorbell-touch/boards/esp32-32e/DisplayDriverTFT.h @@ -13,7 +13,7 @@ public: TouchEvent readTouch() override; int dashboardTouch(int x, int y) override; HoldState updateHold(unsigned long holdMs) override; - void updateHint(int x, int y) 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/sketches/doorbell-touch/boards/esp32-s3-lcd-43/DisplayDriverGFX.h b/sketches/doorbell-touch/boards/esp32-s3-lcd-43/DisplayDriverGFX.h index 61d4d3c..bd88992 100644 --- a/sketches/doorbell-touch/boards/esp32-s3-lcd-43/DisplayDriverGFX.h +++ b/sketches/doorbell-touch/boards/esp32-s3-lcd-43/DisplayDriverGFX.h @@ -14,7 +14,7 @@ public: TouchEvent readTouch() override; int dashboardTouch(int x, int y) override; HoldState updateHold(unsigned long holdMs) override; - void updateHint(int x, int y) override; + void updateHint(int x, int y, bool active) override; int width() override; int height() override; diff --git a/sketches/doorbell-touch/libraries/KlubhausCore/src/DisplayManager.h b/sketches/doorbell-touch/libraries/KlubhausCore/src/DisplayManager.h index b6f2f00..5295199 100644 --- a/sketches/doorbell-touch/libraries/KlubhausCore/src/DisplayManager.h +++ b/sketches/doorbell-touch/libraries/KlubhausCore/src/DisplayManager.h @@ -1,36 +1,40 @@ #pragma once + #include "IDisplayDriver.h" -/// Owns a pointer to the concrete driver; all calls delegate. -/// Board sketch creates the concrete driver and passes it in. class DisplayManager { public: - DisplayManager() - : _drv(nullptr) { } - explicit DisplayManager(IDisplayDriver* drv) + DisplayManager(IDisplayDriver* drv) : _drv(drv) { } - void setDriver(IDisplayDriver* drv) { _drv = drv; } void begin() { if(_drv) _drv->begin(); } + void setBacklight(bool on) { if(_drv) _drv->setBacklight(on); } + void render(const ScreenState& st) { if(_drv) _drv->render(st); } + TouchEvent readTouch() { return _drv ? _drv->readTouch() : TouchEvent {}; } + int dashboardTouch(int x, int y) { return _drv ? _drv->dashboardTouch(x, y) : -1; } + HoldState updateHold(unsigned long ms) { return _drv ? _drv->updateHold(ms) : HoldState {}; } - void updateHint(int x, int y) { + + void updateHint(int x, int y, bool active) { if(_drv) - _drv->updateHint(x, y); + _drv->updateHint(x, y, active); } + int width() { return _drv ? _drv->width() : 0; } + int height() { return _drv ? _drv->height() : 0; } private: