refactor(touch): centralize touch handling in DoorbellLogic
This commit is contained in:
@@ -278,3 +278,29 @@ void DoorbellLogic::setScreen(ScreenID s) {
|
||||
_display->setBacklight(needsBacklight);
|
||||
_state.backlightOn = needsBacklight;
|
||||
}
|
||||
|
||||
int DoorbellLogic::handleTouch(const TouchEvent& evt) {
|
||||
if(!evt.pressed)
|
||||
return -1;
|
||||
|
||||
if(_state.screen == ScreenID::OFF) {
|
||||
Serial.println("[TOUCH] OFF → DASHBOARD");
|
||||
setScreen(ScreenID::DASHBOARD);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(_state.screen == ScreenID::DASHBOARD) {
|
||||
int tile = _display->dashboardTouch(evt.x, evt.y);
|
||||
if(tile >= 0) {
|
||||
Serial.printf("[DASH] Tile %d tapped\n", tile);
|
||||
}
|
||||
return tile;
|
||||
}
|
||||
|
||||
if(_state.screen == ScreenID::ALERT) {
|
||||
Serial.println("[TOUCH] ALERT tap");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ public:
|
||||
/// Externally trigger silence (e.g. hold-to-silence gesture).
|
||||
void silenceAlert();
|
||||
void setScreen(ScreenID s);
|
||||
/// Handle touch input — returns dashboard tile index if tapped, or -1.
|
||||
int handleTouch(const TouchEvent& evt);
|
||||
|
||||
private:
|
||||
void pollTopics();
|
||||
|
||||
Reference in New Issue
Block a user