How finntrannn/esp32_matrixcountdownclock works
1. Project shape and runtime
- This is an ESP32 firmware project built with PlatformIO + Arduino C++.
- It targets a 64x32 HUB75 LED matrix and uses the ESP32 as the control plane for display, networking, time sync, and sensor reading.
2. Top-level execution model
- src/main.cpp is the bootstrapping entry point.
- The runtime is organized around a small set of manager-style subsystems rather than a large monolith: display, network, time, sensors, and web configuration.
- The README indicates the firmware is designed to keep the display refresh path isolated from heavier work, with FreeRTOS-style concurrency / dual-core separation so graphics stay smooth while networking and I/O run elsewhere.
3. Core shared state
- include/AppState.h / src/AppState.cpp are the central state container.
- This likely holds current mode, configuration, timing data, network status, sensor values, and any active screen/effect selection.
- Other modules appear to read/write through this shared state rather than communicating directly, making AppState the main boundary for configuration and runtime status.
4. Display subsystem
- include/DisplayManager.h / src/DisplayManager.cpp are the primary bridge to the HUB75 matrix hardware.
- This layer is responsible for rendering the active screen, brightness, overlays such as Wi‑Fi indicators, borders, and any animated effects.
- It is the most time-sensitive part of the system and is architecturally separated from network and web logic.
5. Screen/page architecture
- The include/screens and src/screens directories define multiple display modes:
- CountdownScreen
- DateTimeScreen
- SensorScreen
- TextScreen
- RandomSpinnerScreen
- These are not separate apps; they are UI states that the display manager can switch between, likely under control of AppState.
- This gives the firmware a screen-based presentation layer where each screen owns its own rendering logic and can participate in auto-cycle behavior.
6. Visual effects
- include/FireworksEffect.h / src/FireworksEffect.cpp implement a dedicated animation effect.
- The README describes scheduled fireworks, so this effect is likely triggered by time rules managed elsewhere, then rendered through the display layer.
- This is a separate concern from the normal screens, which suggests a reusable animation overlay or full-screen effect path.
7. Time and countdown logic
- include/TimeManager.h / src/TimeManager.cpp handle RTC/NTP-derived time, target time calculation, and countdown math.
- The countdown screen and fireworks scheduling both depend on this subsystem.
- Architecturally, this is the time authority for the system: it feeds real-world time into display modes and schedules.
8. Sensor acquisition
- include/DHTSensor.h / src/DHTSensor.cpp encapsulate the DHT11 temperature/humidity sensor.
- The sensor data is exposed to the display and likely stored in shared state for the sensor screen and any status widgets.
- This module is isolated from UI logic so sensor polling can happen independently of rendering.
9. Network and provisioning
- include/NetworkManager.h / src/NetworkManager.cpp manage Wi‑Fi connectivity and AP/client behavior.
- The README shows an initial captive portal / soft AP provisioning flow (THPT_QG_Config), with subsequent joining to a home Wi‑Fi network for NTP and remote control.
- Network status also feeds the display, since the firmware can show a Wi‑Fi icon or similar connectivity indicator.
10. Web configuration and remote control
- include/WebConfigServer.h / src/WebConfigServer.cpp expose the HTTP-based configuration UI.
- Supporting assets and strings live in include/WebUI_Static.h and include/WebStrings.h, which suggests the web app is embedded in firmware as static content rather than served from external storage.
- This server is the main operator interface for changing settings like target countdown time, screen rotation/cycle behavior, brightness, colors, Wi‑Fi credentials, and OTA updates.
11. Configuration boundaries
- include/Config.h is the hardware and system configuration boundary: GPIO mappings, board-specific settings, and likely feature toggles.
- The README specifically calls out DHT11 pin assignment and HUB75 wiring compatibility with the display library’s expected pinout.
- Persistent user settings are saved to non-volatile memory, so runtime state and user configuration are distinct.
12. Primary data flow
- The typical flow is: user configures via web UI or AP portal → settings are persisted → network/time sync and sensor polling run in background → AppState updates → DisplayManager renders the active screen/effect.
- Time-driven features like countdown and fireworks use the time manager; sensor-driven features use the DHT module; both converge in the screen layer for presentation.
13. User experience modes
- The firmware supports several high-level modes: countdown clock, date/time display, sensor readout, scrolling text, random number spinner, splash screen, and automatic cycling between them.
- These are all coordinated by shared state and the display manager, rather than being separate executables or services.
14. Repo structure and operational notes
- demo/ contains example images for documentation, not runtime logic.
- lib/ and test/ are present but minimal, so the project is primarily organized as a single firmware application with internal modules rather than a library ecosystem or large test suite.
- .github/workflows/platformio_build.yml indicates CI builds the firmware through PlatformIO, reinforcing that the main deployment artifact is a compiled ESP32 firmware image.
Main entry points: DisplayManager.cpp DisplayManager · main.cpp main · WebConfigServer.cpp WebConfigServer · AppState.cpp AppState
Components 17
Core firmware
Boot, shared state, hardware control, and system services
- main · Firmware bootstrap and runtime wiring
src/main.cpp - AppState · Central runtime/configuration state
src/AppState.cpp - Config · Board pins, feature flags, and system constants
include/Config.h - DisplayManager · HUB75 matrix rendering and display coordination
src/DisplayManager.cpp - TimeManager · RTC/NTP time authority and countdown math
src/TimeManager.cpp - DHTSensor · Temperature and humidity acquisition
src/DHTSensor.cpp - NetworkManager · Wi-Fi AP/client setup and connection state
src/NetworkManager.cpp - Fireworks · Scheduled animation effect for celebrations
src/FireworksEffect.cpp
Screens
Presentation modes rendered on the LED matrix
- SplashScreen · Startup display shown during boot
src/SplashScreen.cpp - Countdown · Target-time countdown presentation
src/screens/CountdownScreen.cpp - DateTime · Current date and time display
src/screens/DateTimeScreen.cpp - Sensor · Temperature and humidity readout
src/screens/SensorScreen.cpp - Text · Scrolling or fixed text display
src/screens/TextScreen.cpp - Spinner · Random number spinner display
src/screens/RandomSpinnerScreen.cpp
Config UI
Embedded web configuration and static UI assets
- WebConfigServer · Embedded configuration and remote control server
src/WebConfigServer.cpp - Web UI · Static HTML/CSS/JS served by the config server
include/WebUI_Static.h - Strings · Labels and messages for the web interface
include/WebStrings.h
Connections 24
- main → Config: loads · Reads hardware and build-time settings
- main → AppState: initializes · Creates shared runtime state
- main → DisplayManager: starts · Brings up matrix rendering
- main → NetworkManager: starts · Begins Wi-Fi/provisioning flow
- main → TimeManager: starts · Enables time synchronization
- main → DHTSensor: starts · Begins sensor polling
- main → WebConfigServer: starts · Launches configuration server
- NetworkManager → WebConfigServer: hosts · Provides network access for config UI
- WebConfigServer → Web UI: serves · Embedded web application assets
- WebConfigServer → Strings: labels · Uses UI text and messages
- WebConfigServer → AppState: updates · Writes user settings into shared state
- TimeManager → AppState: publishes · Stores current time and countdown status
- DHTSensor → AppState: publishes · Stores latest temperature and humidity
- DisplayManager → AppState: reads · Consumes current mode and status
- DisplayManager → SplashScreen: renders · Shows startup splash when booting
- DisplayManager → Countdown: renders · Delegates countdown view
- DisplayManager → DateTime: renders · Delegates clock/date view
- DisplayManager → Sensor: renders · Delegates sensor view
- DisplayManager → Text: renders · Delegates text view
- DisplayManager → Spinner: renders · Delegates spinner view
- DisplayManager → Fireworks: animates · Plays celebration effect on matrix
- TimeManager → Countdown: drives · Supplies countdown timing and target math
- TimeManager → Fireworks: triggers · Schedules fireworks at configured times
- DHTSensor → Sensor: feeds · Provides temperature/humidity values