55 lines
1.4 KiB
C++
55 lines
1.4 KiB
C++
//
|
|
// Klubhaus Doorbell — ESP32-32E target
|
|
//
|
|
|
|
#include <KlubhausCore.h>
|
|
#include "board_config.h"
|
|
#include "secrets.h"
|
|
#include "DisplayDriverTFT.h"
|
|
|
|
DisplayDriverTFT tftDriver;
|
|
DisplayManager display(&tftDriver);
|
|
DoorbellLogic logic(&display);
|
|
|
|
void setup() {
|
|
Serial.begin(115200);
|
|
delay(500);
|
|
|
|
logic.begin(FW_VERSION, BOARD_NAME, wifiNetworks, wifiNetworkCount);
|
|
logic.finishBoot();
|
|
}
|
|
|
|
void loop() {
|
|
// ── State machine tick ──
|
|
logic.update();
|
|
|
|
// ── Render current screen ──
|
|
display.render(logic.getScreenState());
|
|
|
|
// ── Touch handling ──
|
|
const ScreenState& st = logic.getScreenState();
|
|
|
|
if (st.deviceState == DeviceState::ALERTING) {
|
|
HoldState h = display.updateHold(HOLD_TO_SILENCE_MS);
|
|
if (h.completed) {
|
|
logic.silenceAlert();
|
|
}
|
|
if (!h.active) {
|
|
display.updateHint();
|
|
}
|
|
} else {
|
|
TouchEvent evt = display.readTouch();
|
|
if (evt.pressed && st.screen == ScreenID::DASHBOARD) {
|
|
int tile = display.dashboardTouch(evt.x, evt.y);
|
|
if (tile >= 0) Serial.printf("[DASH] Tile %d tapped\n", tile);
|
|
}
|
|
}
|
|
|
|
// ── Serial console ──
|
|
if (Serial.available()) {
|
|
String cmd = Serial.readStringUntil('\n');
|
|
cmd.trim();
|
|
if (cmd.length() > 0) logic.onSerialCommand(cmd);
|
|
}
|
|
}
|