Public Access
Restructure ESP32 firmware into modules, fix bugs, add tests
Structure (src/esp32/): - logic/: DisplayController, schedule, power timer, LED pattern; pure C++ - display/: FlipdotFrames and bitmaps - nano_link/: NanoLink (relay, serial, READY, bootloader) and flash bridge - net/: WiFi/OTA/panic window, Home Assistant - config.h with all settings; libs.h (globals in a header) removed Bug fixes: - Home Assistant switches now report their state back and start as ON - loop() no longer blocks: WiFi.waitForConnectResult() (up to 60 s without WiFi) and getLocalTime() (5 s before NTP sync) were called every iteration - Power switch off now powers off after 1 s even when a 30 s countdown is already running - millis() overflow safe power-off timer; no frame catch-up bursts - No garbage time string before NTP sync; 'Connecting...' stays instead - Frames are only sent when the screen changes instead of every second - Reset reasons are logged once instead of every 100 ms - Removed dead code (unused fonts, WiFiMulti, rotated bitmap, ...) Tests: new test_esp32 environment (26 tests); native renamed to test_nano Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cefb76c1ad
commit
683a47c055
29 files changed
+1289
-755
No files matched your search
@@ -0,0 +1,69 @@
|
||||
#pragma once
|
||||
|
||||
// All ESP32 settings. Credentials are in secrets.h (see secrets.example.h).
|
||||
// Kept free of Arduino types so the logic modules can be tested on the PC.
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Pins
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const int LED_PIN = 2; // built-in LED of the ESP32 DevKit v1
|
||||
const int RELAY_PIN = 13; // powers the panels and the Nano (LOW = on)
|
||||
|
||||
// Link to the Nano on UART2. Serial (UART0) stays free for USB / debug output.
|
||||
const int NANO_RX_PIN = 16; // wired to the Nano TX (through a 5V -> 3.3V divider)
|
||||
const int NANO_TX_PIN = 17; // wired to the Nano RX
|
||||
|
||||
// Optional: GPIO that resets the Nano through an NPN transistor (HIGH = reset), -1 = not wired.
|
||||
// Needed to flash a Nano with the Optiboot bootloader, which doesn't start after a power cycle.
|
||||
const int NANO_RESET_PIN = -1;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Display and Nano
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const uint8_t DISPLAY_WIDTH = 84;
|
||||
const uint8_t DISPLAY_HEIGHT = 19;
|
||||
const uint8_t PANEL_WIDTH = 28;
|
||||
|
||||
const uint16_t FLIP_TIME = 225; // flip pulse length in us, sent to the Nano at boot
|
||||
|
||||
const uint32_t NANO_BAUD = 115200;
|
||||
// Max wait for the Nano's READY after power on (also the wait when Nano TX is not wired to our RX)
|
||||
const uint32_t NANO_BOOT_TIMEOUT = 3000;
|
||||
|
||||
// After a frame is cleared, wait this long before cutting the power, so the dots can flip
|
||||
const uint32_t CLEAR_BEFORE_OFF_TIME = 1000;
|
||||
// Power off this long after the display is no longer needed (night, standby, logo)
|
||||
const uint32_t POWER_OFF_DELAY = 30000;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Flashing the Nano over WiFi (see README.md, pio run -e nano_ota -t upload)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const uint16_t NANO_FLASH_PORT = 2323;
|
||||
// The bootloader baud rate is chosen by the uploader (57600 old bootloader, 115200 Optiboot)
|
||||
const uint32_t NANO_POWER_OFF_TIME = 1000; // relay off time to make sure the Nano resets
|
||||
const uint32_t NANO_RESET_DELAY = 200; // after power on, before the reset pulse
|
||||
const uint32_t NANO_RESET_PULSE = 50;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Network, time and Home Assistant
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#define HOSTNAME "FlipDotDisplay"
|
||||
|
||||
// Europe/Amsterdam
|
||||
#define TIMEZONE "CET-1CEST,M3.5.0,M10.5.0/3"
|
||||
#define NTP_SERVER "pool.ntp.org"
|
||||
|
||||
// After a crash or unexpected reset, only run OTA for this long before starting the
|
||||
// main code, so a firmware that crashes at boot can still be replaced
|
||||
const uint32_t OTA_PANIC_WINDOW = 15000;
|
||||
|
||||
// Home Assistant device id (do not change: Home Assistant's entities are linked to it)
|
||||
const uint8_t HA_DEVICE_ID[] = {0x34, 0x86, 0x5d, 0x3a, 0x08, 0x28};
|
||||
#define HA_DEVICE_NAME "FlipDotDisplay"
|
||||
#define HA_SOFTWARE_VERSION "2.0.0"
|
||||
Reference in new issue
Block a user