snapshot
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
struct WiFiCred { const char *ssid; const char *pass; };
|
||||
static WiFiCred wifiNetworks[] = {
|
||||
{ "Dobro Veče", "goodnight" },
|
||||
{ "berylpunk", "dhgwilliam" },
|
||||
{ "iot-2GHz", "lesson-greater" },
|
||||
};
|
||||
static const int NUM_WIFI = sizeof(wifiNetworks) / sizeof(wifiNetworks[0]);
|
||||
|
||||
|
||||
@@ -7,6 +7,23 @@ void DisplayManager::begin() {
|
||||
|
||||
_tft.init();
|
||||
_tft.setRotation(1); // landscape: 480x320
|
||||
|
||||
// === DIAGNOSTIC: most basic text rendering ===
|
||||
_tft.fillScreen(TFT_BLUE);
|
||||
_tft.setTextColor(TFT_WHITE); // no background color arg
|
||||
_tft.setTextFont(1); // explicitly set GLCD font
|
||||
_tft.setTextSize(3);
|
||||
_tft.setCursor(10, 10); // absolute position, no datum
|
||||
_tft.print("HELLO");
|
||||
_tft.setCursor(10, 60);
|
||||
_tft.print("W:");
|
||||
_tft.print(_tft.width());
|
||||
_tft.setCursor(10, 110);
|
||||
_tft.print("H:");
|
||||
_tft.print(_tft.height());
|
||||
delay(5000);
|
||||
// === END DIAGNOSTIC ===
|
||||
|
||||
_tft.fillScreen(COL_BLACK);
|
||||
}
|
||||
|
||||
@@ -188,10 +205,19 @@ void DisplayManager::drawStatusScreen(const ScreenState& s) {
|
||||
s.deviceState == DeviceState::SILENT ? COL_GREEN : COL_NEON_TEAL;
|
||||
drawInfoLine(x, y, stCol, buf); y += sp;
|
||||
|
||||
if (strlen(s.alertMessage) > 0) {
|
||||
snprintf(buf, sizeof(buf), "Last: %.40s", s.alertMessage);
|
||||
drawInfoLine(x, y, COL_DARK_GRAY, buf); y += sp;
|
||||
// Recent alerts
|
||||
if (s.alertHistoryCount > 0) {
|
||||
drawInfoLine(x, y, COL_MINT, "Recent Alerts:"); y += sp;
|
||||
for (int i = 0; i < s.alertHistoryCount; i++) {
|
||||
uint16_t col = (i == 0) ? COL_YELLOW : COL_DARK_GRAY;
|
||||
snprintf(buf, sizeof(buf), "%s %.35s",
|
||||
s.alertHistory[i].timestamp,
|
||||
s.alertHistory[i].message);
|
||||
drawInfoLine(x, y, col, buf); y += sp;
|
||||
}
|
||||
} else {
|
||||
drawInfoLine(x, y, COL_DARK_GRAY, "No alerts yet"); y += sp;
|
||||
}
|
||||
|
||||
if (s.debugMode) {
|
||||
drawInfoLine(x, y, COL_YELLOW, "DEBUG MODE - _test topics");
|
||||
|
||||
@@ -117,11 +117,11 @@ void DoorbellLogic::update() {
|
||||
|
||||
switch (_state) {
|
||||
case DeviceState::ALERTING:
|
||||
if (now - _alertStart > ALERT_TIMEOUT_MS) {
|
||||
Serial.println("[ALERT] Timeout — auto-silencing");
|
||||
handleSilence("timeout");
|
||||
break;
|
||||
}
|
||||
// if (now - _alertStart > ALERT_TIMEOUT_MS) {
|
||||
// Serial.println("[ALERT] Timeout — auto-silencing");
|
||||
// handleSilence("timeout");
|
||||
// break;
|
||||
// }
|
||||
if (now - _lastBlink >= BLINK_INTERVAL_MS) {
|
||||
_lastBlink = now;
|
||||
_blinkState = !_blinkState;
|
||||
@@ -251,7 +251,21 @@ void DoorbellLogic::transitionTo(DeviceState newState) {
|
||||
void DoorbellLogic::handleAlert(const String& msg) {
|
||||
if (_state == DeviceState::ALERTING && _currentMessage == msg) return;
|
||||
_currentMessage = msg;
|
||||
_alertMsgEpoch = _lastParsedMsgEpoch; // store ntfy server time of this alert
|
||||
_alertMsgEpoch = _lastParsedMsgEpoch;
|
||||
|
||||
// Push into history (shift older entries down)
|
||||
for (int i = ALERT_HISTORY_SIZE - 1; i > 0; i--) {
|
||||
_screen.alertHistory[i] = _screen.alertHistory[i - 1];
|
||||
}
|
||||
strncpy(_screen.alertHistory[0].message, msg.c_str(), 63);
|
||||
_screen.alertHistory[0].message[63] = '\0';
|
||||
strncpy(_screen.alertHistory[0].timestamp,
|
||||
_ntpSynced ? _timeClient->getFormattedTime().c_str() : "??:??:??", 11);
|
||||
_screen.alertHistory[0].timestamp[11] = '\0';
|
||||
|
||||
if (_screen.alertHistoryCount < ALERT_HISTORY_SIZE)
|
||||
_screen.alertHistoryCount++;
|
||||
|
||||
Serial.printf("[ALERT] Accepted. ntfy time=%ld\n", (long)_alertMsgEpoch);
|
||||
transitionTo(DeviceState::ALERTING);
|
||||
queueStatus("ALERTING", msg);
|
||||
|
||||
@@ -21,6 +21,13 @@ enum class ScreenID : uint8_t {
|
||||
OFF // backlight off, nothing to draw
|
||||
};
|
||||
|
||||
#define ALERT_HISTORY_SIZE 3
|
||||
|
||||
struct AlertRecord {
|
||||
char message[64] = "";
|
||||
char timestamp[12] = ""; // "HH:MM:SS"
|
||||
};
|
||||
|
||||
// Everything the display needs to render any screen
|
||||
struct ScreenState {
|
||||
ScreenID screen = ScreenID::BOOT_SPLASH;
|
||||
@@ -47,6 +54,11 @@ struct ScreenState {
|
||||
|
||||
// Debug
|
||||
bool debugMode = false;
|
||||
|
||||
// Alert history (newest first)
|
||||
AlertRecord alertHistory[ALERT_HISTORY_SIZE] = {};
|
||||
int alertHistoryCount = 0;
|
||||
|
||||
};
|
||||
|
||||
// Touch event passed from display to logic
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
// ===== User_Setup.h for E32R35T (ESP32-32E 3.5" Display) =====
|
||||
#define USER_SETUP_LOADED
|
||||
|
||||
#define ST7796_DRIVER
|
||||
|
||||
#define TFT_WIDTH 320
|
||||
#define TFT_HEIGHT 480
|
||||
|
||||
// LCD pins (HSPI bus)
|
||||
#define TFT_CS 15
|
||||
#define TFT_DC 2 // Called "TFT_RS" on the board
|
||||
#define TFT_RST -1 // RST is tied to EN (ESP32 reset pin), not a GPIO
|
||||
#define TFT_MOSI 13
|
||||
#define TFT_SCLK 14
|
||||
#define TFT_MISO 12
|
||||
|
||||
// Backlight
|
||||
#define TFT_BL 27
|
||||
#define TFT_BACKLIGHT_ON HIGH
|
||||
|
||||
// Touch (XPT2046, shares HSPI bus with LCD)
|
||||
#define TOUCH_CS 33
|
||||
|
||||
// Use HSPI port (not default VSPI)
|
||||
#define USE_HSPI_PORT
|
||||
|
||||
// SPI Frequencies
|
||||
#define SPI_FREQUENCY 27000000
|
||||
#define SPI_READ_FREQUENCY 20000000
|
||||
#define SPI_TOUCH_FREQUENCY 2500000
|
||||
|
||||
#define SUPPORT_TRANSACTIONS
|
||||
|
||||
@@ -16,6 +16,16 @@
|
||||
DisplayManager display;
|
||||
DoorbellLogic logic;
|
||||
|
||||
#include <TFT_eSPI.h>
|
||||
|
||||
#ifndef LOAD_GLCD
|
||||
#error "LOAD_GLCD is NOT defined — fonts missing!"
|
||||
#endif
|
||||
|
||||
#ifndef ST7796_DRIVER
|
||||
#error "ST7796_DRIVER is NOT defined — wrong setup!"
|
||||
#endif
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
unsigned long t = millis();
|
||||
|
||||
Reference in New Issue
Block a user