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:
mangavalkandClaude Opus 5.5 committed 2026-10-13 00:56:32 +02:00
1 parent cefb76c1ad
commit 683a47c055
29 files changed
+1289 -755

No files matched your search

+20 -7
View File
@@ -4,13 +4,14 @@
; nano_ota Same Nano firmware, flashed over WiFi through the ESP32
; esp32 ESP32 "brain" (WiFi, NTP clock, Home Assistant) - OTA upload
; esp32_usb Same ESP32 firmware, flashed over USB (first flash / recovery)
; native Unit tests for the Nano firmware, run on the PC (needs gcc on PATH)
; test_nano Unit tests for the Nano firmware, run on the PC (needs gcc on PATH)
; test_esp32 Unit tests for the ESP32 logic, run on the PC
;
; Build all: pio run
; Build one: pio run -e nano
; Upload one: pio run -e nano -t upload
; Serial monitor: pio device monitor -e nano
; Run tests: pio test -e native
; Run tests: pio test -e test_nano -e test_esp32
;
; https://docs.platformio.org/page/projectconf.html
@@ -22,7 +23,7 @@ framework = arduino
monitor_speed = 115200
lib_deps =
adafruit/Adafruit GFX Library@^1.10.12
; Tests only run in the native environment, never on the boards
; Tests only run in the test_* environments on the PC, never on the boards
test_ignore = *
; ---------------------------------------------------------------------------
@@ -58,7 +59,7 @@ board = esp32doit-devkit-v1
build_src_filter = +<esp32/>
; ESPSERIAL turns the BROSE9323 driver into a serial client: every draw call is
; sent to the Nano as a text command instead of toggling GPIO pins.
build_flags = -D ESPSERIAL
build_flags = -D ESPSERIAL -I src/esp32
lib_deps =
${env.lib_deps}
https://github.com/robjen/GFX_fonts.git
@@ -74,15 +75,27 @@ upload_protocol = esptool
upload_port = COM11
; ---------------------------------------------------------------------------
; Native - unit tests for the Nano firmware on the PC (test/test_nano)
; The Arduino core, EEPROM and the display driver are replaced by test/mocks.
; Unit tests on the PC (pio test -e test_nano -e test_esp32)
; ---------------------------------------------------------------------------
[env:native]
[native]
platform = native
framework =
lib_deps =
lib_ignore = BROSE9323
test_ignore =
test_build_src = yes
; Nano firmware (test/test_nano). The Arduino core, EEPROM and the display driver are
; replaced by test/mocks.
[env:test_nano]
extends = native
test_filter = test_nano
build_src_filter = +<nano/>
build_flags = -std=gnu++17 -I test/mocks
; ESP32 logic (test/test_esp32): only the modules without Arduino dependencies
[env:test_esp32]
extends = native
test_filter = test_esp32
build_src_filter = +<esp32/logic/>
build_flags = -std=gnu++17 -I src/esp32