julian 0b31c6f5f7 Add Driveline screen; stop displaying values that were never measured
New hand-coded LVGL screen (src/modules/driveline_screen.*) showing only
signals verified on this bus: gear as the hero, coolant and gearbox oil temp
flanking it, an engine RPM bar, and turbine / output-shaft speeds, plus
ignition, engine-run, converter-clutch, gearbox-cooling and gear-mismatch
status. Reached by swiping right from Home.

It lives in src/ and hooks its gesture onto the Home screen at RUNTIME rather
than editing ui_Home_Screen.c, because SquareLine Studio overwrites
include/ui/ on every export - that is how the CAN toggle's event handler went
missing. LVGL dispatches to every registered callback, so the runtime hook
coexists with the generated left-swipe handler instead of replacing it. Same
reasoning the existing meters_manager already follows.

Output shaft is labelled "raw" and shown as counts: the x0.125 scaling is
still a hypothesis, so inventing a unit here would launder it into fact.

Also fixes a defect found while wiring this up: main.cpp updated the Home
screen's meters and battery label unconditionally, but those fields are
pre-seeded with DEFAULT_* constants. With no CAN data the display showed a
confident 92.0degC engine oil temp and 12.45V battery that had never been
measured. Two of them have no source on this bus at all - engine oil temp has
no sensor (0x1D0 byte 1 is permanently 0xFF), and 0x3B4 publishes the
battery's not-available marker on nearly every frame. Now gated on
valid_flags, so an unmeasured value reads "--.--" instead of a plausible lie.

Same class of bug in the driver: 0x3B4's U_BT was accepted even when it read
0xFFF, which would have put a confident 61V on screen. Now rejected, leaving
the valid flag clear.

Decodes ignition state from 0x3B4 byte 2 (user-verified: 0x00 = on, 0x09 =
off, unmoved by the engine starting). Both the E65 repo (ST_ENGINE_RUN) and
the E60 VFL sheet (engine flag, 0x09 = running) are wrong about this field on
our bus - inverted and mislabelled. Noted at the definition so it doesn't get
"corrected" back. It also restores ignition sensing, which we thought was
lost with CAS/0x130 absent from the swap.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-17 16:23:10 +02:00
2026-07-15 12:17:06 +02:00
2026-07-15 12:17:06 +02:00
2026-07-15 12:17:06 +02:00

ESP32-S3-LCD-5B - PlatformIO Version

Automotive display controller for Waveshare ESP32-S3-Touch-LCD-5B (1024x600 RGB LCD).

Features

  • ✅ WiFi - Network scanning with dynamic SSID list
  • ✅ UART - Automotive data transmission @ 5Hz (GPIO 43/44)
  • ✅ Debug Mode - FPS and CPU metrics display
  • ✅ Settings Persistence - NVS storage for toggle states
  • ✅ Touch UI - LVGL 8.4.0 with SquareLine Studio UI
  • ✅ FreeRTOS - Multi-core architecture (WiFi/UART on Core 0, LVGL on Core 1)

Hardware

  • Board: Waveshare ESP32-S3-Touch-LCD-5B
  • Display: 1024x600 RGB LCD (5-inch capacitive touch)
  • MCU: ESP32-S3 dual-core @ 240MHz
  • Flash: 16MB
  • PSRAM: 8MB OPI PSRAM

Prerequisites

Install PlatformIO

Option A: VS Code Extension (Recommended)

  1. Install Visual Studio Code
  2. Install "PlatformIO IDE" extension from VS Code marketplace

Option B: Command Line

pip install -U platformio

Build & Upload

Using PlatformIO CLI

# Navigate to project directory
cd migrate-to-pio

# Build project (first build downloads libraries - takes ~5 min)
pio run

# Upload to board
pio run --target upload

# Monitor serial output
pio device monitor

# Or combine upload + monitor
pio run --target upload && pio device monitor

Using VS Code

  1. Open project folder in VS Code
  2. PlatformIO toolbar will appear at bottom
  3. Click "Build" (checkmark icon)
  4. Click "Upload" (arrow icon)
  5. Click "Serial Monitor" (plug icon)

Project Structure

