How ddehimer/elbdisplay works
1. Repository shape
- This repo contains a two-MCU embedded system plus the tooling/assets for the ESP32 display UI.
- The main runtime code is split into:
- RP2040 Code/: sensor acquisition and control firmware.
- CrowPanel7inch/: ESP32-based display/UI firmware, with two alternative UI projects.
- Root README: defines the cross-device architecture and UART contract.
2. System boundary
- The clean architectural boundary is between:
- RP2040 = real-time data/control node
- ESP32 display = UI, logging, and operator control node
- This separation is deliberate: timing-sensitive sensing stays on the RP2040, while the ESP32 handles the user-facing and storage-heavy work.
3. RP2040 firmware responsibilities
- The RP2040 side is a MicroPython-based control loop (main.py, current_control.py) with local drivers under drivers/.
- It reads hardware through I2C ADCs and related sensors:
- ads1115.py for ADC acquisition
- current_dac.py for current/output control
- temperature.py for temperature sensing
- Its job is to sample, calibrate, convert, and stream data deterministically.
4. RP2040 runtime model
- The root README describes the RP2040 as a non-blocking state machine with states like IDLE, ACTIVE, and ERROR.
- It emits structured telemetry over UART and responds to control commands such as start/stop.
- The included test scripts (tempTest.py, uart_test.py, test.py) suggest the RP2040 logic is also exercised in isolation during development.
5. ESP32 display responsibilities
- The ESP32 is the human interface and logging node.
- It owns:
- touch UI and screen rendering
- operator actions like start/stop and filename entry
- UART communication with the RP2040
- SD card CSV logging
- live status/error display
6. ESP32 UI implementation variants
- There are two parallel ESP32 UI projects under CrowPanel7inch/:
- Starter_EEZ-Open/: UI built from EEZ Studio / EEZ Open assets.
- Starter_SquareLineUX/: UI built from SquareLine Studio assets.
- They appear to solve the same display problem using different UI-generation toolchains, so for an architecture diagram they should be treated as alternative front-end implementations of the same ESP32 role.
7. ESP32 application structure
- Both ESP32 projects use PlatformIO and an LVGL-based UI stack.
- The code is split into:
- generated UI screens/styles/fonts/images
- application glue and event handlers
- display driver wrapper (lgfx/, likely LovyanGFX)
- communication/storage helpers
- In the SquareLineUX variant, notable subsystems include uart_link.*, sd_export.*, data_model.*, and generated screen/component files.
8. Data flow: measurement path
- The primary forward data path is:
- Sensors / current control hardware
- → RP2040 acquisition and processing
- → UART
- → ESP32 UI
- → screen display
- → SD card CSV append
- The ESP32 is not the source of measurement truth; it is a consumer and recorder of the RP2040 stream.
9. Data flow: control path
- The reverse path is operator-driven:
- touch input on ESP32
- → UI callback / application logic
- → UART command
- → RP2040 state transition
- The documented commands are simple ASCII lines such as START and STOP, which keeps debugging and integration straightforward.
10. Communication contract
- UART is the only runtime coupling between the MCUs.
- The protocol is intentionally line-delimited ASCII, with messages such as:
- DATA,...
- STATUS,...
- ERROR,...
- This means the two halves are loosely coupled: the ESP32 can be updated independently as long as the message format stays stable.
11. Storage and persistence
- SD card writing is exclusively on the ESP32 side.
- Logged data is written as CSV per session, which matches the repo’s stated separation of concerns: the RP2040 never touches filesystem concerns.
- The ESP32 project structure includes explicit export/logging helpers, reinforcing that storage is a first-class subsystem rather than UI side effect.
12. Board and platform setup
- CrowPanel7inch/BoardDefinition/ contains an ESP32-S3 board definition and install scripts, indicating the display hardware is a custom/declared board target rather than a generic dev kit.
- The ESP32 code targets an embedded graphics stack with project metadata, generated assets, and config headers such as lv_conf.h and touch.h.
13. Reusable/custom components
- Both ESP32 variants include a shared custom component library, including LabelCount.ecomp and a Crowbits_DHT20 library.
- This suggests the UI is not just static screens; it includes reusable widgets and at least one sensor-oriented library dependency in the display-side codebase.
14. What to show in an architecture diagram
- The diagram should center on two boxes:
- RP2040 firmware: acquisition + control + state machine
- ESP32 display firmware: UI + logging + operator control
- Between them, show a UART link carrying ASCII commands and telemetry.
- On the RP2040 side, show sensors/ADCs/DAC/temperature.
- On the ESP32 side, show touch UI, display rendering, and SD card CSV storage.
- Optionally annotate that the ESP32 UI has two implementation variants: EEZ Open and SquareLineUX.
Main entry points: main.py Main loop · main.cpp App entry · ui.c SquareLine UI · uart_link.cpp UART link
Components 16
Repository
Two-MCU embedded system plus ESP32 UI tooling
- Architecture · Cross-device system boundary and UART protocol
README.md
RP2040 firmware
Real-time sensing and control node
- Main loop · Entry point for acquisition and control state machine
RP2040 Code/main.py - Control logic · Non-blocking control and command handling
RP2040 Code/current_control.py - ADC driver · I2C ADC acquisition from measurement hardware
RP2040 Code/drivers/ads1115.py - Output control · Current and output control interface
RP2040 Code/drivers/current_dac.py - Temp sensing · Temperature measurement support
RP2040 Code/drivers/temperature.py - RP2040 tests · Standalone UART and sensor checks used during development
RP2040 Code/uart_test.py
ESP32 display
UI, operator control, and logging node
- App entry · ESP32 display firmware entry point
CrowPanel7inch/Starter_SquareLineUX/src/main.cpp - UART link · Line-delimited ASCII telemetry and commands
CrowPanel7inch/Starter_SquareLineUX/src/uart_link.cpp - Data model · Parsed telemetry and UI-facing state
CrowPanel7inch/Starter_SquareLineUX/src/data_model.cpp - CSV export · Session logging to SD card
CrowPanel7inch/Starter_SquareLineUX/src/sd_export.cpp - Display driver · LovyanGFX-style display and touch backend
CrowPanel7inch/Starter_SquareLineUX/src/lgfx/lgfx.cpp - Board setup · ESP32-S3 board definition and install scripts
CrowPanel7inch/BoardDefinition/esp32-s3-devkitc-1-myboard.json - Custom widgets · Reusable widget and sensor-oriented component library
CrowPanel7inch/Starter_SquareLineUX/components/LabelCount.ecomp
UI variants
Alternative front-end implementations for the ESP32
- SquareLine UI · Generated LVGL screens and event wiring
CrowPanel7inch/Starter_SquareLineUX/src/ui.c - EEZ Open UI · Alternative LVGL UI project built from EEZ assets
CrowPanel7inch/Starter_EEZ-Open/src/ui/ui.c
Connections 21
- Architecture → Main loop: defines · Documents RP2040 runtime role
- Architecture → App entry: defines · Documents ESP32 runtime role
- Main loop → Control logic: uses · Main loop drives state transitions
- Main loop → ADC driver: reads · Samples measurement hardware
- Main loop → Output control: controls · Drives current/output hardware
- Main loop → Temp sensing: reads · Monitors temperature channels
- Control logic → UART link: streams · Emits telemetry and accepts commands
- ADC driver → UART link: feeds · Acquired data is packaged for transport
- Temp sensing → UART link: feeds · Environmental data enters telemetry stream
- UART link → Data model: parses · Converts ASCII lines into UI state
- App entry → Display driver: renders · Initializes display and touch backend
- App entry → SquareLine UI: hosts · Runs the SquareLine-generated interface
- App entry → EEZ Open UI: alternative · Parallel EEZ Open front-end variant
- SquareLine UI → UART link: sends · Operator actions become UART commands
- SquareLine UI → CSV export: logs · UI triggers session CSV writing
- Data model → SquareLine UI: updates · Telemetry refreshes screen state
- CSV export → App entry: persists · Storage remains on ESP32 side
- Board setup → App entry: targets · Board definition configures firmware build
- Custom widgets → SquareLine UI: extends · Reusable components support the UI
- Custom widgets → EEZ Open UI: extends · Reusable components support the alternate UI
- RP2040 tests → Main loop: exercises · Development scripts validate runtime behavior