// // Klubhaus Doorbell — ESP32-S3-Touch-LCD-4.3 target // #include "DisplayDriverGFX.h" #include "board_config.h" #include "secrets.h" #include DisplayDriverGFX gfxDriver; DisplayManager display(&gfxDriver); DoorbellLogic logic(&display); void setup() { Serial.begin(115200); delay(500); logic.begin(FW_VERSION, BOARD_NAME, wifiNetworks, wifiNetworkCount); logic.finishBoot(); } void loop() { // ── Read touch ── TouchEvent evt = display.readTouch(); // ── State machine tick ── logic.update(); display.render(logic.getScreenState()); // ── Touch handling (tap gestures) ── const ScreenState& st = logic.getScreenState(); int tile = logic.handleTouch(evt); // ── Hold gesture (for silencing alerts) ── static int holdStartX = -1; static int holdStartY = -1; if(st.deviceState == DeviceState::ALERTING) { HoldState h = display.updateHold(HOLD_TO_SILENCE_MS); if(h.completed) { logic.silenceAlert(); holdStartX = -1; holdStartY = -1; } if(h.started) { holdStartX = evt.x; holdStartY = evt.y; } if(holdStartX >= 0) { if(h.active) { display.updateHint(holdStartX, holdStartY, true); } else { display.updateHint(holdStartX, holdStartY, false); } } } else { holdStartX = -1; holdStartY = -1; } if(Serial.available()) { String cmd = Serial.readStringUntil('\n'); cmd.trim(); if(cmd.length() > 0) logic.onSerialCommand(cmd); } }