migrate-to-pio/
├── platformio.ini          # PlatformIO configuration
├── partition_table.csv            # Partition table (3MB app + 1MB SPIFFS)
├── src/                    # Source code (non-UI)
│   ├── main.cpp            # Main application
│   ├── automotive_data.h   # UART data structures
│   └── lvgl_v8_port.h/cpp  # LVGL porting layer
├── ui/                     # SquareLine Studio exports
│   └── ui*.h/c             # UI files (auto-generated)
├── include/
│   └── lv_conf.h           # LVGL configuration
└── .pio/                   # Build artifacts (gitignored)

Important: Configure SquareLine Studio to export UI files to the ui/ directory. This prevents the auto-generated UI code from overwriting your custom source files in src/.

Configuration

Partition Scheme

Current: Huge APP (3MB No OTA / 1MB SPIFFS)

  • NVS: 20KB (settings storage)
  • OTA data: 8KB
  • App: 3MB (application code)
  • SPIFFS: 1MB (file system)

Edit partition_table.csv to customize partition sizes.

Serial Monitor

  • Baud Rate: 115200
  • Debug Level: Set in platformio.ini → CORE_DEBUG_LEVEL
    • 0 = None
    • 1 = Error (default)
    • 5 = Verbose

Libraries

Dependencies auto-managed by PlatformIO:

  • ESP32_Display_Panel @ 1.0.4
  • ESP32_IO_Expander @ 1.1.1
  • LVGL @ 8.4.0

Built-in ESP32 libraries:

  • WiFi, Preferences, FreeRTOS, TWAI (CAN bus)

Usage

WiFi Configuration

  1. Navigate to Settings screen
  2. Toggle WiFi ON
  3. Wait for network scan (~2-3 seconds)
  4. Select network from list
  5. Enter password (if secured)
  6. Connection status displayed

UART Transmission

  1. Navigate to Settings screen
  2. Toggle UART ON
  3. Data transmits @ 5Hz on:
    • TX: GPIO 43
    • RX: GPIO 44
    • Baud: 115200

Connect UART-to-USB adapter to monitor:

screen /dev/ttyUSB0 115200
# or
minicom -D /dev/ttyUSB0 -b 115200

Debug Metrics

  1. Navigate to Settings screen
  2. Toggle Debug ON
  3. FPS and CPU metrics appear on screen
  4. Updates every 1 second

Troubleshooting

Build Fails

Issue: Libraries not downloading

# Clear library cache and rebuild
pio lib update
pio run --target clean
pio run

Issue: Partition table not found

  • Ensure partition_table.csv exists in project root
  • Check board_build.partitions in platformio.ini

Upload Fails

Issue: Port not detected

# List available ports
pio device list

# Specify port manually
pio run --target upload --upload-port /dev/ttyUSB0

Issue: Permission denied on Linux

sudo usermod -a -G dialout $USER
# Log out and back in

Display Issues

Issue: White flash on boot

  • Normal - backlight control prevents most flashing
  • Optimized in main.cpp setup sequence

Issue: Screen drift (RGB LCD)

  • Handled by high-performance ESP32 libraries
  • Platform packages configured in platformio.ini

Memory Issues

Issue: Heap overflow / crashes

  • PSRAM is enabled in board config
  • Check board_build.psram_type = opi in platformio.ini
  • Verify LVGL buffer size in lvgl_v8_port.h

Performance

  • FPS: ~50 FPS @ 1024x600 resolution
  • CPU Load: ~80% (Core 1 LVGL rendering)
  • WiFi Scan: 1-3 seconds for 10-20 networks
  • UART Overhead: +1-2% CPU @ 5Hz transmission
  • Build Time:
    • First build: ~5-10 minutes (downloads libraries)
    • Incremental: ~10-30 seconds (much faster than Arduino IDE!)

Development

Adding Libraries

Edit platformio.ini → lib_deps:

lib_deps =
    existing/library@1.0.0
    new/library@2.0.0

Changing Debug Level

Edit platformio.ini → build_flags:

build_flags =
    -DCORE_DEBUG_LEVEL=5  ; 0=None, 1=Error, 5=Verbose

Custom Partition

  1. Edit partition_table.csv
  2. Adjust partition sizes (hex values)
  3. Rebuild: pio run

Original Arduino IDE Version

The original Arduino IDE project remains in parent directory for comparison/rollback if needed.

License

Generated with Claude Code - https://claude.com/claude-code

S
Description
No description provided
Readme 16 MiB
2026-10-28 15:46:42 +00:00
Languages
C 87.3%
C++ 12.3%
Python 0.4%