refactor(doorbell-touch): extract board configs and improve logging

This commit is contained in:
2026-02-18 02:02:35 -08:00
parent ea8aab0a68
commit 5ce02a6eff
5 changed files with 79 additions and 76 deletions

View File

@@ -133,7 +133,8 @@ void DoorbellLogic::update() {
default:
// Inactivity timeout: turn off screen after no activity
if(_state.screen != ScreenID::OFF && now - _lastActivityMs > INACTIVITY_TIMEOUT_MS) {
Serial.println("[STATE] Inactivity timeout → OFF");
Serial.printf("[%lu] [STATE] Inactivity timeout (%lu ms) → OFF\n",
millis(), now - _lastActivityMs);
_state.screen = ScreenID::OFF;
_display->setBacklight(false);
_state.backlightOn = false;
@@ -229,10 +230,12 @@ void DoorbellLogic::onAdmin(const String& cmd) {
delay(500);
ESP.restart();
} else if(cmd == "dashboard") {
Serial.printf("[%lu] [ADMIN] dashboard\n", millis());
_state.screen = ScreenID::DASHBOARD;
_display->setBacklight(true);
_state.backlightOn = true;
} else if(cmd == "off") {
Serial.printf("[%lu] [ADMIN] off\n", millis());
_state.screen = ScreenID::OFF;
_display->setBacklight(false);
_state.backlightOn = false;
@@ -312,7 +315,7 @@ int DoorbellLogic::handleTouch(const TouchEvent& evt) {
_lastActivityMs = millis();
if(_state.screen == ScreenID::OFF) {
Serial.println("[TOUCH] OFF → DASHBOARD");
Serial.printf("[%lu] [TOUCH] OFF → DASHBOARD\n", millis());
setScreen(ScreenID::DASHBOARD);
return -1;
}