Compare commits
34 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9bfcd99dee | |||
| b431cdfa16 | |||
| 0254bf19e9 | |||
| 01f7501ae7 | |||
| 31ca44187e | |||
| f07590bbc5 | |||
| 59fae2c219 | |||
| 803af7568f | |||
| 7a74c02b20 | |||
| 63d64362e8 | |||
| ae9327d91b | |||
| 7ae1ab726a | |||
| 3e86ca3733 | |||
| 8338e4e300 | |||
| 8e739fa24e | |||
| 929fdfa877 | |||
| 990ba68590 | |||
| 26e61190f9 | |||
| f69d195e2a | |||
| 518358a2ab | |||
| 5a874ff943 | |||
| 6593abe9f5 | |||
| 94c70a572b | |||
| bbfa5d9e80 | |||
| d3e499efed | |||
| 43ca6b96ec | |||
| 23b7027d40 | |||
| 40a21557f0 | |||
| 34b3fc7ec0 | |||
| 5d495f8ad1 | |||
| e68fad73b6 | |||
| 766019a01e | |||
| 842f270398 | |||
| 29711fa25e |
@@ -1,6 +1,6 @@
|
|||||||
name: Firmware
|
name: Firmware
|
||||||
|
|
||||||
# Controller A firmware, built by PlatformIO on every push. Two outputs:
|
# Main CTRL firmware, built by PlatformIO on every push. Two outputs:
|
||||||
#
|
#
|
||||||
# - push to main -> rolling PRE-release `main-latest` (firmware.bin + .elf),
|
# - push to main -> rolling PRE-release `main-latest` (firmware.bin + .elf),
|
||||||
# unsigned, no manifest. For bench testing / USB flashing.
|
# unsigned, no manifest. For bench testing / USB flashing.
|
||||||
@@ -19,6 +19,12 @@ name: Firmware
|
|||||||
#
|
#
|
||||||
# Releases go through the Gitea API with plain curl (actions/upload-artifact
|
# Releases go through the Gitea API with plain curl (actions/upload-artifact
|
||||||
# is unreliable on this runner - same pattern as parking_solution).
|
# is unreliable on this runner - same pattern as parking_solution).
|
||||||
|
#
|
||||||
|
# A main push skips itself (step "Skip?") when (a) the commit already carries a
|
||||||
|
# v* tag - the tag build covers it; release with ONE push so the tag exists
|
||||||
|
# when this runs: git push --follow-tags origin main - or (b) it only
|
||||||
|
# changes docs (wiki/**, *.md). Done in-job rather than with paths-ignore so a
|
||||||
|
# tag build can never be skipped by a path filter. Tag builds always run.
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -33,7 +39,29 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Skip?
|
||||||
|
env:
|
||||||
|
BEFORE: ${{ github.event.before }}
|
||||||
|
run: |
|
||||||
|
SKIP=false
|
||||||
|
if [ "${GITHUB_REF#refs/tags/}" = "${GITHUB_REF}" ] && [ "${GITHUB_EVENT_NAME}" = "push" ]; then
|
||||||
|
# (a) already tagged v* ? (annotated tags list their commit as <tag>^{})
|
||||||
|
if git ls-remote --tags origin 'v*' | grep -q "^${GITHUB_SHA}"; then
|
||||||
|
echo "commit ${GITHUB_SHA:0:7} is tagged - the tag build covers it"; SKIP=true
|
||||||
|
# (b) docs only? Needs the previous head; a new branch / force push just builds.
|
||||||
|
elif [ -n "$BEFORE" ] && [ "$BEFORE" != "0000000000000000000000000000000000000000" ] &&
|
||||||
|
git fetch -q --depth=1 origin "$BEFORE" 2>/dev/null; then
|
||||||
|
CHANGED=$(git diff --name-only "$BEFORE" "$GITHUB_SHA")
|
||||||
|
echo "changed files:"; echo "$CHANGED"
|
||||||
|
if [ -n "$CHANGED" ] && ! echo "$CHANGED" | grep -qvE '^wiki/|\.md$'; then
|
||||||
|
echo "docs-only change - no firmware build"; SKIP=true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo "SKIP=${SKIP}" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
- name: Version
|
- name: Version
|
||||||
|
if: env.SKIP != 'true'
|
||||||
run: |
|
run: |
|
||||||
if [ "${GITHUB_REF#refs/tags/}" != "${GITHUB_REF}" ]; then
|
if [ "${GITHUB_REF#refs/tags/}" != "${GITHUB_REF}" ]; then
|
||||||
VERSION="${GITHUB_REF_NAME}"
|
VERSION="${GITHUB_REF_NAME}"
|
||||||
@@ -46,6 +74,7 @@ jobs:
|
|||||||
echo "version: ${VERSION}"
|
echo "version: ${VERSION}"
|
||||||
|
|
||||||
- name: Cache PlatformIO
|
- name: Cache PlatformIO
|
||||||
|
if: env.SKIP != 'true'
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
@@ -54,14 +83,24 @@ jobs:
|
|||||||
.pio/libdeps
|
.pio/libdeps
|
||||||
key: pio-${{ hashFiles('platformio.ini') }}
|
key: pio-${{ hashFiles('platformio.ini') }}
|
||||||
|
|
||||||
- name: Install PlatformIO
|
# pioarduino's fork of the PlatformIO core, NOT upstream: the platform pins
|
||||||
|
# its own SCons 4.8.1 without the Fortran tools, and since the core rebuild
|
||||||
|
# (custom_sdkconfig, v0.1.7) the ESP-IDF build path is exercised, where the
|
||||||
|
# upstream core imports SCons.Tool.FortranCommon and dies
|
||||||
|
# ("ModuleNotFoundError: No module named 'SCons.Tool.FortranCommon'",
|
||||||
|
# first seen on the v0.1.7 tag build). The pin mirrors
|
||||||
|
# platform-espressif32/builder/penv_setup.py :: python_deps["platformio"].
|
||||||
|
- name: Install PlatformIO (pioarduino core)
|
||||||
|
if: env.SKIP != 'true'
|
||||||
run: |
|
run: |
|
||||||
curl -LsSf https://astral.sh/uv/install.sh | sh
|
curl -LsSf https://astral.sh/uv/install.sh | sh
|
||||||
export PATH="$HOME/.local/bin:$PATH"
|
export PATH="$HOME/.local/bin:$PATH"
|
||||||
uv tool install platformio
|
uv tool install "https://github.com/pioarduino/platformio-core/archive/refs/tags/v6.1.18.zip"
|
||||||
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
|
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
|
||||||
|
pio --version
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
|
if: env.SKIP != 'true'
|
||||||
run: |
|
run: |
|
||||||
export PLATFORMIO_BUILD_FLAGS="-DFW_VERSION=\\\"${VERSION}\\\""
|
export PLATFORMIO_BUILD_FLAGS="-DFW_VERSION=\\\"${VERSION}\\\""
|
||||||
pio run
|
pio run
|
||||||
@@ -72,7 +111,7 @@ jobs:
|
|||||||
ls -la dist/
|
ls -la dist/
|
||||||
|
|
||||||
- name: Sign + manifest (tags only)
|
- name: Sign + manifest (tags only)
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: env.SKIP != 'true' && startsWith(github.ref, 'refs/tags/')
|
||||||
env:
|
env:
|
||||||
BMW_NISSAN_FIRMWARE_SIGNING_KEY: ${{ secrets.BMW_NISSAN_FIRMWARE_SIGNING_KEY }}
|
BMW_NISSAN_FIRMWARE_SIGNING_KEY: ${{ secrets.BMW_NISSAN_FIRMWARE_SIGNING_KEY }}
|
||||||
run: |
|
run: |
|
||||||
@@ -93,6 +132,7 @@ jobs:
|
|||||||
cat dist/manifest.txt
|
cat dist/manifest.txt
|
||||||
|
|
||||||
- name: Publish release
|
- name: Publish release
|
||||||
|
if: env.SKIP != 'true'
|
||||||
env:
|
env:
|
||||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
API: ${{ github.api_url }}
|
API: ${{ github.api_url }}
|
||||||
@@ -103,12 +143,12 @@ jobs:
|
|||||||
if [ "${GITHUB_REF#refs/tags/}" != "${GITHUB_REF}" ]; then
|
if [ "${GITHUB_REF#refs/tags/}" != "${GITHUB_REF}" ]; then
|
||||||
TAG="${GITHUB_REF_NAME}"
|
TAG="${GITHUB_REF_NAME}"
|
||||||
PRE=false
|
PRE=false
|
||||||
NAME="Controller A ${TAG}"
|
NAME="Main CTRL ${TAG}"
|
||||||
BODY="Signed OTA release. Install on the controller with \`ota install\` (parked, Wi-Fi joined)."
|
BODY="Signed OTA release. Install on the controller with \`ota install\` (parked, Wi-Fi joined)."
|
||||||
else
|
else
|
||||||
TAG="main-latest"
|
TAG="main-latest"
|
||||||
PRE=true
|
PRE=true
|
||||||
NAME="Controller A main build"
|
NAME="Main CTRL main build"
|
||||||
BODY="Unsigned build of main @ ${GITHUB_SHA}. Rolling - overwritten each push. Not installable over OTA; flash over USB for bench tests."
|
BODY="Unsigned build of main @ ${GITHUB_SHA}. Rolling - overwritten each push. Not installable over OTA; flash over USB for bench tests."
|
||||||
# Rolling: drop the previous release and its tag, recreate at this commit.
|
# Rolling: drop the previous release and its tag, recreate at this commit.
|
||||||
OLD=$(curl -sS -H "$auth" "${API}/repos/${REPO}/releases/tags/${TAG}" \
|
OLD=$(curl -sS -H "$auth" "${API}/repos/${REPO}/releases/tags/${TAG}" \
|
||||||
|
|||||||
@@ -25,3 +25,9 @@ Thumbs.db
|
|||||||
ESP32-S3-Touch-LCD-5-Demo/
|
ESP32-S3-Touch-LCD-5-Demo/
|
||||||
# Excel lock/temp files (created while a spreadsheet is open)
|
# Excel lock/temp files (created while a spreadsheet is open)
|
||||||
~$*
|
~$*
|
||||||
|
|
||||||
|
# pioarduino custom_sdkconfig build artefacts (regenerated on every core rebuild)
|
||||||
|
.dummy/
|
||||||
|
managed_components/
|
||||||
|
sdkconfig.defaults
|
||||||
|
sdkconfig.waveshare_esp32_s3_lcd_5b
|
||||||
|
|||||||
@@ -4,14 +4,16 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
|||||||
|
|
||||||
## Project Overview
|
## Project Overview
|
||||||
|
|
||||||
Automotive display controller for **Waveshare ESP32-S3-Touch-LCD-5B** (1024x600 RGB LCD). This is a dual-controller system where Controller A (this ESP32-S3-LCD-5B) communicates automotive sensor data via UART to Controller B (ESP32-S3-LCD-1.3).
|
Automotive display controller for **Waveshare ESP32-S3-Touch-LCD-5B** (1024x600 RGB LCD). This is a dual-controller system where Main CTRL (this ESP32-S3-LCD-5B) communicates automotive sensor data via UART to Inst. Cluster (ESP32-S3-LCD-1.3).
|
||||||
|
|
||||||
**Hardware**: ESP32-S3 dual-core @ 240MHz, 16MB Flash, 8MB OPI PSRAM, 5-inch capacitive touch LCD
|
**Hardware**: ESP32-S3 dual-core @ 240MHz, 16MB Flash, 8MB OPI PSRAM, 5-inch capacitive touch LCD
|
||||||
|
|
||||||
**Key Features**: WiFi scanning, UART data transmission @ 5Hz, debug metrics (FPS/CPU), NVS settings persistence, LVGL 8.4.0 UI (SquareLine Studio exports)
|
**Key Features**: CAN decode, link to B (UART + ESP-NOW @ 5 Hz), remembered Wi-Fi + on-screen OTA updates, gauge tuning, NVS settings persistence, LVGL 8.4.0 UI (hand-coded screens)
|
||||||
|
|
||||||
## Build & Development Commands
|
## Build & Development Commands
|
||||||
|
|
||||||
|
The complete cheat-sheet for BOTH controllers (build, upload, monitor, every console command, pairing, releasing) is `docs/COMMANDS.md`. Keep it current when a command changes.
|
||||||
|
|
||||||
### PlatformIO CLI
|
### PlatformIO CLI
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -54,7 +56,7 @@ Use PlatformIO extension toolbar:
|
|||||||
The application uses **dual-core architecture** to maximize performance:
|
The application uses **dual-core architecture** to maximize performance:
|
||||||
|
|
||||||
- **Core 1** (Arduino core): LVGL rendering task (Priority 2)
|
- **Core 1** (Arduino core): LVGL rendering task (Priority 2)
|
||||||
- UI rendering at ~50 FPS @ 1024x600 resolution
|
- UI rendering @ 1024x600 (real render FPS never measured - the Debug "FPS" counts loop() passes)
|
||||||
- Touch input handling
|
- Touch input handling
|
||||||
- CPU load ~80% under normal operation
|
- CPU load ~80% under normal operation
|
||||||
|
|
||||||
@@ -74,15 +76,21 @@ The project follows a clean, organized structure with logical separation of conc
|
|||||||
src/
|
src/
|
||||||
main.cpp # Main application logic only
|
main.cpp # Main application logic only
|
||||||
modules/
|
modules/
|
||||||
wifi_manager.cpp # WiFi scanning and connection
|
wifi_manager.cpp # Wi-Fi: one remembered network, scans on request (no LVGL code)
|
||||||
|
settings_screen.cpp # Hand-coded Settings screen: Wi-Fi / Updates / System (swipe left from Driveline)
|
||||||
|
ui_kit.cpp # Shared look for hand-coded screens: header, buttons, switches, confirm dialog
|
||||||
uart_manager.cpp # Link transmitter: v2 DATA/CONFIG frames on UART1 + ESP-NOW
|
uart_manager.cpp # Link transmitter: v2 DATA/CONFIG frames on UART1 + ESP-NOW
|
||||||
tunables.cpp # Gauge calibration + alert thresholds (NVS, 'cfg' serial console)
|
tunables.cpp # Gauge calibration + alert thresholds (NVS, 'cfg' serial console)
|
||||||
espnow_link.cpp # ESP-NOW broadcast leg of the link
|
espnow_link.cpp # ESP-NOW broadcast leg of the link
|
||||||
tuning_screen.cpp # Hand-coded LVGL Gauge Tuning screen (swipe right from Driveline)
|
tuning_screen.cpp # Hand-coded Gauge Tuning screen, 4 tabs (swipe right from Driveline)
|
||||||
diag_probe.cpp # On-demand OBD-II requests ('diag' console) - the ONLY CAN transmitter
|
diag_probe.cpp # On-demand OBD-II requests ('diag' console) - the ONLY CAN transmitter
|
||||||
|
perf_monitor.cpp # 'perf' console: render fps, flush cost, LVGL/CPU idle, heap (display experiments)
|
||||||
ota_update.cpp # Manual firmware updates from Gitea releases ('ota' console)
|
ota_update.cpp # Manual firmware updates from Gitea releases ('ota' console)
|
||||||
|
link_peer.cpp # Inst. Cluster over the link: its STATUS frames, 'link pair' (key over the wire), encrypted credential handoff, B's updates ('link' console)
|
||||||
|
status_overlay.cpp # lv_layer_top() on EVERY screen: Wi-Fi chip top-right, blinking red / steady amber alert banner top-centre
|
||||||
|
diff_locks.cpp # Diff-lock inputs DI0 rear / DI1 front via CH422G EXIO0/EXIO5 ('difflock' console, Settings switch, default OFF)
|
||||||
settings_manager.cpp # NVS persistent storage
|
settings_manager.cpp # NVS persistent storage
|
||||||
ui_state_manager.cpp # UI synchronization logic
|
ui_state_manager.cpp # Debug flag (performance overlay, sent to B)
|
||||||
display_init.cpp # Display initialization; boots into DrivelineScreen
|
display_init.cpp # Display initialization; boots into DrivelineScreen
|
||||||
driveline_screen.cpp # Hand-coded LVGL boot screen (gear, temps, rpm, status)
|
driveline_screen.cpp # Hand-coded LVGL boot screen (gear, temps, rpm, status)
|
||||||
drivers/
|
drivers/
|
||||||
@@ -97,22 +105,18 @@ include/
|
|||||||
can_driver.h # CAN Bus driver interface
|
can_driver.h # CAN Bus driver interface
|
||||||
protocol/
|
protocol/
|
||||||
automotive_data.h # UART protocol and CAN ID mappings
|
automotive_data.h # UART protocol and CAN ID mappings
|
||||||
ui/
|
|
||||||
ui*.c/h # SquareLine Studio generated UI files
|
|
||||||
```
|
```
|
||||||
|
|
||||||
**src/main.cpp** (~1530 lines)
|
**src/main.cpp** (~1530 lines)
|
||||||
- Main application logic, event handlers, FreeRTOS task implementations
|
- Main application logic, event handlers, FreeRTOS task implementations
|
||||||
- WiFi state machine: `wifiTask()` on Core 0 with async scanning
|
- Console command routing (`cfg`, `diag`, `ota`, `wifi`, `mem`, `perf`, `link`), setup order, `loop()` ticks for the three screens
|
||||||
- UART state machine: `uartTask()` on Core 0 with periodic transmission
|
|
||||||
- Settings synchronization: `applySavedStatesToUI()` syncs toggle states when Settings screen loads
|
|
||||||
- Thread-safe UI updates via `lvgl_port_lock()`/`unlock()`
|
|
||||||
|
|
||||||
**include/protocol/automotive_data.h**
|
**include/protocol/automotive_data.h**
|
||||||
- **Shared with Controller B, must stay byte-identical in both repos.** Protocol v2 (2026-09-21).
|
- **Shared with Inst. Cluster, must stay byte-identical in both repos.** Protocol v2 (2026-09-21).
|
||||||
- `automotive_data_t` (DATA payload): gear lever + target/engaged nibbles, rpm, 3 temperatures, battery, alert bitmap, valid flags
|
- `automotive_data_t` (DATA payload): gear lever + target/engaged nibbles, rpm, 3 temperatures, battery, alert bitmap, valid flags
|
||||||
- `link_config_t` (CONFIG payload): Patrol gauge calibration + alert thresholds, pushed A → B
|
- `link_config_t` (CONFIG payload): Patrol gauge calibration + alert thresholds, pushed A → B
|
||||||
- Frame: `0xAA | version | type | length | payload | XOR | 0x55`; helpers `frame_build()` / `frame_parse()`
|
- Frame: `0xAA | version | type | length | payload | XOR | 0x55`; helpers `frame_build()` / `frame_parse()`
|
||||||
|
- Maintenance frames (2026-09-27, `PACKET_VERSION` unchanged): `STATUS` 0x03 B → A, `PAIR` 0x04 A → B **wire only**, `SECURE` 0x05 A → B (AES-256-GCM, `include/protocol/link_secure.h` - shared and byte-identical too). `PACKET_MAX_PAYLOAD` is 160
|
||||||
- Spec: `docs/UART_PROTOCOL.md`
|
- Spec: `docs/UART_PROTOCOL.md`
|
||||||
- **BMW CAN Bus ID mappings**: 11-bit PT-CAN IDs verified live on the swap bus (evidence: `wiki/pages/can-id-candidates.md`)
|
- **BMW CAN Bus ID mappings**: 11-bit PT-CAN IDs verified live on the swap bus (evidence: `wiki/pages/can-id-candidates.md`)
|
||||||
- UART config: 115200 baud on GPIO 44 (TX) / 43 (RX, unused) — leaves the board via the SP3485 RS485 transceiver
|
- UART config: 115200 baud on GPIO 44 (TX) / 43 (RX, unused) — leaves the board via the SP3485 RS485 transceiver
|
||||||
@@ -134,42 +138,25 @@ include/
|
|||||||
- LVGL 8.4.0 configuration file
|
- LVGL 8.4.0 configuration file
|
||||||
- Memory settings, theme configuration, widget enables
|
- Memory settings, theme configuration, widget enables
|
||||||
|
|
||||||
**include/ui/** directory (SquareLine Studio exports)
|
**UI**: every screen is hand-coded in `src/modules` (see Screens). SquareLine Studio was decommissioned on 2026-09-27 (`include/ui/` deleted); the LVGL theme is set in `display_init.cpp`. Don't reintroduce a UI generator.
|
||||||
- `ui_Settings_Screen.c/h`: WiFi, UART, CAN Bus, Debug toggle switches and containers. Its right-swipe calls `app_show_driveline()` (C entry point in `driveline_screen.cpp`)
|
|
||||||
- The SquareLine **Home screen was removed on 2026-09-21** (its meters module too). `ui_init()` loads an empty placeholder; `display_init.cpp` then shows the Driveline screen. If SquareLine re-exports a Home screen, delete it from the SquareLine project — do not wire it back in
|
|
||||||
- External UI references: `uic_Toggle_Wifi_Switch`, `uic_Toggle_UART_Switch`, `uic_Toggle_CAN_Bus_Switch`, `uic_Toggle_Debug_Switch`, `uic_Wifi_Container`, `uic_Settings_Loading_Container`, `uic_Device_State_Container`
|
|
||||||
- Event handlers: `onWifiToggle()`, `onUARTToggle()`, `onCANBusToggle()`, `onDebugToggle()`
|
|
||||||
- **Important**: SquareLine Studio exports to `include/ui/` directory to avoid overwriting custom code in `src/`
|
|
||||||
|
|
||||||
### NVS Persistent Storage
|
### NVS Persistent Storage
|
||||||
|
|
||||||
Settings persist across power cycles via ESP32 NVS (Non-Volatile Storage):
|
Settings persist across power cycles via ESP32 NVS (Non-Volatile Storage):
|
||||||
- Namespace: "settings"
|
- Namespace: "settings"
|
||||||
- Keys: `wifi_en`, `uart_en`, `can_en`, `debug_en` (boolean values)
|
- Keys: `wifi_en`, `uart_en`, `can_en`, `debug_en`, `difflock_en`, `difflock_inv` (boolean values)
|
||||||
- Functions: `saveWiFiState()`, `loadWiFiState()`, `saveUARTState()`, `loadUARTState()`, `saveCANState()`, `loadCANState()`, `saveDebugState()`, `loadDebugState()`
|
- Functions: `saveWiFiState()`, `loadWiFiState()`, `saveUARTState()`, `loadUARTState()`, `saveCANState()`, `loadCANState()`, `saveDebugState()`, `loadDebugState()`
|
||||||
|
- Namespace "wifi": `ssid`, `pass` - the one remembered network (`WiFiManager`); the password is never printed
|
||||||
|
|
||||||
### WiFi Architecture
|
### WiFi Architecture
|
||||||
|
|
||||||
**State Machine**: `WIFI_STATE_OFF` → `WIFI_STATE_SCANNING` → `WIFI_STATE_SCAN_COMPLETE` → `WIFI_STATE_CONNECTED`
|
`WiFiManager` (`wifi_manager.cpp`) owns **no LVGL objects**: the Settings screen polls `getStatus()` / `getNetworks()` and calls `setEnabled()`, `requestScan()`, `connect()`, `connectSaved()`, `forget()`. All radio work runs in `wifiTask()` (Core 0) from a command queue.
|
||||||
|
|
||||||
**Task Communication**:
|
- **One remembered network** (NVS namespace `wifi`), saved after a successful join, joined automatically ~3 s after boot when Wi-Fi is on (verified 2026-09-27)
|
||||||
- Main thread → WiFi task: Via `g_wifi_event_queue` (FreeRTOS queue)
|
- **Scans only on request** (Wi-Fi page opened while not connected, or the Scan button) - background scans every 10 s caused display glitches and hop the radio ESP-NOW uses
|
||||||
- Event types: `WIFI_UI_EVENT_TOGGLE_ON/OFF`, `WIFI_UI_EVENT_SCAN_START`, `WIFI_UI_EVENT_CONNECT`, `WIFI_UI_EVENT_DISCONNECT`
|
- **No endless reconnect**: `setAutoReconnect(false)`; one attempt at boot, one retry after a drop, then idle back on `ESPNOW_CHANNEL`
|
||||||
- Shared data protection: `g_wifi_mutex` (FreeRTOS semaphore) guards `g_scanned_networks[]` array
|
- Failure reasons come from the STA_DISCONNECTED event (wrong password, not in range, ...) and show on the screen
|
||||||
|
- Console: `wifi status | join <ssid> [pass] | forget | scan | on | off`
|
||||||
**Dynamic SSID Buttons**:
|
|
||||||
- WiFi scan results create dynamically-generated LVGL buttons (`lv_btn_create()` in `updateSSIDList()`)
|
|
||||||
- Button array: `g_ssid_buttons[WIFI_SCAN_MAX_NETWORKS]` (max 20 networks)
|
|
||||||
- Each button stores network index in user data: `lv_obj_set_user_data(btn, (void*)(intptr_t)i)`
|
|
||||||
- Click handler: `onSSIDButtonClick()` → shows password entry UI (keyboard + text area) for secured networks, or connects directly for open networks
|
|
||||||
|
|
||||||
**Connection Flow**:
|
|
||||||
1. User clicks SSID button → `onSSIDButtonClick()`
|
|
||||||
2. If secured: Show `uic_Wifi_Passkey_TB` (password text area) + `uic_Keyboard`
|
|
||||||
3. User enters password → `onKeyboardEvent()` (LV_EVENT_READY)
|
|
||||||
4. Allocate `wifi_credentials_t`, send `WIFI_UI_EVENT_CONNECT` to WiFi task
|
|
||||||
5. WiFi task: `WiFi.begin(ssid, password)` with 10-second timeout
|
|
||||||
6. Result: `showConnectionResult()` updates UI with success/failure
|
|
||||||
|
|
||||||
### UART Architecture
|
### UART Architecture
|
||||||
|
|
||||||
@@ -223,7 +210,7 @@ Settings persist across power cycles via ESP32 NVS (Non-Volatile Storage):
|
|||||||
|
|
||||||
### Tunables (gauge calibration, alert thresholds)
|
### Tunables (gauge calibration, alert thresholds)
|
||||||
|
|
||||||
`src/modules/tunables.cpp` owns `link_config_t`: tach pulses/rev + trim + clamps, coolant PWM frequency + duty law + min temp, per-output enables, a bench override (force rpm / duty), and the alert thresholds. Stored as an NVS blob (namespace `tunables`), written 3 s after the last change or on leaving the Tuning screen (`Tunables::flush()`) - every flash write flickers the RGB panel, so no write per tap. Edited over the USB serial console: `cfg show`, `cfg set <name> <value>`, `cfg override rpm <n> | duty <n> | both <rpm> <duty> | off`, `cfg reset`. Every change bumps `cfg_version`, which makes the UART task push a CONFIG frame. Overrides are pushed but never saved. The **Gauge Tuning screen** (`src/modules/tuning_screen.cpp`, hand-coded like the driveline screen so SquareLine exports cannot clobber it; Home → swipe right → Driveline → swipe right → Tuning) edits the same values with −/+ buttons, enable switches, and an override panel with RPM and duty sliders. Overrides are never written to NVS (`save()` strips them).
|
`src/modules/tunables.cpp` owns `link_config_t`: tach pulses/rev + trim + clamps, coolant PWM frequency + duty law + min temp, per-output enables, a bench override (force rpm / duty), and the alert thresholds. Stored as an NVS blob (namespace `tunables`), written 3 s after the last change or on leaving the Tuning screen (`Tunables::flush()`, `isDirty()` drives the screen's save indicator) - every flash write flickers the RGB panel, so no write per tap. Edited over the USB serial console: `cfg show`, `cfg set <name> <value>`, `cfg override rpm <n> | duty <n> | both <rpm> <duty> | off`, `cfg reset`. Every change bumps `cfg_version`, which makes the UART task push a CONFIG frame. Overrides are pushed but never saved. The **Gauge Tuning screen** (`src/modules/tuning_screen.cpp`, see Screens) edits the same values with −/+ buttons, enable switches, and a Simulation tab with RPM and duty sliders. Overrides are never written to NVS (`save()` strips them).
|
||||||
|
|
||||||
### Diagnostic probe (`diag` console)
|
### Diagnostic probe (`diag` console)
|
||||||
|
|
||||||
@@ -231,28 +218,34 @@ Settings persist across power cycles via ESP32 NVS (Non-Volatile Storage):
|
|||||||
|
|
||||||
### OTA updates (`ota` console)
|
### OTA updates (`ota` console)
|
||||||
|
|
||||||
`src/modules/ota_update.cpp` pulls signed firmware from this repo's Gitea releases (`include/config/ota_config.h`: server, repo, Let's Encrypt roots, signing public key). Manual only: `ota status | check | install [force] | rollback` - the future password-gated Diagnostics screen will call the same code. Install is refused unless parked (engine off, shaft still, lever not in a drive gear; silent bus = parked), checked before download and again before the slot switch. The manifest's ECDSA P-256 signature over `patrol-a|version|sha256` is checked before download; the streamed image must match that sha256. `verifyRollbackLater()` is overridden so a new image stays pending until `Ota::tick()` confirms it after 30 s - a reset before that rolls back. CI: `.gitea/workflows/firmware.yml` (push `main` -> rolling unsigned pre-release `main-latest`; tag `v*` -> signed release, needs repo secret `BMW_NISSAN_FIRMWARE_SIGNING_KEY`). Never put secrets in firmware source - the repo and its release binaries are public. Jobs run inside the loop task (8 KB stack) with mbedtls routed to PSRAM - internal RAM is too tight for a TLS task (15.9 KB free, largest block 7.6 KB with Wi-Fi up). `wifi join <ssid> [pass] | status | off` (in `wifi_manager.cpp`) joins a network from the console. Details: `wiki/pages/ota-updates.md`.
|
`src/modules/ota_update.cpp` pulls signed firmware from this repo's Gitea releases (`include/config/ota_config.h`: server, repo, Let's Encrypt roots, signing public key). Manual only: Settings → Updates (Check, then Install behind a confirm dialog; verified end-to-end from the screen 2026-09-27) or the console `ota status | check | install [force] | rollback`. `Ota::getStatus()` gives the screen a phase + latest tag + failure reason. Install is refused unless parked (engine off, shaft still, lever not in a drive gear; silent bus = parked), checked before download and again before the slot switch. The manifest's ECDSA P-256 signature over `patrol-a|version|sha256` is checked before download; the streamed image must match that sha256. `verifyRollbackLater()` is overridden so a new image stays pending until `Ota::tick()` confirms it after 30 s - a reset before that rolls back. CI: `.gitea/workflows/firmware.yml` (push `main` -> rolling unsigned pre-release `main-latest`; tag `v*` -> signed release, needs repo secret `BMW_NISSAN_FIRMWARE_SIGNING_KEY`). CI installs **pioarduino's fork of the PlatformIO core** (v6.1.18 zip, same pin as the platform's `penv_setup.py`), not upstream `platformio`: with `custom_sdkconfig` the build goes through the ESP-IDF path, where the upstream core imports `SCons.Tool.FortranCommon` that pioarduino's SCons 4.8.1 does not ship. The core rebuild makes the first CI build after a `platformio.ini` change ~20 min (esp-idf download + rebuild), cached afterwards. Release with one push so only the tag build runs: `git tag -a vX.Y.Z -m "..." && git push --follow-tags origin main` (a main push skips itself when its commit is tagged, or when it only touches `wiki/**` / `*.md`). Never put secrets in firmware source - the repo and its release binaries are public. Jobs run inside the loop task (8 KB stack) with mbedtls routed to PSRAM - internal RAM is too tight for a TLS task (15.9 KB free, largest block 7.6 KB with Wi-Fi up). Wi-Fi is joined on the Settings screen (remembered) or with `wifi join`. Details: `wiki/pages/ota-updates.md`.
|
||||||
|
|
||||||
|
### Performance monitor (`perf` console)
|
||||||
|
|
||||||
|
`src/modules/perf_monitor.cpp` hooks the LVGL port (`monitor_cb` per rendered frame, a timer around `drawBitmap()` in `flush_callback`) and reads FreeRTOS run-time stats. `perf` prints one `PERF,` CSV line (ts, fps, avg/max ms per frame, kpx per frame, ms per second spent copying into the PSRAM framebuffer, LVGL idle %, core 0/1 idle %, internal free/largest, PSRAM free, **panel vsync/s, longest vsync gap in µs**); `perf on [sec]` prints one every few seconds (from an esp_timer, so it keeps running while the OTA job blocks `loop()`); `perf off`. The vsync columns come from the RGB panel's refresh-finished interrupt (attached in `lvgl_v8_port.cpp` when tearing-avoidance is off): healthy = ~24/s with a 41.5 ms gap; a DMA underrun/restart (flicker, dots) stretches the gap to two frames or more - this is the direct measure for the display work in wiki open-questions #13. Idle Driveline baseline (bench, 2026-09-27, after the `setText()` fix): 0 fps rendered, 0 ms/s flushes, LVGL idle 96 %, core 1 idle 96 % (before the fix: 9.7 fps, 30 ms/frame, 52 ms/s, 68 % / 66 % - the tick re-set every label at 10 Hz). Rule for every screen `tick()`: only write a label or style when the value changed (`lv_label_set_text()` and style setters invalidate even for identical values).
|
||||||
|
|
||||||
### ESP-NOW link
|
### ESP-NOW link
|
||||||
|
|
||||||
`src/modules/espnow_link.cpp` broadcasts every frame on Wi-Fi channel `ESPNOW_CHANNEL` (1). The radio stays in STA mode permanently — `WiFiManager`'s "off" only stops scanning/association. Never call `WiFi.disconnect(true)` or `WiFi.mode(WIFI_OFF)`: powering the radio off de-initialises ESP-NOW (`send()` re-inits it as a safety net). If Wi-Fi joins an AP the channel follows the AP; B hops to find it.
|
`src/modules/espnow_link.cpp` broadcasts every frame on Wi-Fi channel `ESPNOW_CHANNEL` (1). The radio stays in STA mode permanently — `WiFiManager`'s "off" only stops scanning/association. Never call `WiFi.disconnect(true)` or `WiFi.mode(WIFI_OFF)`: powering the radio off de-initialises ESP-NOW (`send()` re-inits it as a safety net). If Wi-Fi joins an AP the channel follows the AP; B hops to find it. Since 2026-09-27 it also receives (`setReceiveHandler()`, runs in the Wi-Fi task - copy and return) and unicasts to one MAC (`sendTo()`, plain peer added on first use); both are used by `LinkPeer` only.
|
||||||
|
|
||||||
### UI State Synchronization
|
### Inst. Cluster over the link (`link` console)
|
||||||
|
|
||||||
**Problem**: SquareLine Studio screens get destroyed/recreated when swiping between screens, losing runtime state.
|
`src/modules/link_peer.cpp` keeps B's last `STATUS` frame (version, update phase, progress, flags; "not heard" after 15 s), owns the pairing key (NVS `linkpeer`) and drives B's updater. `link pair` generates a 32-byte key and sends it **three times over UART1 only** (`UARTManager::sendWire()`, never ESP-NOW - both repos are public, this is the one secret); B confirms with `key_fp` in its next STATUS. `tick()` pushes the remembered Wi-Fi network to B in an encrypted `SECURE` frame whenever B lacks it or it changed (hash-compared, ≥ 15 s apart; `WiFiManager::getSavedCredentials()` exists for this alone - never print the password), and a FORGET when A forgets its network. `requestCheck()` / `requestInstall()` (Settings → Updates, Inst. Cluster card) require: B heard, paired with *this* key, B has credentials, B not busy, A on Wi-Fi (same AP as B ⇒ same channel ⇒ progress frames arrive), and for install `Ota::isParked()`. Console: `link status | pair | unpair | creds | ota check | ota install [force] | ota rollback`. Design + procedure: B's wiki `controller-b-ota`.
|
||||||
|
|
||||||
**Solution**: `applySavedStatesToUI()` function (called continuously in `loop()`)
|
### Diff-lock inputs (`difflock` console)
|
||||||
- Detects when Settings screen loads by checking if `uic_Toggle_Wifi_Switch != NULL`
|
|
||||||
- Tracks screen instance via `g_last_synced_screen` pointer to prevent redundant syncing
|
|
||||||
- Syncs toggle switches with actual service states: `g_wifi_state`, `g_uart_state`, `g_debug_enabled`
|
|
||||||
- Shows loading spinner during sync for smooth UX
|
|
||||||
|
|
||||||
**Screens**: Driveline (boot, hand-coded) ← swipe left → Settings (SquareLine); Driveline → swipe right → Gauge Tuning (hand-coded). Screen switches are instant (`LV_SCR_LOAD_ANIM_NONE`): full-screen fades are software-blended every frame and stutter at 1024x600. The firmware version is a label on `lv_layer_top()` (bottom-right, every screen, `DisplayInit`).
|
`src/modules/diff_locks.cpp` reads the Patrol's two diff-lock signals (+12 V = locked) on the isolated inputs: DI0 = rear, DI1 = front, `DI_COM` to vehicle ground. The PC814 outputs reach the ESP32 only through the CH422G (DI0 = EXIO0, DI1 = EXIO5, active LOW), and the CH422G's IO0-7 are one bank, all in or all out - the same bank drives touch reset (EXIO1), backlight (EXIO2) and LCD reset (EXIO3). Each poll (4 Hz, under the LVGL lock so no touch read shares the bus) writes WR_SET input (0x24 <- 0x00), reads 0x26, and writes output back (0x01), restore retried; the chip keeps its output latch. Raw I2C on host 0 (legacy driver, as the panel library), never the library's `enableAllIO_Input()` (it sleeps 2 ms with the bank floating). A state counts after two equal reads. Polarity is a per-board setting (`difflock_inv`, the "Inverted" switch in the same Settings row, `difflock invert on|off`): in the car the lock wires carry 12 V while UNLOCKED, so the car board needs it on, the bench (12 V = locked) needs it off. Behind the Settings → System switch, default OFF, so a board without the wiring never flips the bank. The Driveline shows a top view of the chassis in the top-right corner, drawn from the user's sketch with `lv_line` objects and two border boxes, geometry in sketch pixels scaled by `DL_S`. All four tyres are the same square-cornered rectangle, and the wheelbase is the sketch's shortened by 20 %. A locked axle turns amber: axle, tyres filled solid, and an X on its diff. A filled tyre is one `lv_line` as wide as the tyre with square ends, because LVGL 8 cannot rotate a box. The front axle turns red if it reads locked without the rear. There is no text caption (user). The whole drawing is hidden when the switch is off; the System row's sub-line shows the live state for testing. Wiring and evidence: wiki `diff-lock-inputs`.
|
||||||
|
|
||||||
**Debug Mode**:
|
### Screens
|
||||||
- Toggle in Settings screen shows/hides `uic_Device_State_Container`
|
|
||||||
- Updates FPS (`uic_FPS_Values_LBL`) and CPU usage (`uic_CPU_Values_LBL`) every second
|
All hand-coded in `src/modules`, built once and kept (never deleted - the old generated screens were deleted on leave, which left dangling pointers and caused the 2026-09-27 freezes). Shared look in `ui_kit.cpp` (20/24 px text, >= 56 px touch targets, no shadows/animations, `UiKit::confirm()` modal dialog). Each screen has a `tick()` called from `loop()` that refreshes values under the LVGL lock, only while it is shown, and only re-sets label text that changed.
|
||||||
- Frame counting: `g_frame_count` incremented in `updateDebugMetrics()` called from `loop()`
|
|
||||||
|
- **Driveline** (boot) - swipe left: Settings, swipe right: Gauge Tuning
|
||||||
|
- **Settings** (`settings_screen.cpp`) - sidebar: **Wi-Fi** (switch, status card, networks nearby, full-screen password page), **Updates** (two cards: Main CTRL -> `Ota::requestCheck/requestInstall`, Inst. Cluster -> `LinkPeer::requestCheck/requestInstall`; each Installed / Latest / status line / Check / Install behind a confirm dialog; must fit 484 px, pages don't scroll), **System** (CAN / link to B / performance overlay / diff-lock input switches, live ESP-NOW, CAN, memory, uptime on the firmware line - the page is full at four rows). Swipe right or the Driveline button goes back
|
||||||
|
- **Gauge Tuning** (`tuning_screen.cpp`) - tabs Tachometer / Coolant gauge / Alerts / Simulation; -/+ rows with hints (hold to repeat, speeds up), per-tab Reset with confirm, "Saving... / All changes saved" footer, SIMULATION ON chip while an override is active. Swipe left or the Driveline button goes back
|
||||||
|
- Screen switches are instant (`LV_SCR_LOAD_ANIM_NONE`): full-screen fades are software-blended every frame and stutter at 1024x600. The firmware version is a label on `lv_layer_top()` (bottom-right, every screen, `DisplayInit`)
|
||||||
|
- **StatusOverlay** (2026-09-27, `status_overlay.cpp`, also on `lv_layer_top()`): a 150 px Wi-Fi chip top-right (off / not connected / joining / network name) and an alert banner top-centre that blinks red at 2 Hz while any red alert bit is set (coolant hot, gearbox oil hot, gear mismatch, battery low - text names the value) and is steady amber for gearbox cooling; hidden with CAN or ignition off. The top ~56 px of every screen belong to it: `UiKit::header()` puts the back button at x -176, the Driveline chips start at y 60. On the Driveline the crossed value AND its title go red (amber for cooling) and a gear mismatch turns the hero ring + letter red (the old top-right mismatch label is gone). Blinking is a colour toggle from `tick()` every 500 ms, not an lv_anim (a 1024-wide banner animated per frame would cost real render time)
|
||||||
|
- The System page's "Performance overlay" switch shows LVGL's own perf monitor (real render FPS / CPU) and sets the debug flag sent to B
|
||||||
|
|
||||||
## Configuration Files
|
## Configuration Files
|
||||||
|
|
||||||
@@ -280,40 +273,15 @@ Settings persist across power cycles via ESP32 NVS (Non-Volatile Storage):
|
|||||||
|
|
||||||
**include/lv_conf.h**
|
**include/lv_conf.h**
|
||||||
- LVGL 8.4.0 configuration
|
- LVGL 8.4.0 configuration
|
||||||
- Memory: Uses PSRAM for large objects
|
- Memory: LVGL's widget pool (`LV_MEM_SIZE`) is 512 KB in PSRAM via `LV_MEM_POOL_ALLOC` (was 48 KB internal and ran out). `mem` on the console prints internal heap, PSRAM and pool use/fragmentation
|
||||||
|
- Asserts: `LV_ASSERT_HANDLER` is `abort()` (backtrace + core dump + reboot), never `while(1)`, which froze the UI while holding the LVGL lock
|
||||||
- Theme: Material theme enabled
|
- Theme: Material theme enabled
|
||||||
|
|
||||||
## Common Patterns
|
## Common Patterns
|
||||||
|
|
||||||
### Adding a New Toggle Switch
|
### Adding a New Setting
|
||||||
|
|
||||||
1. Add NVS keys in main.cpp:
|
See "Adding a setting" under Important Notes: a row + `UiKit::toggle()` on the Settings screen, a `SettingsManager` save/load pair, and a sync line in the page's `refresh*()`.
|
||||||
```cpp
|
|
||||||
#define NVS_KEY_FEATURE_ENABLED "feature_en"
|
|
||||||
```
|
|
||||||
|
|
||||||
2. Add save/load functions:
|
|
||||||
```cpp
|
|
||||||
void saveFeatureState(bool enabled) {
|
|
||||||
preferences.begin(NVS_NAMESPACE, false);
|
|
||||||
preferences.putBool(NVS_KEY_FEATURE_ENABLED, enabled);
|
|
||||||
preferences.end();
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
3. Add global state variable: `static bool g_feature_enabled = false;`
|
|
||||||
|
|
||||||
4. Create event handler (called from SquareLine UI):
|
|
||||||
```cpp
|
|
||||||
void onFeatureToggle(lv_event_t *e) {
|
|
||||||
lv_obj_t *target = lv_event_get_target(e);
|
|
||||||
bool state = lv_obj_has_state(target, LV_STATE_CHECKED);
|
|
||||||
saveFeatureState(state);
|
|
||||||
// Update state, send to task if needed
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
5. Add sync logic in `applySavedStatesToUI()` to restore state when Settings screen loads
|
|
||||||
|
|
||||||
### Thread-Safe UI Update from Background Task
|
### Thread-Safe UI Update from Background Task
|
||||||
|
|
||||||
@@ -355,7 +323,8 @@ xTaskCreatePinnedToCore(
|
|||||||
|
|
||||||
- **CAN Bus**: GPIO 15 (TX), GPIO 16 (RX) - 500 Kbps, TWAI_MODE_NORMAL, onboard TJA1051 on the terminal block
|
- **CAN Bus**: GPIO 15 (TX), GPIO 16 (RX) - 500 Kbps, TWAI_MODE_NORMAL, onboard TJA1051 on the terminal block
|
||||||
- **UART1**: GPIO 44 (TX), GPIO 43 (RX, unused) - reaches the terminal block only as the RS485 A/B pair (SP3485), 115200 baud. Bench: `485_A` straight into B's IO1 + GND works (verified 2026-09-21)
|
- **UART1**: GPIO 44 (TX), GPIO 43 (RX, unused) - reaches the terminal block only as the RS485 A/B pair (SP3485), 115200 baud. Bench: `485_A` straight into B's IO1 + GND works (verified 2026-09-21)
|
||||||
- **USB Serial**: UART0 (default Serial) - 115200 baud for debug output
|
- **USB Serial**: native USB-CDC (`Serial`, 303A:1001). Opening the port with default DTR/RTS resets the board - attach with `pio device monitor -p COM10 --dtr 0 --rts 0 --echo`
|
||||||
|
- **Uploading from a script/pipe on Windows**: set `PYTHONIOENCODING=utf-8` (and `PYTHONUTF8=1`). Otherwise esptool crashes printing its progress bar to a cp1252 pipe *mid-write* and leaves the board frozen until a power cycle (happened 2026-09-27; the bootloader then fell back to the other OTA slot)
|
||||||
|
|
||||||
### Display Panel
|
### Display Panel
|
||||||
|
|
||||||
@@ -374,6 +343,7 @@ xTaskCreatePinnedToCore(
|
|||||||
|
|
||||||
### Build Errors
|
### Build Errors
|
||||||
|
|
||||||
|
- **Build from PowerShell, not Git Bash**: `idf_tools.py` refuses MSYS ("MSys/Mingw is not supported"). The two projects also share one `framework-arduinoespressif32` package directory, so the first `pio run` after building ESP32-S3-LCD-1.3 reinstalls Arduino 3.3.3 and may fail once with `TypeError: expected str, bytes or os.PathLike object, not NoneType` - run it again.
|
||||||
- **`Failed to install Python dependencies into penv (exit code: 2)`** at the start of `pio run`: the sibling ESP32-S3-LCD-1.3 project (official espressif32@6 platform) installs newer `urllib3`/`esptool` into the shared PlatformIO penv, and this project's pioarduino platform needs `urllib3<2`; its install step hides the error. Run `. oolsix_penv_deps.ps1`, then build again. Never build the two projects at the same time (shared penv).
|
- **`Failed to install Python dependencies into penv (exit code: 2)`** at the start of `pio run`: the sibling ESP32-S3-LCD-1.3 project (official espressif32@6 platform) installs newer `urllib3`/`esptool` into the shared PlatformIO penv, and this project's pioarduino platform needs `urllib3<2`; its install step hides the error. Run `. oolsix_penv_deps.ps1`, then build again. Never build the two projects at the same time (shared penv).
|
||||||
- **Missing libraries**: Run `pio lib update` then `pio run --target clean`
|
- **Missing libraries**: Run `pio lib update` then `pio run --target clean`
|
||||||
- **Partition table not found**: Ensure `partition_table.csv` exists in project root
|
- **Partition table not found**: Ensure `partition_table.csv` exists in project root
|
||||||
@@ -388,7 +358,7 @@ xTaskCreatePinnedToCore(
|
|||||||
|
|
||||||
- **Screen drift/artifacts**: RGB LCD timing issue - already optimized in `platformio.ini` with high-performance platform packages
|
- **Screen drift/artifacts**: RGB LCD timing issue - already optimized in `platformio.ini` with high-performance platform packages
|
||||||
- **White flash on boot**: Backlight control sequence in setup() minimizes this (lines 1383-1414)
|
- **White flash on boot**: Backlight control sequence in setup() minimizes this (lines 1383-1414)
|
||||||
- **UI toggles don't match state**: Check `applySavedStatesToUI()` is called in `loop()` - this syncs UI with running services
|
- **UI switches don't match state**: `SettingsScreen::tick()` must run in `loop()` - it re-reads the live state every 250 ms
|
||||||
- **WiFi/UART task not responding**: Check FreeRTOS queue creation succeeded (NULL check in setup())
|
- **WiFi/UART task not responding**: Check FreeRTOS queue creation succeeded (NULL check in setup())
|
||||||
- **LVGL crash from background task**: Ensure `lvgl_port_lock()` / `unlock()` wraps ALL LVGL API calls
|
- **LVGL crash from background task**: Ensure `lvgl_port_lock()` / `unlock()` wraps ALL LVGL API calls
|
||||||
- **Screen flickering**: This was resolved by fixing the proper board configuration and partition table. The key fixes were:
|
- **Screen flickering**: This was resolved by fixing the proper board configuration and partition table. The key fixes were:
|
||||||
@@ -401,7 +371,7 @@ xTaskCreatePinnedToCore(
|
|||||||
|
|
||||||
## Performance Metrics
|
## Performance Metrics
|
||||||
|
|
||||||
- **FPS**: ~50 FPS @ 1024x600 resolution
|
- **FPS**: not measured yet (the Debug-panel counter counts loop() passes, not frames) - see wiki open-questions #13
|
||||||
- **CPU Load**: ~80% on Core 1 (LVGL rendering)
|
- **CPU Load**: ~80% on Core 1 (LVGL rendering)
|
||||||
- **WiFi Scan**: 1-3 seconds for 10-20 networks
|
- **WiFi Scan**: 1-3 seconds for 10-20 networks
|
||||||
- **UART Overhead**: +1-2% CPU @ 5Hz transmission rate
|
- **UART Overhead**: +1-2% CPU @ 5Hz transmission rate
|
||||||
@@ -409,7 +379,6 @@ xTaskCreatePinnedToCore(
|
|||||||
|
|
||||||
## Important Notes
|
## Important Notes
|
||||||
|
|
||||||
- **SquareLine Studio Export**: ALWAYS export UI files to `ui/` directory, NEVER to `src/` (prevents overwriting main.cpp)
|
- **Adding a setting**: add a row to the right page in `settings_screen.cpp` (`makeSettingRow()` + `UiKit::toggle()`), persist it via `SettingsManager`, and sync it in that page's `refresh*()` function
|
||||||
- **Event Handler Registration**: Event handlers for SquareLine UI elements are registered in `ui_Settings_Screen.c` auto-generated code. When adding new toggles, add event callback registration via `lv_obj_add_event_cb()` and declare handler in `ui_events.h`
|
|
||||||
- **CAN Bus Integration**: BMW CAN IDs are defined in `automotive_data.h` (all 11-bit standard frames, verified live on the swap bus). The CAN driver runs in `TWAI_MODE_NORMAL` (it ACKs frames; not LISTEN_ONLY). Evidence and confidence labels live in `wiki/pages/can-id-candidates.md`. Never add a second caller of `CANDriver::transmit()` without a design discussion — transmitting on the vehicle bus is a safety decision
|
- **CAN Bus Integration**: BMW CAN IDs are defined in `automotive_data.h` (all 11-bit standard frames, verified live on the swap bus). The CAN driver runs in `TWAI_MODE_NORMAL` (it ACKs frames; not LISTEN_ONLY). Evidence and confidence labels live in `wiki/pages/can-id-candidates.md`. Never add a second caller of `CANDriver::transmit()` without a design discussion — transmitting on the vehicle bus is a safety decision
|
||||||
- **Security**: Password field (`uic_Wifi_Passkey_TB`) is cleared after connection attempt for security (line 1015, 1029)
|
- **Security**: the Wi-Fi password field is cleared when the password page closes; the saved password lives only in NVS and is never logged (the pre-2026-09-27 code printed it on every join)
|
||||||
|
|||||||
@@ -4,12 +4,13 @@ Automotive display controller for Waveshare ESP32-S3-Touch-LCD-5B (1024x600 RGB
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- ✅ **WiFi** - Network scanning with dynamic SSID list
|
- ✅ **CAN bus** - decodes the BMW M57N / ZF 6HP powertrain frames (gear, temperatures, rpm, ...)
|
||||||
- ✅ **UART** - Automotive data transmission @ 5Hz (GPIO 43/44)
|
- ✅ **Link to Inst. Cluster** - data + gauge config @ 5 Hz over RS485 (UART1) and ESP-NOW
|
||||||
- ✅ **Debug Mode** - FPS and CPU metrics display
|
- ✅ **Screens** - Driveline (boot), Settings (Wi-Fi / Updates / System), Gauge Tuning; LVGL 8.4.0, hand-coded
|
||||||
- ✅ **Settings Persistence** - NVS storage for toggle states
|
- ✅ **Wi-Fi** - one remembered network, joined at boot
|
||||||
- ✅ **Touch UI** - LVGL 8.4.0 with SquareLine Studio UI
|
- ✅ **OTA updates** - signed releases from Gitea, installed from the Settings screen
|
||||||
- ✅ **FreeRTOS** - Multi-core architecture (WiFi/UART on Core 0, LVGL on Core 1)
|
- ✅ **Settings persistence** - NVS
|
||||||
|
- ✅ **FreeRTOS** - Wi-Fi / UART / CAN on Core 0, LVGL on Core 1
|
||||||
|
|
||||||
## Hardware
|
## Hardware
|
||||||
|
|
||||||
@@ -34,6 +35,8 @@ pip install -U platformio
|
|||||||
|
|
||||||
## Build & Upload
|
## Build & Upload
|
||||||
|
|
||||||
|
Full cheat-sheet for both controllers (build, upload, serial monitor, every console command, pairing, releases): [`docs/COMMANDS.md`](docs/COMMANDS.md).
|
||||||
|
|
||||||
### Using PlatformIO CLI
|
### Using PlatformIO CLI
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -64,32 +67,31 @@ pio run --target upload && pio device monitor
|
|||||||
## Project Structure
|
## Project Structure
|
||||||
|
|
||||||
```
|
```
|
||||||
migrate-to-pio/
|
platformio.ini # PlatformIO configuration
|
||||||
├── platformio.ini # PlatformIO configuration
|
partition_table.csv # dual OTA slots (2 x 7.9 MB), NVS, coredump
|
||||||
├── partition_table.csv # Partition table (3MB app + 1MB SPIFFS)
|
src/
|
||||||
├── src/ # Source code (non-UI)
|
main.cpp # setup, loop, console routing
|
||||||
│ ├── main.cpp # Main application
|
modules/ # screens, Wi-Fi, link, OTA, tunables, ...
|
||||||
│ ├── automotive_data.h # UART data structures
|
drivers/can_driver.cpp # CAN (TWAI)
|
||||||
│ └── lvgl_v8_port.h/cpp # LVGL porting layer
|
include/
|
||||||
├── ui/ # SquareLine Studio exports
|
config/ # lv_conf.h, ota_config.h, board config
|
||||||
│ └── ui*.h/c # UI files (auto-generated)
|
display/ # LVGL port
|
||||||
├── include/
|
protocol/automotive_data.h # link protocol shared with Inst. Cluster
|
||||||
│ └── lv_conf.h # LVGL configuration
|
wiki/ # project knowledge base
|
||||||
└── .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/`.
|
See `CLAUDE.md` for the architecture.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
### Partition Scheme
|
### Partition Scheme
|
||||||
|
|
||||||
Current: **Huge APP (3MB No OTA / 1MB SPIFFS)**
|
Dual OTA (see `partition_table.csv`):
|
||||||
|
|
||||||
- NVS: 20KB (settings storage)
|
- NVS: 20KB (settings, tunables, Wi-Fi) - never move it
|
||||||
- OTA data: 8KB
|
- OTA data: 8KB
|
||||||
- App: 3MB (application code)
|
- app0 / app1: 7.9MB each (firmware ~1.7MB)
|
||||||
- SPIFFS: 1MB (file system)
|
- Coredump: 64KB
|
||||||
|
|
||||||
Edit `partition_table.csv` to customize partition sizes.
|
Edit `partition_table.csv` to customize partition sizes.
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,202 @@
|
|||||||
|
# Commands cheat-sheet — both controllers
|
||||||
|
|
||||||
|
Everything you type to build, flash, watch and drive the two boards. Kept in the
|
||||||
|
Main CTRL repo (this one); the Inst. Cluster repo's README points here.
|
||||||
|
|
||||||
|
| | Main CTRL | Inst. Cluster |
|
||||||
|
|---|---|---|
|
||||||
|
| Board | Waveshare ESP32-S3-Touch-LCD-5B (5" touch) | Waveshare ESP32-S3-LCD-1.3 (1.3" round) |
|
||||||
|
| Repo / branch | `ESP32-S3-Touch-LCD-5B`, `main` | `ESP32-S3-LCD-1.3`, `master` |
|
||||||
|
| Platform | pioarduino (Arduino 3.3.3 / IDF 5.5) | espressif32@6 (Arduino 2.0.17 / IDF 4.4) |
|
||||||
|
| Serial | native USB-CDC | CH343 UART |
|
||||||
|
| Bench port (2026-09-28) | COM14 | COM10 |
|
||||||
|
| OTA target / release | `patrol-a`, `v*` tags → signed release | `patrol-b`, `v*` tags → signed release |
|
||||||
|
|
||||||
|
Windows ports move around: `pio device list` shows what is plugged in.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. Rules of the road (Windows, this machine)
|
||||||
|
|
||||||
|
- **PowerShell only.** `pio` refuses to run from Git Bash (`MSys/Mingw is not supported`).
|
||||||
|
- `pio` lives at `$env:USERPROFILE\.platformio\penv\Scripts\pio.exe` (no global install). The commands below assume this alias:
|
||||||
|
```powershell
|
||||||
|
Set-Alias pio "$env:USERPROFILE\.platformio\penv\Scripts\pio.exe"
|
||||||
|
```
|
||||||
|
- **The two projects share one PlatformIO environment.** Consequences:
|
||||||
|
- The first `pio run` after building the *other* project reinstalls the Arduino core and may fail once with `TypeError: expected str, bytes or os.PathLike object, not NoneType`. Run it again.
|
||||||
|
- After **any B build**, repair the environment before building A, or A fails with `Failed to install Python dependencies into penv`:
|
||||||
|
```powershell
|
||||||
|
.\tools\fix_penv_deps.ps1 # run inside the A repo
|
||||||
|
```
|
||||||
|
- Never build both projects at the same time.
|
||||||
|
- **A serial monitor on a port blocks uploads to that port.** Close it (Ctrl+C) first.
|
||||||
|
- Opening a port with DTR/RTS asserted resets the board. Always monitor with `--dtr 0 --rts 0`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. Build and upload
|
||||||
|
|
||||||
|
Run inside the respective repo folder.
|
||||||
|
|
||||||
|
### Main CTRL
|
||||||
|
```powershell
|
||||||
|
cd <path>\ESP32-S3-Touch-LCD-5B
|
||||||
|
pio run # build only (dev build, version "dev")
|
||||||
|
pio run -t upload --upload-port COM14 # build + flash over USB
|
||||||
|
pio run -t clean # wipe the build directory
|
||||||
|
```
|
||||||
|
First build after a `platformio.ini` change rebuilds the ESP-IDF core (~20 min, `custom_sdkconfig`); later builds take 1–3 min.
|
||||||
|
|
||||||
|
### Inst. Cluster
|
||||||
|
```powershell
|
||||||
|
cd <path>\ESP32-S3-LCD-1.3
|
||||||
|
pio run
|
||||||
|
pio run -t upload --upload-port COM10
|
||||||
|
..\ESP32-S3-Touch-LCD-5B\tools\fix_penv_deps.ps1 # ALWAYS after a B build, before the next A build
|
||||||
|
```
|
||||||
|
|
||||||
|
A USB flash writes bootloader, partition table, `boot_app0` and the app into slot 0. It does **not** touch NVS: saved Wi-Fi network, tunables, pairing key and B's cached gauge config survive.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. Serial monitor
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
pio device monitor -p COM14 -b 115200 --dtr 0 --rts 0 --echo # Main CTRL
|
||||||
|
pio device monitor -p COM10 -b 115200 --dtr 0 --rts 0 --echo # Inst. Cluster
|
||||||
|
```
|
||||||
|
Type a command, press Enter. `--echo` shows what you type. Ctrl+C leaves.
|
||||||
|
|
||||||
|
One-shot commands and logging from a script (A repo, `tools/`):
|
||||||
|
```powershell
|
||||||
|
python tools\serial_cmd.py COM14 "link status" 3 # send one line, print 3 s of reply
|
||||||
|
python tools\serial_logger.py COM14 # log a port to wiki\raw\ until Ctrl+C
|
||||||
|
python tools\serial_logger.py COM14,COM10 # both ports at once
|
||||||
|
python tools\perf_session.py COM14 # display-performance session (PERF lines)
|
||||||
|
python tools\diag_session.py COM14 "diag pids" "diag vin" # scripted OBD probe run with log
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4. Main CTRL console
|
||||||
|
|
||||||
|
Type `help` for the list. Unknown lines are reported.
|
||||||
|
|
||||||
|
### `cfg` — Patrol gauge calibration and alert thresholds (saved in NVS, pushed to B)
|
||||||
|
```
|
||||||
|
cfg show
|
||||||
|
cfg set <name> <value> tach_ppr tach_trim tach_min_hz tach_max_hz
|
||||||
|
temp_hz temp_slope(x100) temp_offset temp_min temp_duty_max
|
||||||
|
tach_en temp_en coolant_hot gearbox_hot batt_low(x100)
|
||||||
|
cfg override off | rpm <n> | duty <n> | both <rpm> <duty> bench test of B's outputs, never saved
|
||||||
|
cfg reset
|
||||||
|
```
|
||||||
|
|
||||||
|
### `wifi`
|
||||||
|
```
|
||||||
|
wifi status connection, saved network, ESP-NOW health
|
||||||
|
wifi join <ssid> [pass] join and remember a network (no spaces in the SSID)
|
||||||
|
wifi forget drop the remembered network (B is told to forget too)
|
||||||
|
wifi scan list networks in range
|
||||||
|
wifi on | off
|
||||||
|
```
|
||||||
|
|
||||||
|
### `ota` — this controller's own updates
|
||||||
|
```
|
||||||
|
ota status version, slot, rollback state
|
||||||
|
ota check ask Gitea for the latest release (needs Wi-Fi)
|
||||||
|
ota install [force] download, verify, flash the idle slot, reboot (parked only)
|
||||||
|
ota rollback boot the previous slot (parked only)
|
||||||
|
```
|
||||||
|
|
||||||
|
### `link` — Inst. Cluster over the link
|
||||||
|
```
|
||||||
|
link status B's version, pairing, update phase, credentials
|
||||||
|
link pair new shared key → B over the UART WIRE (bench, wire connected)
|
||||||
|
link unpair forget the key here
|
||||||
|
link creds send the remembered Wi-Fi network to B now (normally automatic)
|
||||||
|
link ota check | install [force] | rollback drive B's updater (A must be on Wi-Fi, parked)
|
||||||
|
```
|
||||||
|
|
||||||
|
### `diag` — OBD-II probe (the only thing that ever transmits on the CAN bus)
|
||||||
|
```
|
||||||
|
diag pids scan mode-01 supported-PID bitmaps
|
||||||
|
diag pid <hex> one mode-01 request (0C rpm, 70 boost, ...)
|
||||||
|
diag dtc mode 03, stored generic DTCs
|
||||||
|
diag vin mode 09 PID 02
|
||||||
|
diag ecu mode 09 PID 0A
|
||||||
|
diag ident [addr] BMW KWP 1A 80 identification (default 12 = DDE)
|
||||||
|
diag bmw <addr> <hex...> raw BMW request on 0x6F1, read-only services only
|
||||||
|
diag raw on | off CANRAW frame logging
|
||||||
|
diag status
|
||||||
|
```
|
||||||
|
|
||||||
|
### `difflock` — diff-lock inputs (DI0 = rear, DI1 = front; Settings → System switch, default OFF)
|
||||||
|
```
|
||||||
|
difflock status rear / front LOCKED or open, raw CH422G IO byte, read counters
|
||||||
|
difflock on | off same as the switch (saved)
|
||||||
|
difflock invert on | off polarity, same as the "Inverted" switch (saved): on = NO current means locked
|
||||||
|
```
|
||||||
|
Wiring: lock wire → DI0 / DI1, `DI_COM` → vehicle ground. If the screen shows locked when unlocked (the Patrol's ground-switched lamp wires do this), turn **Inverted** on. Details: wiki `diff-lock-inputs`.
|
||||||
|
|
||||||
|
### Diagnostics
|
||||||
|
```
|
||||||
|
mem internal heap, PSRAM, LVGL pool
|
||||||
|
perf one PERF line (fps, flush cost, CPU idle, heap, panel vsync)
|
||||||
|
perf on [sec] | perf off
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 5. Inst. Cluster console
|
||||||
|
|
||||||
|
```
|
||||||
|
help
|
||||||
|
link status pairing, A's MAC, STATUS/SECURE counters, credentials
|
||||||
|
link unpair forget the pairing key (re-pair from A over the wire)
|
||||||
|
wifi status stored network name (password never shown)
|
||||||
|
wifi forget
|
||||||
|
ota status version, slot, rollback state
|
||||||
|
ota check join Wi-Fi, ask Gitea for the latest release, leave
|
||||||
|
ota install [force] download, verify, flash, reboot (parked only)
|
||||||
|
ota rollback
|
||||||
|
```
|
||||||
|
B prints a stats line every 5 s (`applied=… uart … espnow …`) — `uart alive` means the wire works.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 6. Procedures
|
||||||
|
|
||||||
|
### Pair a Inst. Cluster (once per board pair)
|
||||||
|
1. Wire: 5B terminal `485_A` → B `IO1`, GND → GND (a real wire, not just the USB hub), 5B's 120 Ω switch OFF. Both powered. B's stats line must say `uart alive`.
|
||||||
|
2. A console: `link pair`. Within 5 s A logs `Inst. Cluster confirmed pairing (fingerprint XXXX)`; B logs `PAIRED over the wire`.
|
||||||
|
3. `link status` on A: `key XXXX (matches)`. About 15 s later `Wi-Fi creds yes` (A pushes them by itself; `link creds` forces it).
|
||||||
|
|
||||||
|
The key lives in NVS on both boards and survives every flash and update. Re-pair only after an NVS erase, `link unpair`, or a board swap.
|
||||||
|
|
||||||
|
### Release a version
|
||||||
|
```powershell
|
||||||
|
git tag -a vX.Y.Z -m "what changed"
|
||||||
|
git push --follow-tags origin main # A (B: origin master)
|
||||||
|
```
|
||||||
|
One push, so only the tag build runs. Gitea builds, signs (`BMW_NISSAN_FIRMWARE_SIGNING_KEY`) and publishes `firmware.bin` + `manifest.txt`: A takes 7–20 min, B 2–5 min. Check: `https://git.infra.msai.al/<owner>/<repo>/releases`. Version strings must stay under 16 characters.
|
||||||
|
|
||||||
|
### Update A from the screen
|
||||||
|
Settings → Updates → Main CTRL → **Check** → **Install vX.Y.Z** (parked, Wi-Fi joined). Progress bar, restart, `A vX.Y.Z` bottom-right. A reset in the first 30 s rolls back.
|
||||||
|
|
||||||
|
### Update B from the screen
|
||||||
|
Settings → Updates → Inst. Cluster → **Check** → **Install** (A on Wi-Fi, parked, B paired). B's round screen shows `Updating vX.Y.Z N%`, the card on A shows the percentage, B restarts and confirms itself after 30 s. Console equivalent: `link ota check`, `link ota install`.
|
||||||
|
|
||||||
|
### Something is wrong after an update
|
||||||
|
`ota rollback` on the affected controller's console (B: `link ota rollback` from A also works). A reset within 30 s of the first boot of a new image rolls back on its own.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 7. Git on several machines
|
||||||
|
|
||||||
|
Fetch before you start on another machine; the wikis are edited from every machine:
|
||||||
|
```powershell
|
||||||
|
git fetch origin
|
||||||
|
git status -sb # "behind" → git pull --ff-only before touching anything
|
||||||
|
```
|
||||||
+20
-8
@@ -1,9 +1,9 @@
|
|||||||
# Link Protocol Specification (v2)
|
# Link Protocol Specification (v2)
|
||||||
|
|
||||||
**Version:** 2 (`PACKET_VERSION 0x02`)
|
**Version:** 2 (`PACKET_VERSION 0x02`)
|
||||||
**Last Updated:** 2026-09-21
|
**Last Updated:** 2026-09-27
|
||||||
**Source of truth:** `include/protocol/automotive_data.h` — byte-identical in both repos.
|
**Source of truth:** `include/protocol/automotive_data.h` (+ `link_secure.h`) — byte-identical in both repos.
|
||||||
**Direction:** Controller A (ESP32-S3-Touch-LCD-5B) → Controller B (ESP32-S3-LCD-1.3), one way.
|
**Direction:** gauge data Main CTRL (ESP32-S3-Touch-LCD-5B) → Inst. Cluster (ESP32-S3-LCD-1.3). Since 2026-09-27 B answers with `STATUS` frames over ESP-NOW and A sends B maintenance frames (`PAIR` on the wire, `SECURE` over ESP-NOW) — see *Maintenance frames* below.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -28,8 +28,8 @@ The same frames are sent on two paths at once. B accepts either and deduplicates
|
|||||||
|---|---|---|
|
|---|---|---|
|
||||||
| start | 1 | `0xAA` |
|
| start | 1 | `0xAA` |
|
||||||
| version | 1 | `0x02` — B rejects any other value (counted as version error) |
|
| version | 1 | `0x02` — B rejects any other value (counted as version error) |
|
||||||
| type | 1 | `0x01` DATA, `0x02` CONFIG |
|
| type | 1 | `0x01` DATA, `0x02` CONFIG, `0x03` STATUS, `0x04` PAIR, `0x05` SECURE |
|
||||||
| length | 1 | payload bytes (21 for DATA, 27 for CONFIG) |
|
| length | 1 | payload bytes (21 DATA, 27 CONFIG, 78 STATUS, 42 PAIR, 29–160 SECURE); `PACKET_MAX_PAYLOAD` = 160 |
|
||||||
| payload | length | see below, little-endian, packed |
|
| payload | length | see below, little-endian, packed |
|
||||||
| checksum | 1 | XOR of version, type, length and every payload byte |
|
| checksum | 1 | XOR of version, type, length and every payload byte |
|
||||||
| end | 1 | `0x55` |
|
| end | 1 | `0x55` |
|
||||||
@@ -101,7 +101,7 @@ Tach: `f = rpm × tach_ppr / 60 × (1 + trim/100)`, clamped, 50 % duty. Output l
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Controller A console commands (USB serial)
|
## Main CTRL console commands (USB serial)
|
||||||
|
|
||||||
```
|
```
|
||||||
cfg show
|
cfg show
|
||||||
@@ -120,6 +120,18 @@ The same console also carries the OBD-II diagnostic probe (`diag pids | pid <hex
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Maintenance frames (2026-09-27) — for Inst. Cluster's firmware updates
|
||||||
|
|
||||||
|
`PACKET_VERSION` did not change: DATA and CONFIG are byte-identical, and a B built before these types counts them as type errors and carries on.
|
||||||
|
|
||||||
|
| Type | Direction | Transport | Payload | Purpose |
|
||||||
|
|---|---|---|---|---|
|
||||||
|
| `STATUS` 0x03 | B → A | ESP-NOW unicast to A's MAC (learned from A's data frames) | `link_status_t` (78 B): B's version, OTA phase (`LINK_OTA_*`, same numbering as A's `Ota::phase_t`), progress %, flags (paired / have Wi-Fi / joined / pending verify), `key_fp`, uptime, free heap, latest tag, message | every 5 s and on every phase change; A's Updates page "Inst. Cluster" card |
|
||||||
|
| `PAIR` 0x04 | A → B | **UART wire only** — B drops a PAIR heard by radio | `link_pair_t` (42 B): magic `"PAIR"`, 32-byte random key, A's STA MAC | `link pair` on A's console, sent 3×; both sides keep the key in NVS. The only secret in the system (both repos are public) |
|
||||||
|
| `SECURE` 0x05 | A → B | ESP-NOW unicast | `nonce[12] \| tag[16] \| AES-256-GCM(key, nonce, inner_type \| inner)` — helpers in `link_secure.h` | inner `LINK_INNER_OTA_CMD` 0x11 (`link_ota_cmd_t`: check / install [force] / rollback + random nonce, B ignores a repeat of the last 4) or `LINK_INNER_WIFI_CREDS` 0x12 (`link_wifi_creds_t`: SET/FORGET, ssid, pass). B also requires the sender MAC to be the paired A |
|
||||||
|
|
||||||
|
B reports `key_fp` = first two bytes of SHA-256(key) so A can tell "paired with my key" from "paired with an old one" and re-pair.
|
||||||
|
|
||||||
## Receiver behaviour (B)
|
## Receiver behaviour (B)
|
||||||
|
|
||||||
- Link considered lost after 1000 ms without an applied DATA frame on any transport; display shows N/A and both gauge outputs go low.
|
- Link considered lost after 1000 ms without an applied DATA frame on any transport; display shows N/A and both gauge outputs go low.
|
||||||
@@ -131,7 +143,7 @@ The same console also carries the OBD-II diagnostic probe (`diag pids | pid <hex
|
|||||||
|
|
||||||
## Changing the protocol
|
## Changing the protocol
|
||||||
|
|
||||||
1. Edit `automotive_data.h` on A, bump `PACKET_VERSION`.
|
1. Edit `automotive_data.h` on A. Bump `PACKET_VERSION` if DATA or CONFIG change; adding a new frame type does not need a bump (a stale B ignores unknown types).
|
||||||
2. Copy the header to B unchanged.
|
2. Copy the header (and `link_secure.h`) to B unchanged (`cmp` them).
|
||||||
3. Update this document.
|
3. Update this document.
|
||||||
4. Flash both. A stale B logs version errors and applies nothing.
|
4. Flash both. A stale B logs version errors and applies nothing.
|
||||||
|
|||||||
@@ -49,14 +49,19 @@
|
|||||||
#define LV_MEM_CUSTOM 0
|
#define LV_MEM_CUSTOM 0
|
||||||
#if LV_MEM_CUSTOM == 0
|
#if LV_MEM_CUSTOM == 0
|
||||||
/*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/
|
/*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/
|
||||||
#define LV_MEM_SIZE (48U * 1024U) /*[bytes]*/
|
/* 512 KB pool in PSRAM (2026-09-27). The old 48 KB pool lived in internal
|
||||||
|
* RAM and ran out: Settings + its Wi-Fi list is ~15 KB, and screen churn +
|
||||||
|
* fragmentation reached 87% used / 4.5 KB biggest block, then a label draw
|
||||||
|
* failed lv_mem_buf_get() -> assert. Moving it out also frees 48 KB of the
|
||||||
|
* scarce internal RAM. `mem` on the console prints the pool state. */
|
||||||
|
#define LV_MEM_SIZE (512U * 1024U) /*[bytes]*/
|
||||||
|
|
||||||
/*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/
|
/*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/
|
||||||
#define LV_MEM_ADR 0 /*0: unused*/
|
#define LV_MEM_ADR 0 /*0: unused*/
|
||||||
/*Instead of an address give a memory allocator that will be called to get a memory pool for LVGL. E.g. my_malloc*/
|
/*Instead of an address give a memory allocator that will be called to get a memory pool for LVGL. E.g. my_malloc*/
|
||||||
#if LV_MEM_ADR == 0
|
#if LV_MEM_ADR == 0
|
||||||
#undef LV_MEM_POOL_INCLUDE
|
#define LV_MEM_POOL_INCLUDE <esp_heap_caps.h>
|
||||||
#undef LV_MEM_POOL_ALLOC
|
#define LV_MEM_POOL_ALLOC(size) heap_caps_malloc((size), MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else /*LV_MEM_CUSTOM*/
|
#else /*LV_MEM_CUSTOM*/
|
||||||
@@ -271,8 +276,12 @@
|
|||||||
#define LV_USE_ASSERT_OBJ 0 /*Check the object's type and existence (e.g. not deleted). (Slow)*/
|
#define LV_USE_ASSERT_OBJ 0 /*Check the object's type and existence (e.g. not deleted). (Slow)*/
|
||||||
|
|
||||||
/*Add a custom handler when assert happens e.g. to restart the MCU*/
|
/*Add a custom handler when assert happens e.g. to restart the MCU*/
|
||||||
#define LV_ASSERT_HANDLER_INCLUDE <stdint.h>
|
#define LV_ASSERT_HANDLER_INCLUDE <stdlib.h>
|
||||||
#define LV_ASSERT_HANDLER while(1); /*Halt by default*/
|
/* Was `while(1);`: a failed assert spun forever inside the calling task while it
|
||||||
|
* held the LVGL lock - the UI froze, loop() blocked on the lock, and only the
|
||||||
|
* link task kept running (2026-09-27). abort() panics instead: backtrace on the
|
||||||
|
* console, core dump to flash (ELF), reboot. A reboot beats a frozen screen. */
|
||||||
|
#define LV_ASSERT_HANDLER abort();
|
||||||
|
|
||||||
/*-------------
|
/*-------------
|
||||||
* Others
|
* Others
|
||||||
@@ -367,9 +376,9 @@
|
|||||||
#define LV_FONT_MONTSERRAT_14 1
|
#define LV_FONT_MONTSERRAT_14 1
|
||||||
#define LV_FONT_MONTSERRAT_16 0
|
#define LV_FONT_MONTSERRAT_16 0
|
||||||
#define LV_FONT_MONTSERRAT_18 0
|
#define LV_FONT_MONTSERRAT_18 0
|
||||||
#define LV_FONT_MONTSERRAT_20 0
|
#define LV_FONT_MONTSERRAT_20 1
|
||||||
#define LV_FONT_MONTSERRAT_22 0
|
#define LV_FONT_MONTSERRAT_22 0
|
||||||
#define LV_FONT_MONTSERRAT_24 0
|
#define LV_FONT_MONTSERRAT_24 1
|
||||||
#define LV_FONT_MONTSERRAT_26 0
|
#define LV_FONT_MONTSERRAT_26 0
|
||||||
#define LV_FONT_MONTSERRAT_28 0
|
#define LV_FONT_MONTSERRAT_28 0
|
||||||
#define LV_FONT_MONTSERRAT_30 1
|
#define LV_FONT_MONTSERRAT_30 1
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* ota_config.h - where Controller A looks for firmware updates, and what it trusts.
|
* ota_config.h - where Main CTRL looks for firmware updates, and what it trusts.
|
||||||
*
|
*
|
||||||
* Updates are pulled over HTTPS from this repo's Gitea releases (public repo,
|
* Updates are pulled over HTTPS from this repo's Gitea releases (public repo,
|
||||||
* no token). CI (.gitea/workflows/firmware.yml) attaches firmware.bin +
|
* no token). CI (.gitea/workflows/firmware.yml) attaches firmware.bin +
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
#define FW_VERSION "dev"
|
#define FW_VERSION "dev"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Identity inside the signed statement, so a Controller B image can never be
|
// Identity inside the signed statement, so a Inst. Cluster image can never be
|
||||||
// accepted by A (and vice versa) even though both are signed by the same key.
|
// accepted by A (and vice versa) even though both are signed by the same key.
|
||||||
#define OTA_TARGET "patrol-a"
|
#define OTA_TARGET "patrol-a"
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
#define ESP_UTILS_LOG_TAG "LvPort"
|
#define ESP_UTILS_LOG_TAG "LvPort"
|
||||||
#include "esp_lib_utils.h"
|
#include "esp_lib_utils.h"
|
||||||
#include "lvgl_v8_port.h"
|
#include "lvgl_v8_port.h"
|
||||||
|
#include "modules/perf_monitor.h"
|
||||||
|
#include "esp_timer.h"
|
||||||
|
|
||||||
using namespace esp_panel::drivers;
|
using namespace esp_panel::drivers;
|
||||||
|
|
||||||
@@ -478,14 +480,35 @@ void flush_callback(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color
|
|||||||
const int offsetx2 = area->x2;
|
const int offsetx2 = area->x2;
|
||||||
const int offsety1 = area->y1;
|
const int offsety1 = area->y1;
|
||||||
const int offsety2 = area->y2;
|
const int offsety2 = area->y2;
|
||||||
|
const int w = offsetx2 - offsetx1 + 1;
|
||||||
|
const int h = offsety2 - offsety1 + 1;
|
||||||
|
|
||||||
lcd->drawBitmap(offsetx1, offsety1, offsetx2 - offsetx1 + 1, offsety2 - offsety1 + 1, (const uint8_t *)color_map);
|
// Time the pixel copy into the (PSRAM) framebuffer - this is the PSRAM
|
||||||
|
// write cost the display experiments (open question #13) change.
|
||||||
|
const int64_t t0 = esp_timer_get_time();
|
||||||
|
lcd->drawBitmap(offsetx1, offsety1, w, h, (const uint8_t *)color_map);
|
||||||
|
PerfMon::onFlush((uint32_t)(esp_timer_get_time() - t0), (uint32_t)(w * h));
|
||||||
// For RGB LCD, directly notify LVGL that the buffer is ready
|
// For RGB LCD, directly notify LVGL that the buffer is ready
|
||||||
if (lcd->getBus()->getBasicAttributes().type == ESP_PANEL_BUS_TYPE_RGB) {
|
if (lcd->getBus()->getBasicAttributes().type == ESP_PANEL_BUS_TYPE_RGB) {
|
||||||
lv_disp_flush_ready(drv);
|
lv_disp_flush_ready(drv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LVGL calls this once per rendered frame (render + flush time, pixels drawn).
|
||||||
|
static void monitor_callback(lv_disp_drv_t *drv, uint32_t time_ms, uint32_t px)
|
||||||
|
{
|
||||||
|
(void)drv;
|
||||||
|
PerfMon::onFrame(time_ms, px);
|
||||||
|
}
|
||||||
|
|
||||||
|
// RGB panel "refresh finished" (vsync) interrupt - counted for the perf monitor.
|
||||||
|
static IRAM_ATTR bool onPerfVsyncCallback(void *user_data)
|
||||||
|
{
|
||||||
|
(void)user_data;
|
||||||
|
PerfMon::onVsync();
|
||||||
|
return false; // no context switch needed
|
||||||
|
}
|
||||||
|
|
||||||
static void update_callback(lv_disp_drv_t *drv)
|
static void update_callback(lv_disp_drv_t *drv)
|
||||||
{
|
{
|
||||||
LCD *lcd = (LCD *)drv->user_data;
|
LCD *lcd = (LCD *)drv->user_data;
|
||||||
@@ -605,6 +628,9 @@ static lv_disp_t *display_init(LCD *lcd)
|
|||||||
ESP_UTILS_LOGD("Register display driver to LVGL");
|
ESP_UTILS_LOGD("Register display driver to LVGL");
|
||||||
lv_disp_drv_init(&disp_drv);
|
lv_disp_drv_init(&disp_drv);
|
||||||
disp_drv.flush_cb = flush_callback;
|
disp_drv.flush_cb = flush_callback;
|
||||||
|
#if LVGL_PORT_AVOID_TEARING_MODE == 0
|
||||||
|
disp_drv.monitor_cb = monitor_callback;
|
||||||
|
#endif
|
||||||
#if (LVGL_PORT_ROTATION_DEGREE == 90) || (LVGL_PORT_ROTATION_DEGREE == 270)
|
#if (LVGL_PORT_ROTATION_DEGREE == 90) || (LVGL_PORT_ROTATION_DEGREE == 270)
|
||||||
disp_drv.hor_res = lcd_height;
|
disp_drv.hor_res = lcd_height;
|
||||||
disp_drv.ver_res = lcd_width;
|
disp_drv.ver_res = lcd_width;
|
||||||
@@ -802,6 +828,10 @@ bool lvgl_port_init(LCD *lcd, Touch *tp)
|
|||||||
|
|
||||||
#if LVGL_PORT_AVOID_TEAR
|
#if LVGL_PORT_AVOID_TEAR
|
||||||
lcd->attachRefreshFinishCallback(onLcdVsyncCallback, (void *)lvgl_task_handle);
|
lcd->attachRefreshFinishCallback(onLcdVsyncCallback, (void *)lvgl_task_handle);
|
||||||
|
#else
|
||||||
|
if (bus_type == ESP_PANEL_BUS_TYPE_RGB) {
|
||||||
|
lcd->attachRefreshFinishCallback(onPerfVsyncCallback, nullptr);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -815,6 +845,15 @@ bool lvgl_port_lock(int timeout_ms)
|
|||||||
return (xSemaphoreTakeRecursive(lvgl_mux, timeout_ticks) == pdTRUE);
|
return (xSemaphoreTakeRecursive(lvgl_mux, timeout_ticks) == pdTRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool lvgl_port_lock_available(void)
|
||||||
|
{
|
||||||
|
if (!lvgl_port_lock(0)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
lvgl_port_unlock();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool lvgl_port_unlock(void)
|
bool lvgl_port_unlock(void)
|
||||||
{
|
{
|
||||||
ESP_UTILS_CHECK_NULL_RETURN(lvgl_mux, false, "LVGL mutex is not initialized");
|
ESP_UTILS_CHECK_NULL_RETURN(lvgl_mux, false, "LVGL mutex is not initialized");
|
||||||
|
|||||||
@@ -171,6 +171,14 @@ bool lvgl_port_lock(int timeout_ms);
|
|||||||
*/
|
*/
|
||||||
bool lvgl_port_unlock(void);
|
bool lvgl_port_unlock(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Try the LVGL lock without waiting and release it at once.
|
||||||
|
* Used by the perf monitor to read lv_timer_get_idle() only when the
|
||||||
|
* UI task is not mid-render (the value is a plain int, so a stale read
|
||||||
|
* is harmless; a blocked console is not).
|
||||||
|
*/
|
||||||
|
bool lvgl_port_lock_available(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ typedef struct {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Decoded driveline speeds. Deliberately NOT part of automotive_data_t: that
|
* Decoded driveline speeds. Deliberately NOT part of automotive_data_t: that
|
||||||
* struct is the wire format for the UART link to Controller B, and widening it
|
* struct is the wire format for the UART link to Inst. Cluster, and widening it
|
||||||
* would break the receiver. These live here until there's a reason to spend a
|
* would break the receiver. These live here until there's a reason to spend a
|
||||||
* protocol version bump on them.
|
* protocol version bump on them.
|
||||||
*
|
*
|
||||||
@@ -178,10 +178,9 @@ namespace CANDriver {
|
|||||||
void setVerboseDecode(bool enabled);
|
void setVerboseDecode(bool enabled);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UI event handler for CAN toggle switch
|
* Settings-screen switch: start/stop the CAN task and remember the choice in NVS.
|
||||||
* @param e LVGL event
|
|
||||||
*/
|
*/
|
||||||
void onCANToggle(lv_event_t *e);
|
void setEnabled(bool enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // _CAN_DRIVER_H
|
#endif // _CAN_DRIVER_H
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* automotive_data.h
|
* automotive_data.h
|
||||||
*
|
*
|
||||||
* Shared wire contract between Controller A (ESP32-S3-Touch-LCD-5B) and
|
* Shared wire contract between Main CTRL (ESP32-S3-Touch-LCD-5B) and
|
||||||
* Controller B (ESP32-S3-LCD-1.3).
|
* Inst. Cluster (ESP32-S3-LCD-1.3).
|
||||||
*
|
*
|
||||||
* THIS FILE MUST BE BYTE-IDENTICAL IN BOTH REPOS. Copy it across whenever it
|
* THIS FILE MUST BE BYTE-IDENTICAL IN BOTH REPOS. Copy it across whenever it
|
||||||
* changes and bump PACKET_VERSION; B rejects frames with any other version.
|
* changes and bump PACKET_VERSION; B rejects frames with any other version.
|
||||||
@@ -16,6 +16,13 @@
|
|||||||
* - link_config_t: Patrol gauge calibration + alert thresholds, edited on A,
|
* - link_config_t: Patrol gauge calibration + alert thresholds, edited on A,
|
||||||
* executed on B (tach + coolant PWM outputs)
|
* executed on B (tach + coolant PWM outputs)
|
||||||
* - the same frames go out on UART1 and ESP-NOW; B dedupes by packet_id
|
* - the same frames go out on UART1 and ESP-NOW; B dedupes by packet_id
|
||||||
|
*
|
||||||
|
* v2 additions (2026-09-27, PACKET_VERSION unchanged - DATA/CONFIG are the same
|
||||||
|
* bytes, an older B counts the new types as FRAME_ERR_TYPE and carries on):
|
||||||
|
* - STATUS B -> A (ESP-NOW unicast): B's version, OTA phase, uptime
|
||||||
|
* - PAIR A -> B (UART wire ONLY): the shared secret for SECURE frames
|
||||||
|
* - SECURE A -> B (ESP-NOW unicast): AES-256-GCM envelope carrying an
|
||||||
|
* OTA_CMD or WIFI_CREDS payload. See ESP32-S3-LCD-1.3/wiki/pages/controller-b-ota.md
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _AUTOMOTIVE_DATA_H
|
#ifndef _AUTOMOTIVE_DATA_H
|
||||||
@@ -38,8 +45,8 @@
|
|||||||
// (B hops until it hears A, then locks)
|
// (B hops until it hears A, then locks)
|
||||||
|
|
||||||
// NOTE: UART pin assignments are controller-specific:
|
// NOTE: UART pin assignments are controller-specific:
|
||||||
// - Controller A (5B): uart_manager.cpp (TX GPIO 44 -> SP3485 -> 485_A/B)
|
// - Main CTRL (5B): uart_manager.cpp (TX GPIO 44 -> SP3485 -> 485_A/B)
|
||||||
// - Controller B (1.3): platformio.ini (RX IO1)
|
// - Inst. Cluster (1.3): platformio.ini (RX IO1)
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// FRAME FORMAT (identical on UART and ESP-NOW)
|
// FRAME FORMAT (identical on UART and ESP-NOW)
|
||||||
@@ -53,12 +60,19 @@
|
|||||||
#define PACKET_END_BYTE 0x55
|
#define PACKET_END_BYTE 0x55
|
||||||
#define PACKET_VERSION 0x02
|
#define PACKET_VERSION 0x02
|
||||||
|
|
||||||
#define PACKET_TYPE_DATA 0x01 // payload = automotive_data_t
|
#define PACKET_TYPE_DATA 0x01 // A -> B payload = automotive_data_t
|
||||||
#define PACKET_TYPE_CONFIG 0x02 // payload = link_config_t
|
#define PACKET_TYPE_CONFIG 0x02 // A -> B payload = link_config_t
|
||||||
|
#define PACKET_TYPE_STATUS 0x03 // B -> A payload = link_status_t (ESP-NOW unicast)
|
||||||
|
#define PACKET_TYPE_PAIR 0x04 // A -> B payload = link_pair_t (UART wire only, never radio)
|
||||||
|
#define PACKET_TYPE_SECURE 0x05 // A -> B payload = secure envelope, see LINK MAINTENANCE below
|
||||||
|
// Inner types carried inside a SECURE envelope (never on the wire in the clear):
|
||||||
|
#define LINK_INNER_OTA_CMD 0x11 // link_ota_cmd_t
|
||||||
|
#define LINK_INNER_WIFI_CREDS 0x12 // link_wifi_creds_t
|
||||||
|
|
||||||
#define PACKET_HEADER_SIZE 4 // start, version, type, length
|
#define PACKET_HEADER_SIZE 4 // start, version, type, length
|
||||||
#define PACKET_TRAILER_SIZE 2 // checksum, end
|
#define PACKET_TRAILER_SIZE 2 // checksum, end
|
||||||
#define PACKET_MAX_PAYLOAD 64
|
#define PACKET_MAX_PAYLOAD 160 // was 64 until 2026-09-27; SECURE(WIFI_CREDS) needs 127.
|
||||||
|
// Whole frame 166 B < ESP-NOW's 250 B limit.
|
||||||
#define PACKET_MAX_SIZE (PACKET_HEADER_SIZE + PACKET_MAX_PAYLOAD + PACKET_TRAILER_SIZE)
|
#define PACKET_MAX_SIZE (PACKET_HEADER_SIZE + PACKET_MAX_PAYLOAD + PACKET_TRAILER_SIZE)
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -76,7 +90,7 @@ typedef enum {
|
|||||||
LEVER_UNKNOWN = 0xFF
|
LEVER_UNKNOWN = 0xFF
|
||||||
} gear_lever_t;
|
} gear_lever_t;
|
||||||
|
|
||||||
// Controller A's internal gear enum (CAN decode helpers below use it). Not on
|
// Main CTRL's internal gear enum (CAN decode helpers below use it). Not on
|
||||||
// the wire any more - B never sees it.
|
// the wire any more - B never sees it.
|
||||||
typedef enum {
|
typedef enum {
|
||||||
GEAR_PARK = 0,
|
GEAR_PARK = 0,
|
||||||
@@ -201,6 +215,88 @@ static inline void link_config_defaults(link_config_t* c) {
|
|||||||
c->battery_low_x100 = 1100;
|
c->battery_low_x100 = 1100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// LINK MAINTENANCE FRAMES (2026-09-27) - Inst. Cluster firmware updates
|
||||||
|
// ============================================================================
|
||||||
|
//
|
||||||
|
// B pulls its own signed release over Wi-Fi; A only hands it the credentials
|
||||||
|
// and the trigger. Both repos are public, so nothing secret is compiled in:
|
||||||
|
// the shared key is generated on A at pairing time and travels to B over the
|
||||||
|
// UART wire only. Everything A later sends B by radio that matters (Wi-Fi
|
||||||
|
// credentials, OTA commands) goes inside a SECURE envelope under that key.
|
||||||
|
// STATUS frames carry nothing secret and go in the clear.
|
||||||
|
|
||||||
|
#define LINK_KEY_LEN 32 // AES-256
|
||||||
|
#define LINK_NONCE_LEN 12 // GCM IV, random per frame
|
||||||
|
#define LINK_TAG_LEN 16 // GCM tag
|
||||||
|
#define LINK_STATUS_PERIOD_MS 5000 // B -> A STATUS cadence
|
||||||
|
#define LINK_STATUS_TIMEOUT_MS 15000 // A: B "not heard" after this
|
||||||
|
|
||||||
|
// --- PAIR (A -> B, wire only) -----------------------------------------------
|
||||||
|
#define LINK_PAIR_MAGIC 0x52494150UL // "PAIR"
|
||||||
|
typedef struct __attribute__((packed)) {
|
||||||
|
uint32_t magic; // LINK_PAIR_MAGIC - guards against a torn frame
|
||||||
|
uint8_t key[LINK_KEY_LEN]; // the shared secret; both sides keep it in NVS
|
||||||
|
uint8_t a_mac[6]; // A's STA MAC: the only sender B accepts SECURE frames from
|
||||||
|
} link_pair_t; // 42 bytes
|
||||||
|
|
||||||
|
// --- STATUS (B -> A, ESP-NOW unicast, every LINK_STATUS_PERIOD_MS) ----------
|
||||||
|
// ota_phase mirrors Main CTRL's Ota::phase_t so one UI renders both.
|
||||||
|
#define LINK_OTA_IDLE 0
|
||||||
|
#define LINK_OTA_CHECKING 1
|
||||||
|
#define LINK_OTA_UP_TO_DATE 2
|
||||||
|
#define LINK_OTA_AVAILABLE 3
|
||||||
|
#define LINK_OTA_INSTALLING 4
|
||||||
|
#define LINK_OTA_FAILED 5
|
||||||
|
|
||||||
|
#define LINK_STATUS_PAIRED (1 << 0) // B holds a pairing key
|
||||||
|
#define LINK_STATUS_HAVE_WIFI (1 << 1) // B holds Wi-Fi credentials
|
||||||
|
#define LINK_STATUS_WIFI_JOINED (1 << 2) // B is currently on the network (during a job)
|
||||||
|
#define LINK_STATUS_PENDING_VERIFY (1 << 3) // B runs a fresh image not yet confirmed
|
||||||
|
|
||||||
|
typedef struct __attribute__((packed)) {
|
||||||
|
char version[16]; // B's firmware version ("dev" for local builds)
|
||||||
|
uint8_t ota_phase; // LINK_OTA_*
|
||||||
|
uint8_t ota_progress; // 0..100 while installing
|
||||||
|
uint8_t flags; // LINK_STATUS_*
|
||||||
|
uint8_t reserved;
|
||||||
|
uint16_t key_fp; // first two bytes of SHA-256(pairing key); 0 = unpaired.
|
||||||
|
// Lets A see "paired with MY key" vs "paired with an old one".
|
||||||
|
uint32_t uptime_s;
|
||||||
|
uint32_t free_heap; // internal heap free, bytes
|
||||||
|
char latest[16]; // latest release tag B knows of ("" = never checked)
|
||||||
|
char message[32]; // failure reason when ota_phase == LINK_OTA_FAILED
|
||||||
|
} link_status_t; // 78 bytes
|
||||||
|
|
||||||
|
// --- OTA_CMD (inner, A -> B) ------------------------------------------------
|
||||||
|
#define LINK_OTA_CMD_CHECK 1
|
||||||
|
#define LINK_OTA_CMD_INSTALL 2
|
||||||
|
#define LINK_OTA_CMD_ROLLBACK 3
|
||||||
|
#define LINK_OTA_FORCE (1 << 0) // reinstall even if versions match
|
||||||
|
|
||||||
|
typedef struct __attribute__((packed)) {
|
||||||
|
uint8_t cmd; // LINK_OTA_CMD_*
|
||||||
|
uint8_t flags; // LINK_OTA_FORCE
|
||||||
|
uint32_t nonce; // random; B drops a repeat of a recently seen one
|
||||||
|
} link_ota_cmd_t; // 6 bytes
|
||||||
|
|
||||||
|
// --- WIFI_CREDS (inner, A -> B) ---------------------------------------------
|
||||||
|
#define LINK_WIFI_SET 1
|
||||||
|
#define LINK_WIFI_FORGET 2
|
||||||
|
|
||||||
|
typedef struct __attribute__((packed)) {
|
||||||
|
uint8_t action; // LINK_WIFI_*
|
||||||
|
char ssid[33];
|
||||||
|
char pass[64];
|
||||||
|
} link_wifi_creds_t; // 98 bytes
|
||||||
|
|
||||||
|
// --- SECURE envelope ---------------------------------------------------------
|
||||||
|
// payload = nonce[12] | tag[16] | ciphertext
|
||||||
|
// ciphertext = AES-256-GCM(key, nonce, plaintext = inner_type | inner_payload)
|
||||||
|
// Helpers that do the encryption live in protocol/link_secure.h (mbedtls).
|
||||||
|
#define LINK_SECURE_OVERHEAD (LINK_NONCE_LEN + LINK_TAG_LEN)
|
||||||
|
#define LINK_SECURE_MAX_INNER (PACKET_MAX_PAYLOAD - LINK_SECURE_OVERHEAD) // 132: 1 + 98 fits
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// CAN BUS ID MAPPINGS (BMW-Specific)
|
// CAN BUS ID MAPPINGS (BMW-Specific)
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -413,6 +509,12 @@ static inline frame_status_t frame_parse(const uint8_t* f, size_t n,
|
|||||||
if (l != sizeof(automotive_data_t)) return FRAME_ERR_TYPE;
|
if (l != sizeof(automotive_data_t)) return FRAME_ERR_TYPE;
|
||||||
} else if (t == PACKET_TYPE_CONFIG) {
|
} else if (t == PACKET_TYPE_CONFIG) {
|
||||||
if (l != sizeof(link_config_t)) return FRAME_ERR_TYPE;
|
if (l != sizeof(link_config_t)) return FRAME_ERR_TYPE;
|
||||||
|
} else if (t == PACKET_TYPE_STATUS) {
|
||||||
|
if (l != sizeof(link_status_t)) return FRAME_ERR_TYPE;
|
||||||
|
} else if (t == PACKET_TYPE_PAIR) {
|
||||||
|
if (l != sizeof(link_pair_t)) return FRAME_ERR_TYPE;
|
||||||
|
} else if (t == PACKET_TYPE_SECURE) {
|
||||||
|
if (l < LINK_SECURE_OVERHEAD + 1) return FRAME_ERR_TYPE; // at least the inner type byte
|
||||||
} else {
|
} else {
|
||||||
return FRAME_ERR_TYPE;
|
return FRAME_ERR_TYPE;
|
||||||
}
|
}
|
||||||
@@ -654,7 +756,7 @@ static inline const char* gear_to_string(gear_position_t gear) {
|
|||||||
* @return Pointer to buffer
|
* @return Pointer to buffer
|
||||||
*/
|
*/
|
||||||
static inline char* format_temperature(int16_t temp_x10, char* buffer) {
|
static inline char* format_temperature(int16_t temp_x10, char* buffer) {
|
||||||
// Plain "C": Controller B's UI font has no degree-sign glyph.
|
// Plain "C": Inst. Cluster's UI font has no degree-sign glyph.
|
||||||
sprintf(buffer, "%d.%dC", temp_x10 / 10, abs(temp_x10 % 10));
|
sprintf(buffer, "%d.%dC", temp_x10 / 10, abs(temp_x10 % 10));
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
@@ -670,16 +772,8 @@ static inline char* format_voltage(uint16_t voltage_x100, char* buffer) {
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// No default / test values: a field is only ever filled from a CAN frame, and
|
||||||
// DEFAULT/TEST VALUES
|
// its VALID_FLAG_* bit says so. Removed 2026-09-28 - the bench defaults
|
||||||
// ============================================================================
|
// (89 / 85 degC, 12.45 V) looked like real readings on Inst. Cluster.
|
||||||
|
|
||||||
// Default values for testing (before CAN data is available)
|
|
||||||
#define DEFAULT_GEAR_LEVER LEVER_PARK
|
|
||||||
#define DEFAULT_GEARBOX_TEMP 850 // 85.0°C
|
|
||||||
#define DEFAULT_ENGINE_OIL_TEMP 920 // 92.0°C
|
|
||||||
#define DEFAULT_COOLANT_TEMP 890 // 89.0°C
|
|
||||||
#define DEFAULT_BATTERY_VOLTAGE 1245 // 12.45V
|
|
||||||
#define DEFAULT_ALERTS 0x0000 // No alerts
|
|
||||||
|
|
||||||
#endif // _AUTOMOTIVE_DATA_H
|
#endif // _AUTOMOTIVE_DATA_H
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
/**
|
||||||
|
* link_secure.h - the SECURE envelope of the A <-> B link (see automotive_data.h).
|
||||||
|
*
|
||||||
|
* THIS FILE MUST BE BYTE-IDENTICAL IN BOTH REPOS, like automotive_data.h.
|
||||||
|
*
|
||||||
|
* payload = nonce[12] | tag[16] | AES-256-GCM(key, nonce, inner_type | inner)
|
||||||
|
*
|
||||||
|
* Both cores ship mbedtls (2.28 on Inst. Cluster's IDF 4.4, 3.x on Controller
|
||||||
|
* A's IDF 5.5); the GCM calls are the same, only SHA-256's name differs.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LINK_SECURE_H
|
||||||
|
#define LINK_SECURE_H
|
||||||
|
|
||||||
|
#include "automotive_data.h"
|
||||||
|
#include <mbedtls/gcm.h>
|
||||||
|
#include <mbedtls/sha256.h>
|
||||||
|
#include <mbedtls/version.h>
|
||||||
|
#if __has_include(<esp_random.h>)
|
||||||
|
#include <esp_random.h>
|
||||||
|
#else
|
||||||
|
#include <esp_system.h> // IDF 4.4: esp_random / esp_fill_random live here
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** First two bytes of SHA-256(key), never 0 (0 means "unpaired" on the wire). */
|
||||||
|
static inline uint16_t link_key_fingerprint(const uint8_t key[LINK_KEY_LEN]) {
|
||||||
|
uint8_t h[32];
|
||||||
|
#if MBEDTLS_VERSION_MAJOR >= 3
|
||||||
|
mbedtls_sha256(key, LINK_KEY_LEN, h, 0);
|
||||||
|
#else
|
||||||
|
mbedtls_sha256_ret(key, LINK_KEY_LEN, h, 0);
|
||||||
|
#endif
|
||||||
|
uint16_t fp = (uint16_t)((h[0] << 8) | h[1]);
|
||||||
|
return fp ? fp : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Seal inner_type + inner into a SECURE payload.
|
||||||
|
* @param out buffer of PACKET_MAX_PAYLOAD bytes
|
||||||
|
* @return payload length, or 0 on error / oversize
|
||||||
|
*/
|
||||||
|
static inline size_t link_secure_seal(const uint8_t key[LINK_KEY_LEN], uint8_t inner_type,
|
||||||
|
const void* inner, size_t inner_len, uint8_t* out) {
|
||||||
|
if (inner_len + 1 > LINK_SECURE_MAX_INNER) return 0;
|
||||||
|
uint8_t plain[LINK_SECURE_MAX_INNER];
|
||||||
|
plain[0] = inner_type;
|
||||||
|
memcpy(&plain[1], inner, inner_len);
|
||||||
|
size_t n = inner_len + 1;
|
||||||
|
|
||||||
|
uint8_t* nonce = out;
|
||||||
|
uint8_t* tag = out + LINK_NONCE_LEN;
|
||||||
|
uint8_t* ct = out + LINK_SECURE_OVERHEAD;
|
||||||
|
esp_fill_random(nonce, LINK_NONCE_LEN);
|
||||||
|
|
||||||
|
mbedtls_gcm_context g;
|
||||||
|
mbedtls_gcm_init(&g);
|
||||||
|
int rc = mbedtls_gcm_setkey(&g, MBEDTLS_CIPHER_ID_AES, key, LINK_KEY_LEN * 8);
|
||||||
|
if (rc == 0) {
|
||||||
|
rc = mbedtls_gcm_crypt_and_tag(&g, MBEDTLS_GCM_ENCRYPT, n, nonce, LINK_NONCE_LEN,
|
||||||
|
NULL, 0, plain, ct, LINK_TAG_LEN, tag);
|
||||||
|
}
|
||||||
|
mbedtls_gcm_free(&g);
|
||||||
|
return rc == 0 ? LINK_SECURE_OVERHEAD + n : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open a SECURE payload. On success *inner_type and inner (LINK_SECURE_MAX_INNER
|
||||||
|
* bytes) are filled; *inner_len excludes the type byte.
|
||||||
|
*/
|
||||||
|
static inline bool link_secure_open(const uint8_t key[LINK_KEY_LEN], const uint8_t* payload, size_t len,
|
||||||
|
uint8_t* inner_type, uint8_t* inner, size_t* inner_len) {
|
||||||
|
if (len < LINK_SECURE_OVERHEAD + 1 || len > PACKET_MAX_PAYLOAD) return false;
|
||||||
|
size_t n = len - LINK_SECURE_OVERHEAD;
|
||||||
|
uint8_t plain[LINK_SECURE_MAX_INNER];
|
||||||
|
|
||||||
|
mbedtls_gcm_context g;
|
||||||
|
mbedtls_gcm_init(&g);
|
||||||
|
int rc = mbedtls_gcm_setkey(&g, MBEDTLS_CIPHER_ID_AES, key, LINK_KEY_LEN * 8);
|
||||||
|
if (rc == 0) {
|
||||||
|
rc = mbedtls_gcm_auth_decrypt(&g, n, payload, LINK_NONCE_LEN, NULL, 0,
|
||||||
|
payload + LINK_NONCE_LEN, LINK_TAG_LEN,
|
||||||
|
payload + LINK_SECURE_OVERHEAD, plain);
|
||||||
|
}
|
||||||
|
mbedtls_gcm_free(&g);
|
||||||
|
if (rc != 0) return false;
|
||||||
|
|
||||||
|
*inner_type = plain[0];
|
||||||
|
*inner_len = n - 1;
|
||||||
|
memcpy(inner, &plain[1], n - 1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // LINK_SECURE_H
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
SET(SOURCES screens/ui_Settings_Screen.c
|
|
||||||
ui_theme_manager.c
|
|
||||||
ui_themes.c
|
|
||||||
ui.c
|
|
||||||
components/ui_comp_hook.c
|
|
||||||
ui_helpers.c)
|
|
||||||
|
|
||||||
add_library(ui ${SOURCES})
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
// This file was generated by SquareLine Studio
|
|
||||||
// SquareLine Studio version: SquareLine Studio 1.5.4
|
|
||||||
// LVGL version: 8.3.6
|
|
||||||
// Project name: ESP32-S3-Touch-LCD
|
|
||||||
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
screens/ui_Settings_Screen.c
|
|
||||||
ui_theme_manager.c
|
|
||||||
ui_themes.c
|
|
||||||
ui.c
|
|
||||||
components/ui_comp_hook.c
|
|
||||||
ui_helpers.c
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"project_name": "SquareLine_Project.spj",
|
|
||||||
"datetime": "2025-11-09T17:09:26.2274380+01:00",
|
|
||||||
"editor_version": "1.5.4",
|
|
||||||
"project_version": 60,
|
|
||||||
"user": "Goxhe Altin",
|
|
||||||
"export_datetime": "2025-11-09T17:09:28.3122290+01:00",
|
|
||||||
"export_user": "Goxhe Altin"
|
|
||||||
}
|
|
||||||
@@ -1,552 +0,0 @@
|
|||||||
// This file was generated by SquareLine Studio
|
|
||||||
// SquareLine Studio version: SquareLine Studio 1.5.4
|
|
||||||
// LVGL version: 8.3.6
|
|
||||||
// Project name: ESP32-S3-Touch-LCD-5B
|
|
||||||
|
|
||||||
#include "../ui.h"
|
|
||||||
|
|
||||||
// Hand-coded Driveline screen (src/modules/driveline_screen.cpp) - replaces Home
|
|
||||||
void app_show_driveline(void);
|
|
||||||
|
|
||||||
lv_obj_t * uic_Settings_Loading_Spinner;
|
|
||||||
lv_obj_t * uic_Settings_Loading_Container;
|
|
||||||
lv_obj_t * uic_CPU_Values_LBL;
|
|
||||||
lv_obj_t * uic_FPS_Values_LBL;
|
|
||||||
lv_obj_t * uic_Device_State_Values_LBL;
|
|
||||||
lv_obj_t * uic_CPU_Static_LBL;
|
|
||||||
lv_obj_t * uic_FPS_Static_LBL;
|
|
||||||
lv_obj_t * uic_Static_LBLS_Container;
|
|
||||||
lv_obj_t * uic_Device_State_Container;
|
|
||||||
lv_obj_t * uic_Keyboard;
|
|
||||||
lv_obj_t * uic_Wifi_Passkey_TB;
|
|
||||||
lv_obj_t * uic_Select_SSID_BTN;
|
|
||||||
lv_obj_t * uic_Wifi_Container;
|
|
||||||
lv_obj_t * uic_Enable_Debug_LBL;
|
|
||||||
lv_obj_t * uic_Toggle_Debug_Switch;
|
|
||||||
lv_obj_t * uic_Debug_CTRL_Panel;
|
|
||||||
lv_obj_t * uic_Enable_BLE_LBL;
|
|
||||||
lv_obj_t * uic_Toggle_BLE_Switch;
|
|
||||||
lv_obj_t * uic_BLE_CTRL_Panel;
|
|
||||||
lv_obj_t * uic_Enable_Wifi_LBL;
|
|
||||||
lv_obj_t * uic_Toggle_Wifi_Switch;
|
|
||||||
lv_obj_t * uic_Wifi_CTRL_Panel;
|
|
||||||
lv_obj_t * uic_Enable_UART_LBL;
|
|
||||||
lv_obj_t * uic_Toggle_UART_Switch;
|
|
||||||
lv_obj_t * uic_UART_CTRL_Panel;
|
|
||||||
lv_obj_t * uic_Enable_CAN_Bus_LBL;
|
|
||||||
lv_obj_t * uic_Toggle_CAN_Bus_Switch;
|
|
||||||
lv_obj_t * uic_CAN_Bus_CTRL_Panel;
|
|
||||||
lv_obj_t * uic_Settings_CTRL_Container;
|
|
||||||
lv_obj_t * uic_Main_Container;
|
|
||||||
lv_obj_t * uic_Settings_Screen_LBL;
|
|
||||||
lv_obj_t * uic_Settings_Screen;
|
|
||||||
lv_obj_t * ui_Settings_Screen = NULL;
|
|
||||||
lv_obj_t * ui_Settings_Screen_LBL = NULL;
|
|
||||||
lv_obj_t * ui_Main_Container = NULL;
|
|
||||||
lv_obj_t * ui_Settings_CTRL_Container = NULL;
|
|
||||||
lv_obj_t * ui_CAN_Bus_CTRL_Panel = NULL;
|
|
||||||
lv_obj_t * ui_Toggle_CAN_Bus_Switch = NULL;
|
|
||||||
lv_obj_t * ui_Enable_CAN_Bus_LBL = NULL;
|
|
||||||
lv_obj_t * ui_UART_CTRL_Panel = NULL;
|
|
||||||
lv_obj_t * ui_Toggle_UART_Switch = NULL;
|
|
||||||
lv_obj_t * ui_Enable_UART_LBL = NULL;
|
|
||||||
lv_obj_t * ui_Wifi_CTRL_Panel = NULL;
|
|
||||||
lv_obj_t * ui_Toggle_Wifi_Switch = NULL;
|
|
||||||
lv_obj_t * ui_Enable_Wifi_LBL = NULL;
|
|
||||||
lv_obj_t * ui_BLE_CTRL_Panel = NULL;
|
|
||||||
lv_obj_t * ui_Toggle_BLE_Switch = NULL;
|
|
||||||
lv_obj_t * ui_Enable_BLE_LBL = NULL;
|
|
||||||
lv_obj_t * ui_Debug_CTRL_Panel = NULL;
|
|
||||||
lv_obj_t * ui_Toggle_Debug_Switch = NULL;
|
|
||||||
lv_obj_t * ui_Enable_Debug_LBL = NULL;
|
|
||||||
lv_obj_t * ui_Wifi_Container = NULL;
|
|
||||||
lv_obj_t * ui_Select_SSID_BTN = NULL;
|
|
||||||
lv_obj_t * ui_Wifi_Passkey_TB = NULL;
|
|
||||||
lv_obj_t * ui_Keyboard = NULL;
|
|
||||||
lv_obj_t * ui_Device_State_Container = NULL;
|
|
||||||
lv_obj_t * ui_Static_LBLS_Container = NULL;
|
|
||||||
lv_obj_t * ui_FPS_Static_LBL = NULL;
|
|
||||||
lv_obj_t * ui_CPU_Static_LBL = NULL;
|
|
||||||
lv_obj_t * ui_Device_State_Values_LBL = NULL;
|
|
||||||
lv_obj_t * ui_FPS_Values_LBL = NULL;
|
|
||||||
lv_obj_t * ui_CPU_Values_LBL = NULL;
|
|
||||||
lv_obj_t * ui_Settings_Loading_Container = NULL;
|
|
||||||
lv_obj_t * ui_Settings_Loading_Spinner = NULL;
|
|
||||||
// event funtions
|
|
||||||
void ui_event_Settings_Screen(lv_event_t * e)
|
|
||||||
{
|
|
||||||
lv_event_code_t event_code = lv_event_get_code(e);
|
|
||||||
|
|
||||||
if(event_code == LV_EVENT_GESTURE && lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_RIGHT) {
|
|
||||||
lv_indev_wait_release(lv_indev_get_act());
|
|
||||||
app_show_driveline(); // Home screen removed; back goes to the Driveline screen
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ui_event_Toggle_UART_Switch(lv_event_t * e)
|
|
||||||
{
|
|
||||||
lv_event_code_t event_code = lv_event_get_code(e);
|
|
||||||
|
|
||||||
if(event_code == LV_EVENT_RELEASED) {
|
|
||||||
onUARTToggle(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ui_event_Toggle_Wifi_Switch(lv_event_t * e)
|
|
||||||
{
|
|
||||||
lv_event_code_t event_code = lv_event_get_code(e);
|
|
||||||
|
|
||||||
if(event_code == LV_EVENT_RELEASED) {
|
|
||||||
onWifiToggle(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ui_event_Toggle_CAN_Bus_Switch(lv_event_t * e)
|
|
||||||
{
|
|
||||||
lv_event_code_t event_code = lv_event_get_code(e);
|
|
||||||
|
|
||||||
if(event_code == LV_EVENT_RELEASED) {
|
|
||||||
onCANBusToggle(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ui_event_Toggle_Debug_Switch(lv_event_t * e)
|
|
||||||
{
|
|
||||||
lv_event_code_t event_code = lv_event_get_code(e);
|
|
||||||
|
|
||||||
if(event_code == LV_EVENT_RELEASED) {
|
|
||||||
onDebugToggle(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ui_event_Select_SSID_BTN(lv_event_t * e)
|
|
||||||
{
|
|
||||||
lv_event_code_t event_code = lv_event_get_code(e);
|
|
||||||
|
|
||||||
if(event_code == LV_EVENT_CLICKED) {
|
|
||||||
onSelectSSID(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// build funtions
|
|
||||||
|
|
||||||
void ui_Settings_Screen_screen_init(void)
|
|
||||||
{
|
|
||||||
ui_Settings_Screen = lv_obj_create(NULL);
|
|
||||||
lv_obj_clear_flag(ui_Settings_Screen, LV_OBJ_FLAG_SCROLLABLE); /// Flags
|
|
||||||
lv_obj_add_event_cb(ui_Settings_Screen, scr_unloaded_delete_cb, LV_EVENT_SCREEN_UNLOADED,
|
|
||||||
ui_Settings_Screen_screen_destroy);
|
|
||||||
|
|
||||||
ui_Settings_Screen_LBL = lv_label_create(ui_Settings_Screen);
|
|
||||||
lv_obj_set_width(ui_Settings_Screen_LBL, LV_SIZE_CONTENT); /// 1
|
|
||||||
lv_obj_set_height(ui_Settings_Screen_LBL, LV_SIZE_CONTENT); /// 1
|
|
||||||
lv_obj_set_x(ui_Settings_Screen_LBL, -405);
|
|
||||||
lv_obj_set_y(ui_Settings_Screen_LBL, -268);
|
|
||||||
lv_obj_set_align(ui_Settings_Screen_LBL, LV_ALIGN_CENTER);
|
|
||||||
lv_label_set_text(ui_Settings_Screen_LBL, "Settings");
|
|
||||||
lv_obj_set_style_text_font(ui_Settings_Screen_LBL, &lv_font_montserrat_48, LV_PART_MAIN | LV_STATE_DEFAULT);
|
|
||||||
|
|
||||||
ui_Main_Container = lv_obj_create(ui_Settings_Screen);
|
|
||||||
lv_obj_remove_style_all(ui_Main_Container);
|
|
||||||
lv_obj_set_width(ui_Main_Container, 1024);
|
|
||||||
lv_obj_set_height(ui_Main_Container, 530);
|
|
||||||
lv_obj_set_x(ui_Main_Container, 0);
|
|
||||||
lv_obj_set_y(ui_Main_Container, 34);
|
|
||||||
lv_obj_set_align(ui_Main_Container, LV_ALIGN_CENTER);
|
|
||||||
lv_obj_set_flex_flow(ui_Main_Container, LV_FLEX_FLOW_ROW_WRAP);
|
|
||||||
lv_obj_set_flex_align(ui_Main_Container, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER);
|
|
||||||
lv_obj_clear_flag(ui_Main_Container, LV_OBJ_FLAG_CLICKABLE | LV_OBJ_FLAG_SCROLLABLE); /// Flags
|
|
||||||
|
|
||||||
ui_Settings_CTRL_Container = lv_obj_create(ui_Main_Container);
|
|
||||||
lv_obj_remove_style_all(ui_Settings_CTRL_Container);
|
|
||||||
lv_obj_set_width(ui_Settings_CTRL_Container, 410);
|
|
||||||
lv_obj_set_height(ui_Settings_CTRL_Container, 530);
|
|
||||||
lv_obj_set_x(ui_Settings_CTRL_Container, -130);
|
|
||||||
lv_obj_set_y(ui_Settings_CTRL_Container, 8);
|
|
||||||
lv_obj_set_align(ui_Settings_CTRL_Container, LV_ALIGN_CENTER);
|
|
||||||
lv_obj_set_flex_flow(ui_Settings_CTRL_Container, LV_FLEX_FLOW_COLUMN);
|
|
||||||
lv_obj_set_flex_align(ui_Settings_CTRL_Container, LV_FLEX_ALIGN_SPACE_AROUND, LV_FLEX_ALIGN_CENTER,
|
|
||||||
LV_FLEX_ALIGN_SPACE_EVENLY);
|
|
||||||
lv_obj_clear_flag(ui_Settings_CTRL_Container, LV_OBJ_FLAG_CLICKABLE | LV_OBJ_FLAG_SCROLLABLE); /// Flags
|
|
||||||
|
|
||||||
ui_CAN_Bus_CTRL_Panel = lv_obj_create(ui_Settings_CTRL_Container);
|
|
||||||
lv_obj_set_width(ui_CAN_Bus_CTRL_Panel, 400);
|
|
||||||
lv_obj_set_height(ui_CAN_Bus_CTRL_Panel, 100);
|
|
||||||
lv_obj_set_x(ui_CAN_Bus_CTRL_Panel, 0);
|
|
||||||
lv_obj_set_y(ui_CAN_Bus_CTRL_Panel, 1);
|
|
||||||
lv_obj_set_align(ui_CAN_Bus_CTRL_Panel, LV_ALIGN_CENTER);
|
|
||||||
lv_obj_set_flex_flow(ui_CAN_Bus_CTRL_Panel, LV_FLEX_FLOW_ROW);
|
|
||||||
lv_obj_set_flex_align(ui_CAN_Bus_CTRL_Panel, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
|
|
||||||
lv_obj_clear_flag(ui_CAN_Bus_CTRL_Panel, LV_OBJ_FLAG_SCROLLABLE); /// Flags
|
|
||||||
lv_obj_set_style_bg_color(ui_CAN_Bus_CTRL_Panel, lv_color_hex(0x7F7A9C), LV_PART_MAIN | LV_STATE_DEFAULT);
|
|
||||||
lv_obj_set_style_bg_opa(ui_CAN_Bus_CTRL_Panel, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
|
|
||||||
|
|
||||||
ui_Toggle_CAN_Bus_Switch = lv_switch_create(ui_CAN_Bus_CTRL_Panel);
|
|
||||||
lv_obj_set_width(ui_Toggle_CAN_Bus_Switch, 110);
|
|
||||||
lv_obj_set_height(ui_Toggle_CAN_Bus_Switch, 60);
|
|
||||||
lv_obj_set_x(ui_Toggle_CAN_Bus_Switch, -181);
|
|
||||||
lv_obj_set_y(ui_Toggle_CAN_Bus_Switch, -3);
|
|
||||||
lv_obj_set_align(ui_Toggle_CAN_Bus_Switch, LV_ALIGN_CENTER);
|
|
||||||
|
|
||||||
ui_Enable_CAN_Bus_LBL = lv_label_create(ui_CAN_Bus_CTRL_Panel);
|
|
||||||
lv_obj_set_width(ui_Enable_CAN_Bus_LBL, LV_SIZE_CONTENT); /// 1
|
|
||||||
lv_obj_set_height(ui_Enable_CAN_Bus_LBL, LV_SIZE_CONTENT); /// 1
|
|
||||||
lv_obj_set_x(ui_Enable_CAN_Bus_LBL, -117);
|
|
||||||
lv_obj_set_y(ui_Enable_CAN_Bus_LBL, -2);
|
|
||||||
lv_obj_set_align(ui_Enable_CAN_Bus_LBL, LV_ALIGN_CENTER);
|
|
||||||
lv_label_set_text(ui_Enable_CAN_Bus_LBL, "Enable CANBus");
|
|
||||||
lv_obj_set_style_text_font(ui_Enable_CAN_Bus_LBL, &lv_font_montserrat_30, LV_PART_MAIN | LV_STATE_DEFAULT);
|
|
||||||
|
|
||||||
ui_UART_CTRL_Panel = lv_obj_create(ui_Settings_CTRL_Container);
|
|
||||||
lv_obj_set_width(ui_UART_CTRL_Panel, 400);
|
|
||||||
lv_obj_set_height(ui_UART_CTRL_Panel, 100);
|
|
||||||
lv_obj_set_x(ui_UART_CTRL_Panel, 0);
|
|
||||||
lv_obj_set_y(ui_UART_CTRL_Panel, 1);
|
|
||||||
lv_obj_set_align(ui_UART_CTRL_Panel, LV_ALIGN_CENTER);
|
|
||||||
lv_obj_set_flex_flow(ui_UART_CTRL_Panel, LV_FLEX_FLOW_ROW);
|
|
||||||
lv_obj_set_flex_align(ui_UART_CTRL_Panel, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
|
|
||||||
lv_obj_clear_flag(ui_UART_CTRL_Panel, LV_OBJ_FLAG_SCROLLABLE); /// Flags
|
|
||||||
ui_object_set_themeable_style_property(ui_UART_CTRL_Panel, LV_PART_MAIN | LV_STATE_DEFAULT, LV_STYLE_BG_COLOR,
|
|
||||||
_ui_theme_color_panel_backgroung);
|
|
||||||
ui_object_set_themeable_style_property(ui_UART_CTRL_Panel, LV_PART_MAIN | LV_STATE_DEFAULT, LV_STYLE_BG_OPA,
|
|
||||||
_ui_theme_alpha_panel_backgroung);
|
|
||||||
|
|
||||||
ui_Toggle_UART_Switch = lv_switch_create(ui_UART_CTRL_Panel);
|
|
||||||
lv_obj_set_width(ui_Toggle_UART_Switch, 110);
|
|
||||||
lv_obj_set_height(ui_Toggle_UART_Switch, 60);
|
|
||||||
lv_obj_set_x(ui_Toggle_UART_Switch, -181);
|
|
||||||
lv_obj_set_y(ui_Toggle_UART_Switch, -3);
|
|
||||||
lv_obj_set_align(ui_Toggle_UART_Switch, LV_ALIGN_CENTER);
|
|
||||||
|
|
||||||
ui_Enable_UART_LBL = lv_label_create(ui_UART_CTRL_Panel);
|
|
||||||
lv_obj_set_width(ui_Enable_UART_LBL, LV_SIZE_CONTENT); /// 1
|
|
||||||
lv_obj_set_height(ui_Enable_UART_LBL, LV_SIZE_CONTENT); /// 1
|
|
||||||
lv_obj_set_x(ui_Enable_UART_LBL, -117);
|
|
||||||
lv_obj_set_y(ui_Enable_UART_LBL, -2);
|
|
||||||
lv_obj_set_align(ui_Enable_UART_LBL, LV_ALIGN_CENTER);
|
|
||||||
lv_label_set_text(ui_Enable_UART_LBL, "Enable UART");
|
|
||||||
lv_obj_set_style_text_font(ui_Enable_UART_LBL, &lv_font_montserrat_30, LV_PART_MAIN | LV_STATE_DEFAULT);
|
|
||||||
|
|
||||||
ui_Wifi_CTRL_Panel = lv_obj_create(ui_Settings_CTRL_Container);
|
|
||||||
lv_obj_set_width(ui_Wifi_CTRL_Panel, 405);
|
|
||||||
lv_obj_set_height(ui_Wifi_CTRL_Panel, 100);
|
|
||||||
lv_obj_set_x(ui_Wifi_CTRL_Panel, 0);
|
|
||||||
lv_obj_set_y(ui_Wifi_CTRL_Panel, 1);
|
|
||||||
lv_obj_set_align(ui_Wifi_CTRL_Panel, LV_ALIGN_CENTER);
|
|
||||||
lv_obj_set_flex_flow(ui_Wifi_CTRL_Panel, LV_FLEX_FLOW_ROW);
|
|
||||||
lv_obj_set_flex_align(ui_Wifi_CTRL_Panel, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
|
|
||||||
lv_obj_clear_flag(ui_Wifi_CTRL_Panel, LV_OBJ_FLAG_SCROLLABLE); /// Flags
|
|
||||||
ui_object_set_themeable_style_property(ui_Wifi_CTRL_Panel, LV_PART_MAIN | LV_STATE_DEFAULT, LV_STYLE_BG_COLOR,
|
|
||||||
_ui_theme_color_panel_backgroung);
|
|
||||||
ui_object_set_themeable_style_property(ui_Wifi_CTRL_Panel, LV_PART_MAIN | LV_STATE_DEFAULT, LV_STYLE_BG_OPA,
|
|
||||||
_ui_theme_alpha_panel_backgroung);
|
|
||||||
|
|
||||||
ui_Toggle_Wifi_Switch = lv_switch_create(ui_Wifi_CTRL_Panel);
|
|
||||||
lv_obj_set_width(ui_Toggle_Wifi_Switch, 110);
|
|
||||||
lv_obj_set_height(ui_Toggle_Wifi_Switch, 60);
|
|
||||||
lv_obj_set_x(ui_Toggle_Wifi_Switch, -181);
|
|
||||||
lv_obj_set_y(ui_Toggle_Wifi_Switch, -3);
|
|
||||||
lv_obj_set_align(ui_Toggle_Wifi_Switch, LV_ALIGN_CENTER);
|
|
||||||
lv_obj_add_state(ui_Toggle_Wifi_Switch, LV_STATE_DISABLED); /// States
|
|
||||||
|
|
||||||
ui_Enable_Wifi_LBL = lv_label_create(ui_Wifi_CTRL_Panel);
|
|
||||||
lv_obj_set_width(ui_Enable_Wifi_LBL, LV_SIZE_CONTENT); /// 1
|
|
||||||
lv_obj_set_height(ui_Enable_Wifi_LBL, LV_SIZE_CONTENT); /// 1
|
|
||||||
lv_obj_set_x(ui_Enable_Wifi_LBL, -117);
|
|
||||||
lv_obj_set_y(ui_Enable_Wifi_LBL, -2);
|
|
||||||
lv_obj_set_align(ui_Enable_Wifi_LBL, LV_ALIGN_CENTER);
|
|
||||||
lv_label_set_text(ui_Enable_Wifi_LBL, "Enable Wifi");
|
|
||||||
lv_obj_set_style_text_font(ui_Enable_Wifi_LBL, &lv_font_montserrat_30, LV_PART_MAIN | LV_STATE_DEFAULT);
|
|
||||||
|
|
||||||
ui_BLE_CTRL_Panel = lv_obj_create(ui_Settings_CTRL_Container);
|
|
||||||
lv_obj_set_width(ui_BLE_CTRL_Panel, 400);
|
|
||||||
lv_obj_set_height(ui_BLE_CTRL_Panel, 100);
|
|
||||||
lv_obj_set_x(ui_BLE_CTRL_Panel, 0);
|
|
||||||
lv_obj_set_y(ui_BLE_CTRL_Panel, 1);
|
|
||||||
lv_obj_set_align(ui_BLE_CTRL_Panel, LV_ALIGN_CENTER);
|
|
||||||
lv_obj_set_flex_flow(ui_BLE_CTRL_Panel, LV_FLEX_FLOW_ROW);
|
|
||||||
lv_obj_set_flex_align(ui_BLE_CTRL_Panel, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
|
|
||||||
lv_obj_clear_flag(ui_BLE_CTRL_Panel, LV_OBJ_FLAG_SCROLLABLE); /// Flags
|
|
||||||
ui_object_set_themeable_style_property(ui_BLE_CTRL_Panel, LV_PART_MAIN | LV_STATE_DEFAULT, LV_STYLE_BG_COLOR,
|
|
||||||
_ui_theme_color_panel_backgroung);
|
|
||||||
ui_object_set_themeable_style_property(ui_BLE_CTRL_Panel, LV_PART_MAIN | LV_STATE_DEFAULT, LV_STYLE_BG_OPA,
|
|
||||||
_ui_theme_alpha_panel_backgroung);
|
|
||||||
|
|
||||||
ui_Toggle_BLE_Switch = lv_switch_create(ui_BLE_CTRL_Panel);
|
|
||||||
lv_obj_set_width(ui_Toggle_BLE_Switch, 110);
|
|
||||||
lv_obj_set_height(ui_Toggle_BLE_Switch, 60);
|
|
||||||
lv_obj_set_x(ui_Toggle_BLE_Switch, -181);
|
|
||||||
lv_obj_set_y(ui_Toggle_BLE_Switch, -3);
|
|
||||||
lv_obj_set_align(ui_Toggle_BLE_Switch, LV_ALIGN_CENTER);
|
|
||||||
lv_obj_add_state(ui_Toggle_BLE_Switch, LV_STATE_DISABLED); /// States
|
|
||||||
|
|
||||||
ui_Enable_BLE_LBL = lv_label_create(ui_BLE_CTRL_Panel);
|
|
||||||
lv_obj_set_width(ui_Enable_BLE_LBL, LV_SIZE_CONTENT); /// 1
|
|
||||||
lv_obj_set_height(ui_Enable_BLE_LBL, LV_SIZE_CONTENT); /// 1
|
|
||||||
lv_obj_set_x(ui_Enable_BLE_LBL, -117);
|
|
||||||
lv_obj_set_y(ui_Enable_BLE_LBL, -2);
|
|
||||||
lv_obj_set_align(ui_Enable_BLE_LBL, LV_ALIGN_CENTER);
|
|
||||||
lv_label_set_text(ui_Enable_BLE_LBL, "Enable BLE");
|
|
||||||
lv_obj_set_style_text_font(ui_Enable_BLE_LBL, &lv_font_montserrat_30, LV_PART_MAIN | LV_STATE_DEFAULT);
|
|
||||||
|
|
||||||
ui_Debug_CTRL_Panel = lv_obj_create(ui_Settings_CTRL_Container);
|
|
||||||
lv_obj_set_width(ui_Debug_CTRL_Panel, 400);
|
|
||||||
lv_obj_set_height(ui_Debug_CTRL_Panel, 100);
|
|
||||||
lv_obj_set_x(ui_Debug_CTRL_Panel, 0);
|
|
||||||
lv_obj_set_y(ui_Debug_CTRL_Panel, 1);
|
|
||||||
lv_obj_set_align(ui_Debug_CTRL_Panel, LV_ALIGN_CENTER);
|
|
||||||
lv_obj_set_flex_flow(ui_Debug_CTRL_Panel, LV_FLEX_FLOW_ROW);
|
|
||||||
lv_obj_set_flex_align(ui_Debug_CTRL_Panel, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
|
|
||||||
lv_obj_clear_flag(ui_Debug_CTRL_Panel, LV_OBJ_FLAG_SCROLLABLE); /// Flags
|
|
||||||
ui_object_set_themeable_style_property(ui_Debug_CTRL_Panel, LV_PART_MAIN | LV_STATE_DEFAULT, LV_STYLE_BG_COLOR,
|
|
||||||
_ui_theme_color_panel_backgroung);
|
|
||||||
ui_object_set_themeable_style_property(ui_Debug_CTRL_Panel, LV_PART_MAIN | LV_STATE_DEFAULT, LV_STYLE_BG_OPA,
|
|
||||||
_ui_theme_alpha_panel_backgroung);
|
|
||||||
|
|
||||||
ui_Toggle_Debug_Switch = lv_switch_create(ui_Debug_CTRL_Panel);
|
|
||||||
lv_obj_set_width(ui_Toggle_Debug_Switch, 110);
|
|
||||||
lv_obj_set_height(ui_Toggle_Debug_Switch, 60);
|
|
||||||
lv_obj_set_x(ui_Toggle_Debug_Switch, -181);
|
|
||||||
lv_obj_set_y(ui_Toggle_Debug_Switch, -3);
|
|
||||||
lv_obj_set_align(ui_Toggle_Debug_Switch, LV_ALIGN_CENTER);
|
|
||||||
|
|
||||||
ui_Enable_Debug_LBL = lv_label_create(ui_Debug_CTRL_Panel);
|
|
||||||
lv_obj_set_width(ui_Enable_Debug_LBL, LV_SIZE_CONTENT); /// 1
|
|
||||||
lv_obj_set_height(ui_Enable_Debug_LBL, LV_SIZE_CONTENT); /// 1
|
|
||||||
lv_obj_set_x(ui_Enable_Debug_LBL, -117);
|
|
||||||
lv_obj_set_y(ui_Enable_Debug_LBL, -2);
|
|
||||||
lv_obj_set_align(ui_Enable_Debug_LBL, LV_ALIGN_CENTER);
|
|
||||||
lv_label_set_text(ui_Enable_Debug_LBL, "Enable Debug");
|
|
||||||
lv_obj_set_style_text_font(ui_Enable_Debug_LBL, &lv_font_montserrat_30, LV_PART_MAIN | LV_STATE_DEFAULT);
|
|
||||||
|
|
||||||
ui_Wifi_Container = lv_obj_create(ui_Main_Container);
|
|
||||||
lv_obj_remove_style_all(ui_Wifi_Container);
|
|
||||||
lv_obj_set_width(ui_Wifi_Container, 610);
|
|
||||||
lv_obj_set_height(ui_Wifi_Container, 530);
|
|
||||||
lv_obj_set_x(ui_Wifi_Container, -100);
|
|
||||||
lv_obj_set_y(ui_Wifi_Container, 8);
|
|
||||||
lv_obj_set_align(ui_Wifi_Container, LV_ALIGN_CENTER);
|
|
||||||
lv_obj_set_flex_flow(ui_Wifi_Container, LV_FLEX_FLOW_COLUMN);
|
|
||||||
lv_obj_set_flex_align(ui_Wifi_Container, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START);
|
|
||||||
lv_obj_clear_flag(ui_Wifi_Container, LV_OBJ_FLAG_CLICKABLE | LV_OBJ_FLAG_SCROLLABLE); /// Flags
|
|
||||||
|
|
||||||
ui_Select_SSID_BTN = lv_btn_create(ui_Wifi_Container);
|
|
||||||
lv_obj_set_width(ui_Select_SSID_BTN, 668);
|
|
||||||
lv_obj_set_height(ui_Select_SSID_BTN, 50);
|
|
||||||
lv_obj_set_x(ui_Select_SSID_BTN, 7);
|
|
||||||
lv_obj_set_y(ui_Select_SSID_BTN, -4);
|
|
||||||
lv_obj_set_align(ui_Select_SSID_BTN, LV_ALIGN_CENTER);
|
|
||||||
lv_obj_add_flag(ui_Select_SSID_BTN, LV_OBJ_FLAG_HIDDEN); /// Flags
|
|
||||||
lv_obj_set_style_bg_color(ui_Select_SSID_BTN, lv_color_hex(0x7F7A9C), LV_PART_MAIN | LV_STATE_DEFAULT);
|
|
||||||
lv_obj_set_style_bg_opa(ui_Select_SSID_BTN, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
|
|
||||||
|
|
||||||
ui_Wifi_Passkey_TB = lv_textarea_create(ui_Wifi_Container);
|
|
||||||
lv_obj_set_width(ui_Wifi_Passkey_TB, 200);
|
|
||||||
lv_obj_set_height(ui_Wifi_Passkey_TB, LV_SIZE_CONTENT); /// 70
|
|
||||||
lv_obj_set_x(ui_Wifi_Passkey_TB, 129);
|
|
||||||
lv_obj_set_y(ui_Wifi_Passkey_TB, -173);
|
|
||||||
lv_obj_set_align(ui_Wifi_Passkey_TB, LV_ALIGN_CENTER);
|
|
||||||
lv_textarea_set_placeholder_text(ui_Wifi_Passkey_TB, "Placeholder...");
|
|
||||||
lv_textarea_set_one_line(ui_Wifi_Passkey_TB, true);
|
|
||||||
lv_obj_add_flag(ui_Wifi_Passkey_TB, LV_OBJ_FLAG_HIDDEN); /// Flags
|
|
||||||
|
|
||||||
ui_Keyboard = lv_keyboard_create(ui_Settings_Screen);
|
|
||||||
lv_obj_set_width(ui_Keyboard, 1012);
|
|
||||||
lv_obj_set_height(ui_Keyboard, 268);
|
|
||||||
lv_obj_set_x(ui_Keyboard, 3);
|
|
||||||
lv_obj_set_y(ui_Keyboard, 161);
|
|
||||||
lv_obj_set_align(ui_Keyboard, LV_ALIGN_CENTER);
|
|
||||||
lv_obj_add_flag(ui_Keyboard, LV_OBJ_FLAG_HIDDEN); /// Flags
|
|
||||||
|
|
||||||
ui_Device_State_Container = lv_obj_create(ui_Settings_Screen);
|
|
||||||
lv_obj_remove_style_all(ui_Device_State_Container);
|
|
||||||
lv_obj_set_width(ui_Device_State_Container, 75);
|
|
||||||
lv_obj_set_height(ui_Device_State_Container, 30);
|
|
||||||
lv_obj_set_x(ui_Device_State_Container, 470);
|
|
||||||
lv_obj_set_y(ui_Device_State_Container, -282);
|
|
||||||
lv_obj_set_align(ui_Device_State_Container, LV_ALIGN_CENTER);
|
|
||||||
lv_obj_set_flex_flow(ui_Device_State_Container, LV_FLEX_FLOW_ROW);
|
|
||||||
lv_obj_set_flex_align(ui_Device_State_Container, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START);
|
|
||||||
lv_obj_add_flag(ui_Device_State_Container, LV_OBJ_FLAG_HIDDEN); /// Flags
|
|
||||||
lv_obj_clear_flag(ui_Device_State_Container, LV_OBJ_FLAG_CLICKABLE | LV_OBJ_FLAG_SCROLLABLE); /// Flags
|
|
||||||
|
|
||||||
ui_Static_LBLS_Container = lv_obj_create(ui_Device_State_Container);
|
|
||||||
lv_obj_remove_style_all(ui_Static_LBLS_Container);
|
|
||||||
lv_obj_set_width(ui_Static_LBLS_Container, 35);
|
|
||||||
lv_obj_set_height(ui_Static_LBLS_Container, 30);
|
|
||||||
lv_obj_set_align(ui_Static_LBLS_Container, LV_ALIGN_CENTER);
|
|
||||||
lv_obj_set_flex_flow(ui_Static_LBLS_Container, LV_FLEX_FLOW_COLUMN);
|
|
||||||
lv_obj_set_flex_align(ui_Static_LBLS_Container, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_END, LV_FLEX_ALIGN_START);
|
|
||||||
lv_obj_clear_flag(ui_Static_LBLS_Container, LV_OBJ_FLAG_CLICKABLE | LV_OBJ_FLAG_SCROLLABLE); /// Flags
|
|
||||||
|
|
||||||
ui_FPS_Static_LBL = lv_label_create(ui_Static_LBLS_Container);
|
|
||||||
lv_obj_set_width(ui_FPS_Static_LBL, LV_SIZE_CONTENT); /// 1
|
|
||||||
lv_obj_set_height(ui_FPS_Static_LBL, LV_SIZE_CONTENT); /// 1
|
|
||||||
lv_obj_set_x(ui_FPS_Static_LBL, -176);
|
|
||||||
lv_obj_set_y(ui_FPS_Static_LBL, 34);
|
|
||||||
lv_obj_set_align(ui_FPS_Static_LBL, LV_ALIGN_CENTER);
|
|
||||||
lv_label_set_text(ui_FPS_Static_LBL, "FPS:");
|
|
||||||
|
|
||||||
ui_CPU_Static_LBL = lv_label_create(ui_Static_LBLS_Container);
|
|
||||||
lv_obj_set_width(ui_CPU_Static_LBL, LV_SIZE_CONTENT); /// 1
|
|
||||||
lv_obj_set_height(ui_CPU_Static_LBL, LV_SIZE_CONTENT); /// 1
|
|
||||||
lv_obj_set_x(ui_CPU_Static_LBL, -1);
|
|
||||||
lv_obj_set_y(ui_CPU_Static_LBL, -1);
|
|
||||||
lv_obj_set_align(ui_CPU_Static_LBL, LV_ALIGN_CENTER);
|
|
||||||
lv_label_set_text(ui_CPU_Static_LBL, "CPU:");
|
|
||||||
|
|
||||||
ui_Device_State_Values_LBL = lv_obj_create(ui_Device_State_Container);
|
|
||||||
lv_obj_remove_style_all(ui_Device_State_Values_LBL);
|
|
||||||
lv_obj_set_width(ui_Device_State_Values_LBL, 35);
|
|
||||||
lv_obj_set_height(ui_Device_State_Values_LBL, 30);
|
|
||||||
lv_obj_set_align(ui_Device_State_Values_LBL, LV_ALIGN_CENTER);
|
|
||||||
lv_obj_set_flex_flow(ui_Device_State_Values_LBL, LV_FLEX_FLOW_COLUMN);
|
|
||||||
lv_obj_set_flex_align(ui_Device_State_Values_LBL, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START);
|
|
||||||
lv_obj_clear_flag(ui_Device_State_Values_LBL, LV_OBJ_FLAG_CLICKABLE | LV_OBJ_FLAG_SCROLLABLE); /// Flags
|
|
||||||
|
|
||||||
ui_FPS_Values_LBL = lv_label_create(ui_Device_State_Values_LBL);
|
|
||||||
lv_obj_set_width(ui_FPS_Values_LBL, LV_SIZE_CONTENT); /// 1
|
|
||||||
lv_obj_set_height(ui_FPS_Values_LBL, LV_SIZE_CONTENT); /// 1
|
|
||||||
lv_obj_set_x(ui_FPS_Values_LBL, -176);
|
|
||||||
lv_obj_set_y(ui_FPS_Values_LBL, 34);
|
|
||||||
lv_obj_set_align(ui_FPS_Values_LBL, LV_ALIGN_CENTER);
|
|
||||||
lv_label_set_text(ui_FPS_Values_LBL, "0");
|
|
||||||
|
|
||||||
ui_CPU_Values_LBL = lv_label_create(ui_Device_State_Values_LBL);
|
|
||||||
lv_obj_set_width(ui_CPU_Values_LBL, LV_SIZE_CONTENT); /// 1
|
|
||||||
lv_obj_set_height(ui_CPU_Values_LBL, LV_SIZE_CONTENT); /// 1
|
|
||||||
lv_obj_set_x(ui_CPU_Values_LBL, -1);
|
|
||||||
lv_obj_set_y(ui_CPU_Values_LBL, -1);
|
|
||||||
lv_obj_set_align(ui_CPU_Values_LBL, LV_ALIGN_CENTER);
|
|
||||||
lv_label_set_text(ui_CPU_Values_LBL, "0%");
|
|
||||||
|
|
||||||
ui_Settings_Loading_Container = lv_obj_create(ui_Settings_Screen);
|
|
||||||
lv_obj_remove_style_all(ui_Settings_Loading_Container);
|
|
||||||
lv_obj_set_width(ui_Settings_Loading_Container, 1024);
|
|
||||||
lv_obj_set_height(ui_Settings_Loading_Container, 600);
|
|
||||||
lv_obj_set_align(ui_Settings_Loading_Container, LV_ALIGN_CENTER);
|
|
||||||
lv_obj_set_flex_flow(ui_Settings_Loading_Container, LV_FLEX_FLOW_ROW);
|
|
||||||
lv_obj_set_flex_align(ui_Settings_Loading_Container, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
|
|
||||||
lv_obj_clear_flag(ui_Settings_Loading_Container, LV_OBJ_FLAG_CLICKABLE | LV_OBJ_FLAG_SCROLLABLE); /// Flags
|
|
||||||
|
|
||||||
ui_Settings_Loading_Spinner = lv_spinner_create(ui_Settings_Loading_Container, 1000, 90);
|
|
||||||
lv_obj_set_width(ui_Settings_Loading_Spinner, 80);
|
|
||||||
lv_obj_set_height(ui_Settings_Loading_Spinner, 80);
|
|
||||||
lv_obj_set_x(ui_Settings_Loading_Spinner, -22);
|
|
||||||
lv_obj_set_y(ui_Settings_Loading_Spinner, -22);
|
|
||||||
lv_obj_set_align(ui_Settings_Loading_Spinner, LV_ALIGN_CENTER);
|
|
||||||
lv_obj_add_flag(ui_Settings_Loading_Spinner, LV_OBJ_FLAG_HIDDEN); /// Flags
|
|
||||||
lv_obj_clear_flag(ui_Settings_Loading_Spinner, LV_OBJ_FLAG_CLICKABLE); /// Flags
|
|
||||||
|
|
||||||
lv_obj_add_event_cb(ui_Toggle_UART_Switch, ui_event_Toggle_UART_Switch, LV_EVENT_ALL, NULL);
|
|
||||||
lv_obj_add_event_cb(ui_Toggle_Wifi_Switch, ui_event_Toggle_Wifi_Switch, LV_EVENT_ALL, NULL);
|
|
||||||
lv_obj_add_event_cb(ui_Toggle_CAN_Bus_Switch, ui_event_Toggle_CAN_Bus_Switch, LV_EVENT_ALL, NULL);
|
|
||||||
lv_obj_add_event_cb(ui_Toggle_Debug_Switch, ui_event_Toggle_Debug_Switch, LV_EVENT_ALL, NULL);
|
|
||||||
lv_obj_add_event_cb(ui_Select_SSID_BTN, ui_event_Select_SSID_BTN, LV_EVENT_ALL, NULL);
|
|
||||||
lv_obj_add_event_cb(ui_Settings_Screen, ui_event_Settings_Screen, LV_EVENT_ALL, NULL);
|
|
||||||
uic_Settings_Screen = ui_Settings_Screen;
|
|
||||||
uic_Settings_Screen_LBL = ui_Settings_Screen_LBL;
|
|
||||||
uic_Main_Container = ui_Main_Container;
|
|
||||||
uic_Settings_CTRL_Container = ui_Settings_CTRL_Container;
|
|
||||||
uic_CAN_Bus_CTRL_Panel = ui_CAN_Bus_CTRL_Panel;
|
|
||||||
uic_Toggle_CAN_Bus_Switch = ui_Toggle_CAN_Bus_Switch;
|
|
||||||
uic_Enable_CAN_Bus_LBL = ui_Enable_CAN_Bus_LBL;
|
|
||||||
uic_UART_CTRL_Panel = ui_UART_CTRL_Panel;
|
|
||||||
uic_Toggle_UART_Switch = ui_Toggle_UART_Switch;
|
|
||||||
uic_Enable_UART_LBL = ui_Enable_UART_LBL;
|
|
||||||
uic_Wifi_CTRL_Panel = ui_Wifi_CTRL_Panel;
|
|
||||||
uic_Toggle_Wifi_Switch = ui_Toggle_Wifi_Switch;
|
|
||||||
uic_Enable_Wifi_LBL = ui_Enable_Wifi_LBL;
|
|
||||||
uic_BLE_CTRL_Panel = ui_BLE_CTRL_Panel;
|
|
||||||
uic_Toggle_BLE_Switch = ui_Toggle_BLE_Switch;
|
|
||||||
uic_Enable_BLE_LBL = ui_Enable_BLE_LBL;
|
|
||||||
uic_Debug_CTRL_Panel = ui_Debug_CTRL_Panel;
|
|
||||||
uic_Toggle_Debug_Switch = ui_Toggle_Debug_Switch;
|
|
||||||
uic_Enable_Debug_LBL = ui_Enable_Debug_LBL;
|
|
||||||
uic_Wifi_Container = ui_Wifi_Container;
|
|
||||||
uic_Select_SSID_BTN = ui_Select_SSID_BTN;
|
|
||||||
uic_Wifi_Passkey_TB = ui_Wifi_Passkey_TB;
|
|
||||||
uic_Keyboard = ui_Keyboard;
|
|
||||||
uic_Device_State_Container = ui_Device_State_Container;
|
|
||||||
uic_Static_LBLS_Container = ui_Static_LBLS_Container;
|
|
||||||
uic_FPS_Static_LBL = ui_FPS_Static_LBL;
|
|
||||||
uic_CPU_Static_LBL = ui_CPU_Static_LBL;
|
|
||||||
uic_Device_State_Values_LBL = ui_Device_State_Values_LBL;
|
|
||||||
uic_FPS_Values_LBL = ui_FPS_Values_LBL;
|
|
||||||
uic_CPU_Values_LBL = ui_CPU_Values_LBL;
|
|
||||||
uic_Settings_Loading_Container = ui_Settings_Loading_Container;
|
|
||||||
uic_Settings_Loading_Spinner = ui_Settings_Loading_Spinner;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void ui_Settings_Screen_screen_destroy(void)
|
|
||||||
{
|
|
||||||
if(ui_Settings_Screen) lv_obj_del(ui_Settings_Screen);
|
|
||||||
|
|
||||||
// NULL screen variables
|
|
||||||
uic_Settings_Screen = NULL;
|
|
||||||
ui_Settings_Screen = NULL;
|
|
||||||
uic_Settings_Screen_LBL = NULL;
|
|
||||||
ui_Settings_Screen_LBL = NULL;
|
|
||||||
uic_Main_Container = NULL;
|
|
||||||
ui_Main_Container = NULL;
|
|
||||||
uic_Settings_CTRL_Container = NULL;
|
|
||||||
ui_Settings_CTRL_Container = NULL;
|
|
||||||
uic_CAN_Bus_CTRL_Panel = NULL;
|
|
||||||
ui_CAN_Bus_CTRL_Panel = NULL;
|
|
||||||
uic_Toggle_CAN_Bus_Switch = NULL;
|
|
||||||
ui_Toggle_CAN_Bus_Switch = NULL;
|
|
||||||
uic_Enable_CAN_Bus_LBL = NULL;
|
|
||||||
ui_Enable_CAN_Bus_LBL = NULL;
|
|
||||||
uic_UART_CTRL_Panel = NULL;
|
|
||||||
ui_UART_CTRL_Panel = NULL;
|
|
||||||
uic_Toggle_UART_Switch = NULL;
|
|
||||||
ui_Toggle_UART_Switch = NULL;
|
|
||||||
uic_Enable_UART_LBL = NULL;
|
|
||||||
ui_Enable_UART_LBL = NULL;
|
|
||||||
uic_Wifi_CTRL_Panel = NULL;
|
|
||||||
ui_Wifi_CTRL_Panel = NULL;
|
|
||||||
uic_Toggle_Wifi_Switch = NULL;
|
|
||||||
ui_Toggle_Wifi_Switch = NULL;
|
|
||||||
uic_Enable_Wifi_LBL = NULL;
|
|
||||||
ui_Enable_Wifi_LBL = NULL;
|
|
||||||
uic_BLE_CTRL_Panel = NULL;
|
|
||||||
ui_BLE_CTRL_Panel = NULL;
|
|
||||||
uic_Toggle_BLE_Switch = NULL;
|
|
||||||
ui_Toggle_BLE_Switch = NULL;
|
|
||||||
uic_Enable_BLE_LBL = NULL;
|
|
||||||
ui_Enable_BLE_LBL = NULL;
|
|
||||||
uic_Debug_CTRL_Panel = NULL;
|
|
||||||
ui_Debug_CTRL_Panel = NULL;
|
|
||||||
uic_Toggle_Debug_Switch = NULL;
|
|
||||||
ui_Toggle_Debug_Switch = NULL;
|
|
||||||
uic_Enable_Debug_LBL = NULL;
|
|
||||||
ui_Enable_Debug_LBL = NULL;
|
|
||||||
uic_Wifi_Container = NULL;
|
|
||||||
ui_Wifi_Container = NULL;
|
|
||||||
uic_Select_SSID_BTN = NULL;
|
|
||||||
ui_Select_SSID_BTN = NULL;
|
|
||||||
uic_Wifi_Passkey_TB = NULL;
|
|
||||||
ui_Wifi_Passkey_TB = NULL;
|
|
||||||
uic_Keyboard = NULL;
|
|
||||||
ui_Keyboard = NULL;
|
|
||||||
uic_Device_State_Container = NULL;
|
|
||||||
ui_Device_State_Container = NULL;
|
|
||||||
uic_Static_LBLS_Container = NULL;
|
|
||||||
ui_Static_LBLS_Container = NULL;
|
|
||||||
uic_FPS_Static_LBL = NULL;
|
|
||||||
ui_FPS_Static_LBL = NULL;
|
|
||||||
uic_CPU_Static_LBL = NULL;
|
|
||||||
ui_CPU_Static_LBL = NULL;
|
|
||||||
uic_Device_State_Values_LBL = NULL;
|
|
||||||
ui_Device_State_Values_LBL = NULL;
|
|
||||||
uic_FPS_Values_LBL = NULL;
|
|
||||||
ui_FPS_Values_LBL = NULL;
|
|
||||||
uic_CPU_Values_LBL = NULL;
|
|
||||||
ui_CPU_Values_LBL = NULL;
|
|
||||||
uic_Settings_Loading_Container = NULL;
|
|
||||||
ui_Settings_Loading_Container = NULL;
|
|
||||||
uic_Settings_Loading_Spinner = NULL;
|
|
||||||
ui_Settings_Loading_Spinner = NULL;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
// This file was generated by SquareLine Studio
|
|
||||||
// SquareLine Studio version: SquareLine Studio 1.5.4
|
|
||||||
// LVGL version: 8.3.6
|
|
||||||
// Project name: ESP32-S3-Touch-LCD-5B
|
|
||||||
|
|
||||||
#ifndef UI_SETTINGS_SCREEN_H
|
|
||||||
#define UI_SETTINGS_SCREEN_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// SCREEN: ui_Settings_Screen
|
|
||||||
extern void ui_Settings_Screen_screen_init(void);
|
|
||||||
extern void ui_Settings_Screen_screen_destroy(void);
|
|
||||||
extern void ui_event_Settings_Screen(lv_event_t * e);
|
|
||||||
extern lv_obj_t * ui_Settings_Screen;
|
|
||||||
extern lv_obj_t * ui_Settings_Screen_LBL;
|
|
||||||
extern lv_obj_t * ui_Main_Container;
|
|
||||||
extern lv_obj_t * ui_Settings_CTRL_Container;
|
|
||||||
extern lv_obj_t * ui_CAN_Bus_CTRL_Panel;
|
|
||||||
extern lv_obj_t * ui_Toggle_CAN_Bus_Switch;
|
|
||||||
extern lv_obj_t * ui_Enable_CAN_Bus_LBL;
|
|
||||||
extern lv_obj_t * ui_UART_CTRL_Panel;
|
|
||||||
extern void ui_event_Toggle_UART_Switch(lv_event_t * e);
|
|
||||||
extern lv_obj_t * ui_Toggle_UART_Switch;
|
|
||||||
extern lv_obj_t * ui_Enable_UART_LBL;
|
|
||||||
extern lv_obj_t * ui_Wifi_CTRL_Panel;
|
|
||||||
extern void ui_event_Toggle_Wifi_Switch(lv_event_t * e);
|
|
||||||
extern lv_obj_t * ui_Toggle_Wifi_Switch;
|
|
||||||
extern lv_obj_t * ui_Enable_Wifi_LBL;
|
|
||||||
extern lv_obj_t * ui_BLE_CTRL_Panel;
|
|
||||||
extern lv_obj_t * ui_Toggle_BLE_Switch;
|
|
||||||
extern lv_obj_t * ui_Enable_BLE_LBL;
|
|
||||||
extern lv_obj_t * ui_Debug_CTRL_Panel;
|
|
||||||
extern void ui_event_Toggle_Debug_Switch(lv_event_t * e);
|
|
||||||
extern lv_obj_t * ui_Toggle_Debug_Switch;
|
|
||||||
extern lv_obj_t * ui_Enable_Debug_LBL;
|
|
||||||
extern lv_obj_t * ui_Wifi_Container;
|
|
||||||
extern void ui_event_Select_SSID_BTN(lv_event_t * e);
|
|
||||||
extern lv_obj_t * ui_Select_SSID_BTN;
|
|
||||||
extern lv_obj_t * ui_Wifi_Passkey_TB;
|
|
||||||
extern lv_obj_t * ui_Keyboard;
|
|
||||||
extern lv_obj_t * ui_Device_State_Container;
|
|
||||||
extern lv_obj_t * ui_Static_LBLS_Container;
|
|
||||||
extern lv_obj_t * ui_FPS_Static_LBL;
|
|
||||||
extern lv_obj_t * ui_CPU_Static_LBL;
|
|
||||||
extern lv_obj_t * ui_Device_State_Values_LBL;
|
|
||||||
extern lv_obj_t * ui_FPS_Values_LBL;
|
|
||||||
extern lv_obj_t * ui_CPU_Values_LBL;
|
|
||||||
extern lv_obj_t * ui_Settings_Loading_Container;
|
|
||||||
extern lv_obj_t * ui_Settings_Loading_Spinner;
|
|
||||||
// CUSTOM VARIABLES
|
|
||||||
extern lv_obj_t * uic_Settings_Screen;
|
|
||||||
extern lv_obj_t * uic_Settings_Screen_LBL;
|
|
||||||
extern lv_obj_t * uic_Main_Container;
|
|
||||||
extern lv_obj_t * uic_Settings_CTRL_Container;
|
|
||||||
extern lv_obj_t * uic_CAN_Bus_CTRL_Panel;
|
|
||||||
extern lv_obj_t * uic_Toggle_CAN_Bus_Switch;
|
|
||||||
extern lv_obj_t * uic_Enable_CAN_Bus_LBL;
|
|
||||||
extern lv_obj_t * uic_UART_CTRL_Panel;
|
|
||||||
extern lv_obj_t * uic_Toggle_UART_Switch;
|
|
||||||
extern lv_obj_t * uic_Enable_UART_LBL;
|
|
||||||
extern lv_obj_t * uic_Wifi_CTRL_Panel;
|
|
||||||
extern lv_obj_t * uic_Toggle_Wifi_Switch;
|
|
||||||
extern lv_obj_t * uic_Enable_Wifi_LBL;
|
|
||||||
extern lv_obj_t * uic_BLE_CTRL_Panel;
|
|
||||||
extern lv_obj_t * uic_Toggle_BLE_Switch;
|
|
||||||
extern lv_obj_t * uic_Enable_BLE_LBL;
|
|
||||||
extern lv_obj_t * uic_Debug_CTRL_Panel;
|
|
||||||
extern lv_obj_t * uic_Toggle_Debug_Switch;
|
|
||||||
extern lv_obj_t * uic_Enable_Debug_LBL;
|
|
||||||
extern lv_obj_t * uic_Wifi_Container;
|
|
||||||
extern lv_obj_t * uic_Select_SSID_BTN;
|
|
||||||
extern lv_obj_t * uic_Wifi_Passkey_TB;
|
|
||||||
extern lv_obj_t * uic_Keyboard;
|
|
||||||
extern lv_obj_t * uic_Device_State_Container;
|
|
||||||
extern lv_obj_t * uic_Static_LBLS_Container;
|
|
||||||
extern lv_obj_t * uic_FPS_Static_LBL;
|
|
||||||
extern lv_obj_t * uic_CPU_Static_LBL;
|
|
||||||
extern lv_obj_t * uic_Device_State_Values_LBL;
|
|
||||||
extern lv_obj_t * uic_FPS_Values_LBL;
|
|
||||||
extern lv_obj_t * uic_CPU_Values_LBL;
|
|
||||||
extern lv_obj_t * uic_Settings_Loading_Container;
|
|
||||||
extern lv_obj_t * uic_Settings_Loading_Spinner;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
} /*extern "C"*/
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
// This file was generated by SquareLine Studio
|
|
||||||
// SquareLine Studio version: SquareLine Studio 1.5.4
|
|
||||||
// LVGL version: 8.3.6
|
|
||||||
// Project name: ESP32-S3-Touch-LCD-5B
|
|
||||||
|
|
||||||
#include "ui.h"
|
|
||||||
#include "ui_helpers.h"
|
|
||||||
|
|
||||||
///////////////////// VARIABLES ////////////////////
|
|
||||||
|
|
||||||
// EVENTS
|
|
||||||
lv_obj_t * ui____initial_actions0;
|
|
||||||
|
|
||||||
// IMAGES AND IMAGE SETS
|
|
||||||
|
|
||||||
///////////////////// TEST LVGL SETTINGS ////////////////////
|
|
||||||
#if LV_COLOR_DEPTH != 16
|
|
||||||
#error "LV_COLOR_DEPTH should be 16bit to match SquareLine Studio's settings"
|
|
||||||
#endif
|
|
||||||
#if LV_COLOR_16_SWAP !=0
|
|
||||||
#error "LV_COLOR_16_SWAP should be 0 to match SquareLine Studio's settings"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
///////////////////// ANIMATIONS ////////////////////
|
|
||||||
|
|
||||||
///////////////////// FUNCTIONS ////////////////////
|
|
||||||
|
|
||||||
///////////////////// SCREENS ////////////////////
|
|
||||||
|
|
||||||
void ui_init(void)
|
|
||||||
{
|
|
||||||
lv_disp_t * dispp = lv_disp_get_default();
|
|
||||||
lv_theme_t * theme = lv_theme_default_init(dispp, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_RED),
|
|
||||||
true, LV_FONT_DEFAULT);
|
|
||||||
lv_disp_set_theme(dispp, theme);
|
|
||||||
// Home screen removed (2026-09-21): the firmware boots into the hand-coded
|
|
||||||
// Driveline screen (DrivelineScreen::show() in display_init.cpp). Settings is
|
|
||||||
// created lazily by _ui_screen_change() when swiped to.
|
|
||||||
ui____initial_actions0 = lv_obj_create(NULL);
|
|
||||||
lv_disp_load_scr(ui____initial_actions0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ui_destroy(void)
|
|
||||||
{
|
|
||||||
ui_Settings_Screen_screen_destroy();
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
// This file was generated by SquareLine Studio
|
|
||||||
// SquareLine Studio version: SquareLine Studio 1.5.4
|
|
||||||
// LVGL version: 8.3.6
|
|
||||||
// Project name: ESP32-S3-Touch-LCD-5B
|
|
||||||
|
|
||||||
#ifndef _ESP32_S3_TOUCH_LCD_5B_UI_H
|
|
||||||
#define _ESP32_S3_TOUCH_LCD_5B_UI_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined __has_include
|
|
||||||
#if __has_include("lvgl.h")
|
|
||||||
#include "lvgl.h"
|
|
||||||
#elif __has_include("lvgl/lvgl.h")
|
|
||||||
#include "lvgl/lvgl.h"
|
|
||||||
#else
|
|
||||||
#include "lvgl.h"
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#include "lvgl.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "ui_helpers.h"
|
|
||||||
#include "ui_events.h"
|
|
||||||
#include "ui_theme_manager.h"
|
|
||||||
#include "ui_themes.h"
|
|
||||||
|
|
||||||
///////////////////// SCREENS ////////////////////
|
|
||||||
#include "screens/ui_Settings_Screen.h"
|
|
||||||
|
|
||||||
///////////////////// VARIABLES ////////////////////
|
|
||||||
|
|
||||||
// EVENTS
|
|
||||||
extern lv_obj_t * ui____initial_actions0;
|
|
||||||
|
|
||||||
// IMAGES AND IMAGE SETS
|
|
||||||
|
|
||||||
// UI INIT
|
|
||||||
void ui_init(void);
|
|
||||||
void ui_destroy(void);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
} /*extern "C"*/
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
// This file was generated by SquareLine Studio
|
|
||||||
// SquareLine Studio version: SquareLine Studio 1.5.4
|
|
||||||
// LVGL version: 8.3.6
|
|
||||||
// Project name: ESP32-S3-Touch-LCD-5B
|
|
||||||
|
|
||||||
#ifndef _UI_EVENTS_H
|
|
||||||
#define _UI_EVENTS_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void onUARTToggle(lv_event_t * e);
|
|
||||||
void onWifiToggle(lv_event_t * e);
|
|
||||||
void onCANBusToggle(lv_event_t * e);
|
|
||||||
void onDebugToggle(lv_event_t * e);
|
|
||||||
void onSelectSSID(lv_event_t * e);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
} /*extern "C"*/
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,262 +0,0 @@
|
|||||||
// This file was generated by SquareLine Studio
|
|
||||||
// SquareLine Studio version: SquareLine Studio 1.5.4
|
|
||||||
// LVGL version: 8.3.6
|
|
||||||
// Project name: ESP32-S3-Touch-LCD-5B
|
|
||||||
|
|
||||||
#include "ui_helpers.h"
|
|
||||||
|
|
||||||
void _ui_bar_set_property(lv_obj_t * target, int id, int val)
|
|
||||||
{
|
|
||||||
if(id == _UI_BAR_PROPERTY_VALUE_WITH_ANIM) lv_bar_set_value(target, val, LV_ANIM_ON);
|
|
||||||
if(id == _UI_BAR_PROPERTY_VALUE) lv_bar_set_value(target, val, LV_ANIM_OFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _ui_basic_set_property(lv_obj_t * target, int id, int val)
|
|
||||||
{
|
|
||||||
if(id == _UI_BASIC_PROPERTY_POSITION_X) lv_obj_set_x(target, val);
|
|
||||||
if(id == _UI_BASIC_PROPERTY_POSITION_Y) lv_obj_set_y(target, val);
|
|
||||||
if(id == _UI_BASIC_PROPERTY_WIDTH) lv_obj_set_width(target, val);
|
|
||||||
if(id == _UI_BASIC_PROPERTY_HEIGHT) lv_obj_set_height(target, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _ui_dropdown_set_property(lv_obj_t * target, int id, int val)
|
|
||||||
{
|
|
||||||
if(id == _UI_DROPDOWN_PROPERTY_SELECTED) lv_dropdown_set_selected(target, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _ui_image_set_property(lv_obj_t * target, int id, uint8_t * val)
|
|
||||||
{
|
|
||||||
if(id == _UI_IMAGE_PROPERTY_IMAGE) lv_img_set_src(target, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _ui_label_set_property(lv_obj_t * target, int id, const char * val)
|
|
||||||
{
|
|
||||||
if(id == _UI_LABEL_PROPERTY_TEXT) lv_label_set_text(target, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _ui_roller_set_property(lv_obj_t * target, int id, int val)
|
|
||||||
{
|
|
||||||
if(id == _UI_ROLLER_PROPERTY_SELECTED_WITH_ANIM) lv_roller_set_selected(target, val, LV_ANIM_ON);
|
|
||||||
if(id == _UI_ROLLER_PROPERTY_SELECTED) lv_roller_set_selected(target, val, LV_ANIM_OFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _ui_slider_set_property(lv_obj_t * target, int id, int val)
|
|
||||||
{
|
|
||||||
if(id == _UI_SLIDER_PROPERTY_VALUE_WITH_ANIM) lv_slider_set_value(target, val, LV_ANIM_ON);
|
|
||||||
if(id == _UI_SLIDER_PROPERTY_VALUE) lv_slider_set_value(target, val, LV_ANIM_OFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _ui_screen_change(lv_obj_t ** target, lv_scr_load_anim_t fademode, int spd, int delay, void (*target_init)(void))
|
|
||||||
{
|
|
||||||
if(*target == NULL)
|
|
||||||
target_init();
|
|
||||||
lv_scr_load_anim(*target, fademode, spd, delay, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _ui_arc_increment(lv_obj_t * target, int val)
|
|
||||||
{
|
|
||||||
int old = lv_arc_get_value(target);
|
|
||||||
lv_arc_set_value(target, old + val);
|
|
||||||
lv_event_send(target, LV_EVENT_VALUE_CHANGED, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _ui_bar_increment(lv_obj_t * target, int val, int anm)
|
|
||||||
{
|
|
||||||
int old = lv_bar_get_value(target);
|
|
||||||
lv_bar_set_value(target, old + val, anm);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _ui_slider_increment(lv_obj_t * target, int val, int anm)
|
|
||||||
{
|
|
||||||
int old = lv_slider_get_value(target);
|
|
||||||
lv_slider_set_value(target, old + val, anm);
|
|
||||||
lv_event_send(target, LV_EVENT_VALUE_CHANGED, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _ui_keyboard_set_target(lv_obj_t * keyboard, lv_obj_t * textarea)
|
|
||||||
{
|
|
||||||
lv_keyboard_set_textarea(keyboard, textarea);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _ui_flag_modify(lv_obj_t * target, int32_t flag, int value)
|
|
||||||
{
|
|
||||||
if(value == _UI_MODIFY_FLAG_TOGGLE) {
|
|
||||||
if(lv_obj_has_flag(target, flag)) lv_obj_clear_flag(target, flag);
|
|
||||||
else lv_obj_add_flag(target, flag);
|
|
||||||
}
|
|
||||||
else if(value == _UI_MODIFY_FLAG_ADD) lv_obj_add_flag(target, flag);
|
|
||||||
else lv_obj_clear_flag(target, flag);
|
|
||||||
}
|
|
||||||
void _ui_state_modify(lv_obj_t * target, int32_t state, int value)
|
|
||||||
{
|
|
||||||
if(value == _UI_MODIFY_STATE_TOGGLE) {
|
|
||||||
if(lv_obj_has_state(target, state)) lv_obj_clear_state(target, state);
|
|
||||||
else lv_obj_add_state(target, state);
|
|
||||||
}
|
|
||||||
else if(value == _UI_MODIFY_STATE_ADD) lv_obj_add_state(target, state);
|
|
||||||
else lv_obj_clear_state(target, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _ui_textarea_move_cursor(lv_obj_t * target, int val)
|
|
||||||
{
|
|
||||||
if(val == UI_MOVE_CURSOR_UP) lv_textarea_cursor_up(target);
|
|
||||||
if(val == UI_MOVE_CURSOR_RIGHT) lv_textarea_cursor_right(target);
|
|
||||||
if(val == UI_MOVE_CURSOR_DOWN) lv_textarea_cursor_down(target);
|
|
||||||
if(val == UI_MOVE_CURSOR_LEFT) lv_textarea_cursor_left(target);
|
|
||||||
lv_obj_add_state(target, LV_STATE_FOCUSED);
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef void (*screen_destroy_cb_t)(void);
|
|
||||||
void scr_unloaded_delete_cb(lv_event_t * e)
|
|
||||||
{
|
|
||||||
// Get the destroy callback from user_data
|
|
||||||
screen_destroy_cb_t destroy_cb = lv_event_get_user_data(e);
|
|
||||||
if(destroy_cb) {
|
|
||||||
destroy_cb(); // call the specific screen destroy function
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _ui_opacity_set(lv_obj_t * target, int val)
|
|
||||||
{
|
|
||||||
lv_obj_set_style_opa(target, val, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _ui_anim_callback_free_user_data(lv_anim_t * a)
|
|
||||||
{
|
|
||||||
lv_mem_free(a->user_data);
|
|
||||||
a->user_data = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void _ui_anim_callback_set_x(lv_anim_t * a, int32_t v)
|
|
||||||
{
|
|
||||||
ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data;
|
|
||||||
lv_obj_set_x(usr->target, v);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _ui_anim_callback_set_y(lv_anim_t * a, int32_t v)
|
|
||||||
{
|
|
||||||
ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data;
|
|
||||||
lv_obj_set_y(usr->target, v);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _ui_anim_callback_set_width(lv_anim_t * a, int32_t v)
|
|
||||||
{
|
|
||||||
ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data;
|
|
||||||
lv_obj_set_width(usr->target, v);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _ui_anim_callback_set_height(lv_anim_t * a, int32_t v)
|
|
||||||
{
|
|
||||||
ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data;
|
|
||||||
lv_obj_set_height(usr->target, v);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _ui_anim_callback_set_opacity(lv_anim_t * a, int32_t v)
|
|
||||||
{
|
|
||||||
ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data;
|
|
||||||
lv_obj_set_style_opa(usr->target, v, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _ui_anim_callback_set_image_zoom(lv_anim_t * a, int32_t v)
|
|
||||||
{
|
|
||||||
ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data;
|
|
||||||
lv_img_set_zoom(usr->target, v);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _ui_anim_callback_set_image_angle(lv_anim_t * a, int32_t v)
|
|
||||||
{
|
|
||||||
ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data;
|
|
||||||
lv_img_set_angle(usr->target, v);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _ui_anim_callback_set_image_frame(lv_anim_t * a, int32_t v)
|
|
||||||
{
|
|
||||||
ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data;
|
|
||||||
usr->val = v;
|
|
||||||
if(v < 0) v = 0;
|
|
||||||
if(v >= usr->imgset_size) v = usr->imgset_size - 1;
|
|
||||||
lv_img_set_src(usr->target, usr->imgset[v]);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t _ui_anim_callback_get_x(lv_anim_t * a)
|
|
||||||
{
|
|
||||||
ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data;
|
|
||||||
return lv_obj_get_x_aligned(usr->target);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t _ui_anim_callback_get_y(lv_anim_t * a)
|
|
||||||
{
|
|
||||||
ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data;
|
|
||||||
return lv_obj_get_y_aligned(usr->target);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t _ui_anim_callback_get_width(lv_anim_t * a)
|
|
||||||
{
|
|
||||||
ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data;
|
|
||||||
return lv_obj_get_width(usr->target);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t _ui_anim_callback_get_height(lv_anim_t * a)
|
|
||||||
{
|
|
||||||
ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data;
|
|
||||||
return lv_obj_get_height(usr->target);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t _ui_anim_callback_get_opacity(lv_anim_t * a)
|
|
||||||
{
|
|
||||||
ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data;
|
|
||||||
return lv_obj_get_style_opa(usr->target, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t _ui_anim_callback_get_image_zoom(lv_anim_t * a)
|
|
||||||
{
|
|
||||||
ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data;
|
|
||||||
return lv_img_get_zoom(usr->target);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t _ui_anim_callback_get_image_angle(lv_anim_t * a)
|
|
||||||
{
|
|
||||||
ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data;
|
|
||||||
return lv_img_get_angle(usr->target);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t _ui_anim_callback_get_image_frame(lv_anim_t * a)
|
|
||||||
{
|
|
||||||
ui_anim_user_data_t * usr = (ui_anim_user_data_t *)a->user_data;
|
|
||||||
return usr->val;
|
|
||||||
}
|
|
||||||
|
|
||||||
void _ui_arc_set_text_value(lv_obj_t * trg, lv_obj_t * src, const char * prefix, const char * postfix)
|
|
||||||
{
|
|
||||||
char buf[_UI_TEMPORARY_STRING_BUFFER_SIZE];
|
|
||||||
lv_snprintf(buf, sizeof(buf), "%s%d%s", prefix, (int)lv_arc_get_value(src), postfix);
|
|
||||||
lv_label_set_text(trg, buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _ui_slider_set_text_value(lv_obj_t * trg, lv_obj_t * src, const char * prefix, const char * postfix)
|
|
||||||
{
|
|
||||||
char buf[_UI_TEMPORARY_STRING_BUFFER_SIZE];
|
|
||||||
lv_snprintf(buf, sizeof(buf), "%s%d%s", prefix, (int)lv_slider_get_value(src), postfix);
|
|
||||||
lv_label_set_text(trg, buf);
|
|
||||||
}
|
|
||||||
void _ui_checked_set_text_value(lv_obj_t * trg, lv_obj_t * src, const char * txt_on, const char * txt_off)
|
|
||||||
{
|
|
||||||
if(lv_obj_has_state(src, LV_STATE_CHECKED)) lv_label_set_text(trg, txt_on);
|
|
||||||
else lv_label_set_text(trg, txt_off);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _ui_spinbox_step(lv_obj_t * target, int val)
|
|
||||||
{
|
|
||||||
if(val > 0) lv_spinbox_increment(target);
|
|
||||||
else lv_spinbox_decrement(target);
|
|
||||||
|
|
||||||
lv_event_send(target, LV_EVENT_VALUE_CHANGED, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _ui_switch_theme(int val)
|
|
||||||
{
|
|
||||||
#ifdef UI_THEME_ACTIVE
|
|
||||||
ui_theme_set(val);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,131 +0,0 @@
|
|||||||
// This file was generated by SquareLine Studio
|
|
||||||
// SquareLine Studio version: SquareLine Studio 1.5.4
|
|
||||||
// LVGL version: 8.3.6
|
|
||||||
// Project name: ESP32-S3-Touch-LCD-5B
|
|
||||||
|
|
||||||
#ifndef _ESP32_S3_TOUCH_LCD_5B_UI_HELPERS_H
|
|
||||||
#define _ESP32_S3_TOUCH_LCD_5B_UI_HELPERS_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "ui.h"
|
|
||||||
|
|
||||||
#define _UI_TEMPORARY_STRING_BUFFER_SIZE 32
|
|
||||||
#define _UI_BAR_PROPERTY_VALUE 0
|
|
||||||
#define _UI_BAR_PROPERTY_VALUE_WITH_ANIM 1
|
|
||||||
void _ui_bar_set_property(lv_obj_t * target, int id, int val);
|
|
||||||
|
|
||||||
#define _UI_BASIC_PROPERTY_POSITION_X 0
|
|
||||||
#define _UI_BASIC_PROPERTY_POSITION_Y 1
|
|
||||||
#define _UI_BASIC_PROPERTY_WIDTH 2
|
|
||||||
#define _UI_BASIC_PROPERTY_HEIGHT 3
|
|
||||||
void _ui_basic_set_property(lv_obj_t * target, int id, int val);
|
|
||||||
|
|
||||||
#define _UI_DROPDOWN_PROPERTY_SELECTED 0
|
|
||||||
void _ui_dropdown_set_property(lv_obj_t * target, int id, int val);
|
|
||||||
|
|
||||||
#define _UI_IMAGE_PROPERTY_IMAGE 0
|
|
||||||
void _ui_image_set_property(lv_obj_t * target, int id, uint8_t * val);
|
|
||||||
|
|
||||||
#define _UI_LABEL_PROPERTY_TEXT 0
|
|
||||||
void _ui_label_set_property(lv_obj_t * target, int id, const char * val);
|
|
||||||
|
|
||||||
#define _UI_ROLLER_PROPERTY_SELECTED 0
|
|
||||||
#define _UI_ROLLER_PROPERTY_SELECTED_WITH_ANIM 1
|
|
||||||
void _ui_roller_set_property(lv_obj_t * target, int id, int val);
|
|
||||||
|
|
||||||
#define _UI_SLIDER_PROPERTY_VALUE 0
|
|
||||||
#define _UI_SLIDER_PROPERTY_VALUE_WITH_ANIM 1
|
|
||||||
void _ui_slider_set_property(lv_obj_t * target, int id, int val);
|
|
||||||
|
|
||||||
void _ui_screen_change(lv_obj_t ** target, lv_scr_load_anim_t fademode, int spd, int delay, void (*target_init)(void));
|
|
||||||
|
|
||||||
void _ui_arc_increment(lv_obj_t * target, int val);
|
|
||||||
|
|
||||||
void _ui_bar_increment(lv_obj_t * target, int val, int anm);
|
|
||||||
|
|
||||||
void _ui_slider_increment(lv_obj_t * target, int val, int anm);
|
|
||||||
|
|
||||||
void _ui_keyboard_set_target(lv_obj_t * keyboard, lv_obj_t * textarea);
|
|
||||||
|
|
||||||
#define _UI_MODIFY_FLAG_ADD 0
|
|
||||||
#define _UI_MODIFY_FLAG_REMOVE 1
|
|
||||||
#define _UI_MODIFY_FLAG_TOGGLE 2
|
|
||||||
void _ui_flag_modify(lv_obj_t * target, int32_t flag, int value);
|
|
||||||
|
|
||||||
#define _UI_MODIFY_STATE_ADD 0
|
|
||||||
#define _UI_MODIFY_STATE_REMOVE 1
|
|
||||||
#define _UI_MODIFY_STATE_TOGGLE 2
|
|
||||||
void _ui_state_modify(lv_obj_t * target, int32_t state, int value);
|
|
||||||
|
|
||||||
#define UI_MOVE_CURSOR_UP 0
|
|
||||||
#define UI_MOVE_CURSOR_RIGHT 1
|
|
||||||
#define UI_MOVE_CURSOR_DOWN 2
|
|
||||||
#define UI_MOVE_CURSOR_LEFT 3
|
|
||||||
void _ui_textarea_move_cursor(lv_obj_t * target, int val)
|
|
||||||
;
|
|
||||||
|
|
||||||
void scr_unloaded_delete_cb(lv_event_t * e);
|
|
||||||
|
|
||||||
void _ui_opacity_set(lv_obj_t * target, int val);
|
|
||||||
|
|
||||||
/** Describes an animation*/
|
|
||||||
typedef struct _ui_anim_user_data_t {
|
|
||||||
lv_obj_t * target;
|
|
||||||
lv_img_dsc_t ** imgset;
|
|
||||||
int32_t imgset_size;
|
|
||||||
int32_t val;
|
|
||||||
} ui_anim_user_data_t;
|
|
||||||
void _ui_anim_callback_free_user_data(lv_anim_t * a);
|
|
||||||
|
|
||||||
void _ui_anim_callback_set_x(lv_anim_t * a, int32_t v);
|
|
||||||
|
|
||||||
void _ui_anim_callback_set_y(lv_anim_t * a, int32_t v);
|
|
||||||
|
|
||||||
void _ui_anim_callback_set_width(lv_anim_t * a, int32_t v);
|
|
||||||
|
|
||||||
void _ui_anim_callback_set_height(lv_anim_t * a, int32_t v);
|
|
||||||
|
|
||||||
void _ui_anim_callback_set_opacity(lv_anim_t * a, int32_t v);
|
|
||||||
|
|
||||||
void _ui_anim_callback_set_image_zoom(lv_anim_t * a, int32_t v);
|
|
||||||
|
|
||||||
void _ui_anim_callback_set_image_angle(lv_anim_t * a, int32_t v);
|
|
||||||
|
|
||||||
void _ui_anim_callback_set_image_frame(lv_anim_t * a, int32_t v);
|
|
||||||
|
|
||||||
int32_t _ui_anim_callback_get_x(lv_anim_t * a);
|
|
||||||
|
|
||||||
int32_t _ui_anim_callback_get_y(lv_anim_t * a);
|
|
||||||
|
|
||||||
int32_t _ui_anim_callback_get_width(lv_anim_t * a);
|
|
||||||
|
|
||||||
int32_t _ui_anim_callback_get_height(lv_anim_t * a);
|
|
||||||
|
|
||||||
int32_t _ui_anim_callback_get_opacity(lv_anim_t * a);
|
|
||||||
|
|
||||||
int32_t _ui_anim_callback_get_image_zoom(lv_anim_t * a);
|
|
||||||
|
|
||||||
int32_t _ui_anim_callback_get_image_angle(lv_anim_t * a);
|
|
||||||
|
|
||||||
int32_t _ui_anim_callback_get_image_frame(lv_anim_t * a);
|
|
||||||
|
|
||||||
void _ui_arc_set_text_value(lv_obj_t * trg, lv_obj_t * src, const char * prefix, const char * postfix);
|
|
||||||
|
|
||||||
void _ui_slider_set_text_value(lv_obj_t * trg, lv_obj_t * src, const char * prefix, const char * postfix);
|
|
||||||
|
|
||||||
void _ui_checked_set_text_value(lv_obj_t * trg, lv_obj_t * src, const char * txt_on, const char * txt_off);
|
|
||||||
|
|
||||||
void _ui_spinbox_step(lv_obj_t * target, int val)
|
|
||||||
;
|
|
||||||
|
|
||||||
void _ui_switch_theme(int val)
|
|
||||||
;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
} /*extern "C"*/
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,209 +0,0 @@
|
|||||||
// This file was generated by SquareLine Studio
|
|
||||||
// SquareLine Studio version: SquareLine Studio 1.4.3+
|
|
||||||
// LVGL version: 8.3.11
|
|
||||||
// Project name: design
|
|
||||||
|
|
||||||
#include "ui.h"
|
|
||||||
|
|
||||||
_ui_local_style_t* _ui_local_styles;
|
|
||||||
uint32_t _ui_local_style_count = 0;
|
|
||||||
|
|
||||||
|
|
||||||
inline void ui_object_set_local_style_property
|
|
||||||
(lv_obj_t* object_p, lv_style_selector_t selector, lv_style_prop_t property, ui_style_variable_t value ) {
|
|
||||||
if ( object_p!=NULL /*&& lv_obj_is_valid(object_p)*/ ) {
|
|
||||||
lv_obj_set_local_style_prop( object_p, property, _ui_style_value_convert( property, value ), selector );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Atomic function to set (and register) an LVGL local style-property for a given part+state (selector) of an object (widget) - can be used in many ways due to being atomic
|
|
||||||
void ui_object_set_themeable_style_property
|
|
||||||
(lv_obj_t* object_p, lv_style_selector_t selector, lv_style_prop_t property, const ui_theme_variable_t* theme_variable_p) {
|
|
||||||
static _ui_local_style_t* local_style_p;
|
|
||||||
static _ui_local_style_property_setting_t* property_setting_p;
|
|
||||||
|
|
||||||
if (object_p==NULL /*|| !lv_obj_is_valid(object_p)*/ || theme_variable_p==NULL) return;
|
|
||||||
local_style_p = _ui_local_style_create( theme_variable_p, true );
|
|
||||||
if (local_style_p == NULL) return;
|
|
||||||
property_setting_p = _ui_local_style_property_setting_create( local_style_p, object_p, selector, property );
|
|
||||||
if (property_setting_p == NULL) return;
|
|
||||||
|
|
||||||
lv_obj_set_local_style_prop( object_p, property, _ui_style_value_convert( property, ui_get_theme_value(theme_variable_p) ), selector ); //ui_object_set_local_style_property( object_p, selector, property, ui_get_theme_value(theme_variable_p) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//This function goes through all registered style-property settings and if theme is changed, sets all of them to the theme. (If called periodically, it can follow change of values automatically.)
|
|
||||||
void _ui_theme_set_variable_styles (uint8_t mode) {
|
|
||||||
static uint8_t ui_theme_idx_previous = -1;
|
|
||||||
static uint32_t i, j;
|
|
||||||
static _ui_local_style_property_setting_t* property_setting_p;
|
|
||||||
static ui_style_variable_t style_value;
|
|
||||||
static ui_style_variable_t* style_variable_p;
|
|
||||||
|
|
||||||
uint8_t ui_Theme_Changed = (ui_theme_idx != ui_theme_idx_previous); ui_theme_idx_previous = ui_theme_idx;
|
|
||||||
|
|
||||||
for (i = 0; i < _ui_local_style_count; ++i) {
|
|
||||||
|
|
||||||
style_variable_p = _ui_local_styles[i].style_variable_p;
|
|
||||||
if (_ui_local_styles[i].is_themeable) style_value = ui_get_theme_value( style_variable_p );
|
|
||||||
else style_value = *style_variable_p;
|
|
||||||
|
|
||||||
if (style_variable_p != _ui_local_styles[i].previous_pointer || style_value != _ui_local_styles[i].previous_value
|
|
||||||
|| mode == UI_VARIABLE_STYLES_MODE_INIT || ui_Theme_Changed) {
|
|
||||||
_ui_local_styles[i].previous_pointer = style_variable_p; _ui_local_styles[i].previous_value = style_value;
|
|
||||||
|
|
||||||
property_setting_p = _ui_local_styles[i].style_property_settings; //first item of linked list
|
|
||||||
for (j = 0; j < _ui_local_styles[i].style_property_setting_count; ++j) {
|
|
||||||
if (property_setting_p->object_p != NULL) {
|
|
||||||
ui_object_set_local_style_property (
|
|
||||||
property_setting_p->object_p, property_setting_p->selector, property_setting_p->property, style_value
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (property_setting_p->next_p != NULL) property_setting_p = (_ui_local_style_property_setting_t*) property_setting_p->next_p; //get next item in linked-list for next round
|
|
||||||
else break; //this shouldn't happen, but if it does, it's assumed end of the list
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ui_style_variable_t ui_get_theme_value(const ui_theme_variable_t* var) {
|
|
||||||
return var[ui_theme_idx];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
lv_style_value_t _ui_style_value_convert (lv_style_prop_t property, ui_style_variable_t value) {
|
|
||||||
static lv_style_value_t Style_Value; //LVGL would produce artefacts if both .num and .color were set for the local style to add:
|
|
||||||
//static lv_style_const_prop_t ValueConvert_Table [_LV_STYLE_NUM_BUILT_IN_PROPS] = { [LV_STYLE_BG_COLOR] = LV_STYLE_CONST_BG_COLOR(1), [LV_STYLE_BG_OPA] = LV_STYLE_CONST_BG_OPA(1) };
|
|
||||||
if (property==LV_STYLE_BG_COLOR || property==LV_STYLE_BG_GRAD_COLOR || property==LV_STYLE_BG_IMG_RECOLOR || property==LV_STYLE_BORDER_COLOR
|
|
||||||
|| property==LV_STYLE_OUTLINE_COLOR || property==LV_STYLE_SHADOW_COLOR || property==LV_STYLE_IMG_RECOLOR || property==LV_STYLE_LINE_COLOR
|
|
||||||
|| property==LV_STYLE_ARC_COLOR || property==LV_STYLE_TEXT_COLOR) {
|
|
||||||
Style_Value.color = lv_color_hex(value);
|
|
||||||
}
|
|
||||||
else if (property==LV_STYLE_BG_GRAD || property==LV_STYLE_BG_IMG_SRC || property==LV_STYLE_ARC_IMG_SRC || property==LV_STYLE_TEXT_FONT
|
|
||||||
|| property==LV_STYLE_COLOR_FILTER_DSC || property==LV_STYLE_ANIM || property==LV_STYLE_TRANSITION) {
|
|
||||||
Style_Value.ptr = (void*)(uintptr_t) value;
|
|
||||||
}
|
|
||||||
else Style_Value.num = value;
|
|
||||||
return Style_Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//auto-update dynamic local style array with existing/new style-variable (1st dimension)
|
|
||||||
_ui_local_style_t* _ui_local_style_create (const ui_style_variable_t* style_variable_p, bool is_themeable) {
|
|
||||||
static uint32_t i;
|
|
||||||
static _ui_local_style_t* local_style_p;
|
|
||||||
|
|
||||||
for (i = 0; i < _ui_local_style_count; ++i) { //Find existing local style
|
|
||||||
if (_ui_local_styles[i].style_variable_p == style_variable_p) return &_ui_local_styles[i];
|
|
||||||
}
|
|
||||||
//If not found, create new local style
|
|
||||||
_ui_local_styles = (_ui_local_style_t*) lv_mem_realloc( _ui_local_styles, (_ui_local_style_count + 1) * sizeof(_ui_local_style_t) );
|
|
||||||
LV_ASSERT_MALLOC( _ui_local_styles );
|
|
||||||
if (_ui_local_styles == NULL) return NULL;
|
|
||||||
//Reset new local style
|
|
||||||
local_style_p = &_ui_local_styles[ _ui_local_style_count ];
|
|
||||||
local_style_p->style_variable_p = (ui_style_variable_t*) style_variable_p;
|
|
||||||
local_style_p->is_themeable = is_themeable;
|
|
||||||
local_style_p->previous_pointer = NULL;
|
|
||||||
local_style_p->previous_value = -1;
|
|
||||||
local_style_p->style_property_setting_count = 0;
|
|
||||||
local_style_p->style_property_settings = NULL;
|
|
||||||
/*#ifdef LV_SQUARELINE_THEME__EXPLICIT_GARBAGE_COLLECTOR_PERIOD
|
|
||||||
local_style_p->garbage_collector_couter = 0;
|
|
||||||
#endif*/
|
|
||||||
|
|
||||||
++_ui_local_style_count;
|
|
||||||
return local_style_p;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void _ui_local_style_property_setting_delete (lv_event_t* event) { * (lv_obj_t**) lv_event_get_user_data( event ) = NULL; }
|
|
||||||
|
|
||||||
//auto-update dynamic local style-array's 2nd dimension (object part+state style-property settings for a given style-variable)
|
|
||||||
_ui_local_style_property_setting_t* _ui_local_style_property_setting_create
|
|
||||||
(_ui_local_style_t* local_style_p, lv_obj_t* object_p, lv_style_selector_t selector, lv_style_prop_t property) {
|
|
||||||
static uint32_t i; //auto-update
|
|
||||||
static _ui_local_style_property_setting_t *style_property_setting_p, *empty_style_property_setting_p;
|
|
||||||
|
|
||||||
/*#ifdef LV_SQUARELINE_THEME__EXPLICIT_GARBAGE_COLLECTOR_PERIOD
|
|
||||||
style_property_setting_p = local_style_p->style_property_settings; //first item of linked list
|
|
||||||
if (style_property_setting_p != NULL) { //checking might be unnecessary if count is properly initialized to 0
|
|
||||||
if (local_style_p->garbage_collector_couter > 0) --local_style_p->garbage_collector_couter; //avoid calling garbage collector every time
|
|
||||||
else if (LV_SQUARELINE_THEME__EXPLICIT_GARBAGE_COLLECTOR_PERIOD > 0) {
|
|
||||||
local_style_p->garbage_collector_couter = LV_SQUARELINE_THEME__EXPLICIT_GARBAGE_COLLECTOR_PERIOD - 1;
|
|
||||||
for (i = 0; i < local_style_p->style_property_setting_count; ++i) {
|
|
||||||
if (style_property_setting_p->object_p != NULL) { //check only valid object entry (skip already emptied positions{
|
|
||||||
#if ( defined(LV_SQUARELINE_THEME__OBJECT_VALIDITY_CACHE) && LV_SQUARELINE_THEME__OBJECT_VALIDITY_CACHE ) //Not recommended inside explicit garbage collector.
|
|
||||||
if ( style_property_setting_p->validcheck_counter > 0 ) --style_property_setting_p->validcheck_counter; //avoids calling complex lv_obj_is_valid() many times
|
|
||||||
else { //check objects with expired positive vaidity check
|
|
||||||
if ( lv_obj_is_valid( style_property_setting_p->object_p ) ) style_property_setting_p->validcheck_counter = LV_SQUARELINE_THEME__OBJECT_VALIDITY_CACHE;
|
|
||||||
else style_property_setting_p->object_p = NULL; //free up an entry of a deleted widget
|
|
||||||
}
|
|
||||||
#else //this is the recommended variant inside explicit garbage collector:
|
|
||||||
if ( !lv_obj_is_valid( style_property_setting_p->object_p ) ) style_property_setting_p->object_p = NULL; //free up an entry of a deleted widget
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
if (style_property_setting_p->next_p != NULL) style_property_setting_p = (_ui_local_style_property_setting_t*) style_property_setting_p->next_p; //get next item in linked-list for next round
|
|
||||||
else break; //this shouldn't happen
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif*/
|
|
||||||
style_property_setting_p = local_style_p->style_property_settings; //first item of linked list
|
|
||||||
empty_style_property_setting_p = NULL;
|
|
||||||
if (style_property_setting_p != NULL) { //checking might be unnecessary if count is properly initialized to 0
|
|
||||||
for (i = 0; i < local_style_p->style_property_setting_count; ++i) {
|
|
||||||
if (empty_style_property_setting_p == NULL) { //search and register one empty position that might be needed for a newly created entry
|
|
||||||
if (style_property_setting_p->object_p == NULL) empty_style_property_setting_p = style_property_setting_p; //if found empty position, register it
|
|
||||||
/*#ifdef LV_SQUARELINE_THEME__IMPLICIT_GARBAGE_COLLECTOR
|
|
||||||
else { //if not, check for possible empty positions of deleted objects (garbage-collection)
|
|
||||||
#if ( defined(LV_SQUARELINE_THEME__OBJECT_VALIDITY_CACHE) && LV_SQUARELINE_THEME__OBJECT_VALIDITY_CACHE ) //for slow hardware, adding this and setting to 5..10 in lv_conf.h might make it faster
|
|
||||||
if ( style_property_setting_p->validcheck_counter > 0 ) --style_property_setting_p->validcheck_counter; //avoids calling complex lv_obj_is_valid() many times
|
|
||||||
else { //check objects with expired positive vaidity check
|
|
||||||
if ( lv_obj_is_valid( style_property_setting_p->object_p ) ) style_property_setting_p->validcheck_counter = LV_SQUARELINE_THEME__OBJECT_VALIDITY_CACHE;
|
|
||||||
else { //free up an entry of a deleted widget
|
|
||||||
style_property_setting_p->object_p = NULL;
|
|
||||||
empty_style_property_setting_p = style_property_setting_p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if ( !lv_obj_is_valid( style_property_setting_p->object_p ) ) { //free up an entry of a deleted widget
|
|
||||||
style_property_setting_p->object_p = NULL;
|
|
||||||
empty_style_property_setting_p = style_property_setting_p;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif*/
|
|
||||||
}
|
|
||||||
if (style_property_setting_p->object_p == object_p && style_property_setting_p->selector == selector
|
|
||||||
&& style_property_setting_p->property == property) { //setting found in the list (created already), so returning it
|
|
||||||
return style_property_setting_p;
|
|
||||||
}
|
|
||||||
if (style_property_setting_p->next_p != NULL) style_property_setting_p = (_ui_local_style_property_setting_t*) style_property_setting_p->next_p; //get next item in linked-list for next round
|
|
||||||
else break; //this shouldn't happen, but if it does, create a new element
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//If not found, create new local style-property (can be inside the array at freed-up places of deleted objects too)
|
|
||||||
if (empty_style_property_setting_p == NULL) { //allocate new
|
|
||||||
empty_style_property_setting_p = (_ui_local_style_property_setting_t*) lv_mem_alloc( sizeof(_ui_local_style_property_setting_t) );
|
|
||||||
LV_ASSERT_MALLOC( empty_style_property_setting_p );
|
|
||||||
if (empty_style_property_setting_p == NULL) return NULL;
|
|
||||||
if (style_property_setting_p != NULL) style_property_setting_p->next_p = (void*) empty_style_property_setting_p; //create link from last item to the new
|
|
||||||
else local_style_p->style_property_settings = empty_style_property_setting_p; //(except if creating first item)
|
|
||||||
style_property_setting_p = empty_style_property_setting_p; //take the new item pointer for initialization
|
|
||||||
style_property_setting_p->next_p = NULL; //signify the end of the linked list, just in case
|
|
||||||
++local_style_p->style_property_setting_count;
|
|
||||||
}
|
|
||||||
else { //reuse empty
|
|
||||||
style_property_setting_p = empty_style_property_setting_p;
|
|
||||||
}
|
|
||||||
style_property_setting_p->object_p = object_p; lv_obj_add_event_cb( object_p, _ui_local_style_property_setting_delete, LV_EVENT_DELETE, &style_property_setting_p->object_p );
|
|
||||||
style_property_setting_p->selector = selector;
|
|
||||||
style_property_setting_p->property = property;
|
|
||||||
/*#ifdef LV_SQUARELINE_THEME__OBJECT_VALIDITY_CACHE
|
|
||||||
style_property_setting_p->validcheck_counter = LV_SQUARELINE_THEME__OBJECT_VALIDITY_CACHE; //0
|
|
||||||
#endif*/
|
|
||||||
return style_property_setting_p;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
// This file was generated by SquareLine Studio
|
|
||||||
// SquareLine Studio version: SquareLine Studio 1.4.3+
|
|
||||||
|
|
||||||
#ifndef _UI_THEME_MANAGER_H
|
|
||||||
#define _UI_THEME_MANAGER_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define UI_THEME_ACTIVE 1
|
|
||||||
|
|
||||||
/*#ifndef LV_SQUARELINE_THEME__IMPLICIT_GARBAGE_COLLECTOR
|
|
||||||
#ifndef LV_SQUARELINE_THEME__EXPLICIT_GARBAGE_COLLECTOR_PERIOD //for slow hardware, tells how frequently the style-properties inside this style should be garbage-collected (recommended value: 10..100, 0:never)
|
|
||||||
#define LV_SQUARELINE_THEME__EXPLICIT_GARBAGE_COLLECTOR_PERIOD 100 //a sensible default value that already gives good results on slow hardware, can be overridden from outside
|
|
||||||
#endif
|
|
||||||
#endif*/
|
|
||||||
|
|
||||||
|
|
||||||
enum { UI_VARIABLE_STYLES_MODE_INIT = 1, UI_VARIABLE_STYLES_MODE_FOLLOW = 0 };
|
|
||||||
|
|
||||||
|
|
||||||
typedef int64_t ui_style_variable_t;
|
|
||||||
typedef ui_style_variable_t ui_theme_variable_t; //A 'theme' variable array is an array of 'style' variables for corresponding themes.
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
lv_obj_t * object_p;
|
|
||||||
lv_style_selector_t selector;
|
|
||||||
lv_style_prop_t property;
|
|
||||||
/*#ifdef LV_SQUARELINE_THEME__OBJECT_VALIDITY_CACHE //for slow hardware, adding this and setting to 5..10 in lv_conf.h might make it faster (less lv_obj_is_valid calls)
|
|
||||||
uint16_t validcheck_counter; //used for garbage collection (finding empty slots) not to call lv_obj_is_valid() every time
|
|
||||||
#endif*/
|
|
||||||
void * next_p;
|
|
||||||
} _ui_local_style_property_setting_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
bool is_themeable; //scalar or vector?
|
|
||||||
ui_style_variable_t * style_variable_p;
|
|
||||||
ui_style_variable_t * previous_pointer;
|
|
||||||
ui_style_variable_t previous_value;
|
|
||||||
uint32_t style_property_setting_count;
|
|
||||||
_ui_local_style_property_setting_t * style_property_settings;
|
|
||||||
/*#ifdef LV_SQUARELINE_THEME__EXPLICIT_GARBAGE_COLLECTOR_PERIOD
|
|
||||||
uint16_t garbage_collector_couter;
|
|
||||||
#endif*/
|
|
||||||
} _ui_local_style_t;
|
|
||||||
|
|
||||||
|
|
||||||
extern _ui_local_style_t * _ui_local_styles;
|
|
||||||
extern uint32_t _ui_local_style_count;
|
|
||||||
|
|
||||||
|
|
||||||
void ui_object_set_local_style_property
|
|
||||||
(lv_obj_t* object_p, lv_style_selector_t selector, lv_style_prop_t property, ui_style_variable_t value );
|
|
||||||
|
|
||||||
void ui_object_set_themeable_style_property
|
|
||||||
(lv_obj_t* object_p, lv_style_selector_t selector, lv_style_prop_t property, const ui_theme_variable_t* theme_variable_p);
|
|
||||||
|
|
||||||
void _ui_theme_set_variable_styles (uint8_t mode);
|
|
||||||
|
|
||||||
lv_style_value_t _ui_style_value_convert (lv_style_prop_t property, ui_style_variable_t value);
|
|
||||||
ui_style_variable_t ui_get_theme_value (const ui_theme_variable_t *var);
|
|
||||||
|
|
||||||
_ui_local_style_t * _ui_local_style_create (const ui_style_variable_t * style_variable_p, bool is_themeable);
|
|
||||||
|
|
||||||
_ui_local_style_property_setting_t * _ui_local_style_property_setting_create
|
|
||||||
(_ui_local_style_t * local_style, lv_obj_t * object_p, lv_style_selector_t selector, lv_style_prop_t property);
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
} /*extern "C"*/
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
// This file was generated by SquareLine Studio
|
|
||||||
// SquareLine Studio version: SquareLine Studio 1.5.4
|
|
||||||
// LVGL version: 8.3.6
|
|
||||||
// Project name: ESP32-S3-Touch-LCD-5B
|
|
||||||
|
|
||||||
#include "ui.h"
|
|
||||||
|
|
||||||
const ui_theme_variable_t _ui_theme_color_panel_backgroung[1] = {0x7F7A9C};
|
|
||||||
const ui_theme_variable_t _ui_theme_alpha_panel_backgroung[1] = {255};
|
|
||||||
uint8_t ui_theme_idx = UI_THEME_DEFAULT;
|
|
||||||
|
|
||||||
void ui_theme_set(uint8_t theme_idx)
|
|
||||||
{
|
|
||||||
ui_theme_idx = theme_idx;
|
|
||||||
_ui_theme_set_variable_styles(UI_VARIABLE_STYLES_MODE_FOLLOW);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
// This file was generated by SquareLine Studio
|
|
||||||
// SquareLine Studio version: SquareLine Studio 1.5.4
|
|
||||||
// LVGL version: 8.3.6
|
|
||||||
// Project name: ESP32-S3-Touch-LCD-5B
|
|
||||||
|
|
||||||
#ifndef _UI_THEMES_H
|
|
||||||
#define _UI_THEMES_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define UI_THEME_COLOR_PANEL_BACKGROUNG 0
|
|
||||||
|
|
||||||
#define UI_THEME_DEFAULT 0
|
|
||||||
|
|
||||||
extern const ui_theme_variable_t _ui_theme_color_panel_backgroung[1];
|
|
||||||
extern const ui_theme_variable_t _ui_theme_alpha_panel_backgroung[1];
|
|
||||||
|
|
||||||
extern const uint32_t * ui_theme_colors[1];
|
|
||||||
extern const uint8_t * ui_theme_alphas[1];
|
|
||||||
extern uint8_t ui_theme_idx;
|
|
||||||
|
|
||||||
void ui_theme_set(uint8_t theme_idx);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
} /*extern "C"*/
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
+42
-6
@@ -49,8 +49,43 @@ lib_deps =
|
|||||||
; ----------------------------------------------------------------------------
|
; ----------------------------------------------------------------------------
|
||||||
; Build Flags & Source Directories
|
; Build Flags & Source Directories
|
||||||
; ----------------------------------------------------------------------------
|
; ----------------------------------------------------------------------------
|
||||||
; Include UI, display, and modules directories as source directories
|
; Also compile the LVGL port that lives under include/display
|
||||||
build_src_filter = +<*> +<modules/*> +<../include/ui/*> +<../include/display/*>
|
build_src_filter = +<*> +<modules/*> +<../include/display/*>
|
||||||
|
|
||||||
|
; ---- Display experiment (branch display-xip, wiki open-questions #13 step 3) ----
|
||||||
|
; Rebuilds the Arduino core with these sdkconfig changes (pioarduino custom_sdkconfig):
|
||||||
|
; - XIP_FROM_PSRAM: code + rodata execute from PSRAM, so flash writes (NVS, OTA)
|
||||||
|
; no longer stall everything that touches PSRAM (the LCD framebuffer refill).
|
||||||
|
; - LCD_RGB_ISR_IRAM_SAFE: the bounce-buffer refill interrupt keeps running while
|
||||||
|
; the flash cache is disabled.
|
||||||
|
; Components not used by this firmware, dropped from the core rebuild. RainMaker /
|
||||||
|
; Insights also try to embed a https_server.crt that only exists in their own
|
||||||
|
; projects, which broke the first custom_sdkconfig build (2026-09-27).
|
||||||
|
custom_component_remove =
|
||||||
|
espressif/esp_rainmaker
|
||||||
|
espressif/rmaker_common
|
||||||
|
espressif/esp_insights
|
||||||
|
espressif/esp_diag_data_store
|
||||||
|
espressif/esp_diagnostics
|
||||||
|
espressif/cbor
|
||||||
|
espressif/qrcode
|
||||||
|
espressif/network_provisioning
|
||||||
|
espressif/esp-zboss-lib
|
||||||
|
espressif/esp-zigbee-lib
|
||||||
|
espressif/esp_hosted
|
||||||
|
espressif/esp_wifi_remote
|
||||||
|
espressif/esp-sr
|
||||||
|
espressif/esp-dsp
|
||||||
|
espressif/esp-modbus
|
||||||
|
espressif/libsodium
|
||||||
|
chmorgan/esp-libhelix-mp3
|
||||||
|
espressif/esp32-camera
|
||||||
|
|
||||||
|
custom_sdkconfig =
|
||||||
|
CONFIG_SPIRAM_XIP_FROM_PSRAM=y
|
||||||
|
CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y
|
||||||
|
CONFIG_SPIRAM_RODATA=y
|
||||||
|
CONFIG_LCD_RGB_ISR_IRAM_SAFE=y
|
||||||
|
|
||||||
build_flags =
|
build_flags =
|
||||||
; C++ standard (required for ESP32_Display_Panel)
|
; C++ standard (required for ESP32_Display_Panel)
|
||||||
@@ -79,9 +114,11 @@ build_flags =
|
|||||||
|
|
||||||
; RGB LCD Framebuffer Configuration for large displays
|
; RGB LCD Framebuffer Configuration for large displays
|
||||||
; Force RGB LCD to use PSRAM for framebuffers (1024x600 requires ~2.4MB)
|
; Force RGB LCD to use PSRAM for framebuffers (1024x600 requires ~2.4MB)
|
||||||
-DESP_PANEL_LCD_RGB_BUFFER_NUMS=2
|
; NOTE: the RGB panel settings (21 MHz pixel clock, 10-line bounce buffers,
|
||||||
-DESP_PANEL_LCD_RGB_BOUNCE_BUF_SIZE=0
|
; porches, pins) come from ESP32_Display_Panel's board header
|
||||||
-DESP_PANEL_LCD_RGB_REFRESH_MODE=0
|
; BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_5_B.h (ESP_PANEL_BOARD_LCD_RGB_*).
|
||||||
|
; The old -DESP_PANEL_LCD_RGB_{BUFFER_NUMS,BOUNCE_BUF_SIZE,REFRESH_MODE}
|
||||||
|
; flags here were never read by the v1.x library and were removed 2026-09-27.
|
||||||
|
|
||||||
; FreeRTOS configuration
|
; FreeRTOS configuration
|
||||||
-DARDUINO_RUNNING_CORE=1 ; LVGL runs on Core 1
|
-DARDUINO_RUNNING_CORE=1 ; LVGL runs on Core 1
|
||||||
@@ -91,7 +128,6 @@ build_flags =
|
|||||||
-I include/config
|
-I include/config
|
||||||
-I include/display
|
-I include/display
|
||||||
-I include/protocol
|
-I include/protocol
|
||||||
-I include/ui
|
|
||||||
-I src
|
-I src
|
||||||
|
|
||||||
; ----------------------------------------------------------------------------
|
; ----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ static QueueHandle_t g_can_event_queue = NULL;
|
|||||||
static can_stats_t g_can_stats = {0};
|
static can_stats_t g_can_stats = {0};
|
||||||
static bool g_uart_auto_stopped = false; // Track if UART was auto-stopped due to CAN timeout
|
static bool g_uart_auto_stopped = false; // Track if UART was auto-stopped due to CAN timeout
|
||||||
|
|
||||||
|
|
||||||
// Raw frame logging: capture EVERY frame (candump-style) for offline CAN ID
|
// Raw frame logging: capture EVERY frame (candump-style) for offline CAN ID
|
||||||
// discovery. Default ON since discovery is the current priority.
|
// discovery. Default ON since discovery is the current priority.
|
||||||
static bool g_raw_logging = true;
|
static bool g_raw_logging = true;
|
||||||
@@ -53,6 +54,22 @@ static bool g_verbose_decode = false;
|
|||||||
// Guarded by g_data_mutex along with g_automotive_data.
|
// Guarded by g_data_mutex along with g_automotive_data.
|
||||||
static driveline_t g_driveline = {0};
|
static driveline_t g_driveline = {0};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forget every CAN-derived value: nothing may be shown or sent that the bus
|
||||||
|
* did not say recently. Called when CAN stops and when the bus goes silent.
|
||||||
|
*/
|
||||||
|
static void clearSharedData() {
|
||||||
|
if (xSemaphoreTake(UARTManager::g_data_mutex, pdMS_TO_TICKS(100)) == pdTRUE) {
|
||||||
|
uint8_t dbg = UARTManager::g_automotive_data.debug_enabled;
|
||||||
|
memset(&UARTManager::g_automotive_data, 0, sizeof(UARTManager::g_automotive_data));
|
||||||
|
UARTManager::g_automotive_data.gear_lever = LEVER_UNKNOWN;
|
||||||
|
UARTManager::g_automotive_data.debug_enabled = dbg;
|
||||||
|
xSemaphoreGive(UARTManager::g_data_mutex);
|
||||||
|
}
|
||||||
|
memset(&g_driveline, 0, sizeof(g_driveline));
|
||||||
|
g_driveline.lever = GEAR_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
// Last gear LEVER code seen on 0x1D2, for the lever-vs-gearbox cross-check.
|
// Last gear LEVER code seen on 0x1D2, for the lever-vs-gearbox cross-check.
|
||||||
static gear_position_t g_last_lever = GEAR_UNKNOWN;
|
static gear_position_t g_last_lever = GEAR_UNKNOWN;
|
||||||
// When the current disagreement started (0 = currently in agreement).
|
// When the current disagreement started (0 = currently in agreement).
|
||||||
@@ -523,6 +540,7 @@ static void canTask(void* parameter) {
|
|||||||
deinitTWAI();
|
deinitTWAI();
|
||||||
g_can_active = false;
|
g_can_active = false;
|
||||||
g_uart_auto_stopped = false; // Reset auto-stop flag
|
g_uart_auto_stopped = false; // Reset auto-stop flag
|
||||||
|
clearSharedData();
|
||||||
|
|
||||||
// Auto-stop UART transmission (CAN drives UART)
|
// Auto-stop UART transmission (CAN drives UART)
|
||||||
UARTManager::linkToCANState(false);
|
UARTManager::linkToCANState(false);
|
||||||
@@ -595,6 +613,7 @@ static void canTask(void* parameter) {
|
|||||||
// CAN data is stale - auto-stop UART to prevent transmitting stale data
|
// CAN data is stale - auto-stop UART to prevent transmitting stale data
|
||||||
ESP_LOGW("CANTask", "⚠ CAN timeout (%dms since last message), auto-stopping UART", time_since_last_rx);
|
ESP_LOGW("CANTask", "⚠ CAN timeout (%dms since last message), auto-stopping UART", time_since_last_rx);
|
||||||
UARTManager::linkToCANState(false);
|
UARTManager::linkToCANState(false);
|
||||||
|
clearSharedData(); // stale values must not come back as "valid" later
|
||||||
g_uart_auto_stopped = true;
|
g_uart_auto_stopped = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -718,14 +737,7 @@ void setVerboseDecode(bool enabled) {
|
|||||||
ESP_LOGI("CANDrv", "Verbose decode logging %s", enabled ? "ENABLED" : "disabled");
|
ESP_LOGI("CANDrv", "Verbose decode logging %s", enabled ? "ENABLED" : "disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
void onCANToggle(lv_event_t *e) {
|
void setEnabled(bool state) {
|
||||||
lv_obj_t *target = lv_event_get_target(e);
|
|
||||||
if (target == NULL) {
|
|
||||||
ESP_LOGE("CANDrv", "ERROR: CAN toggle target is NULL!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool state = lv_obj_has_state(target, LV_STATE_CHECKED);
|
|
||||||
ESP_LOGI("CANDrv", "===== CAN Toggle Event =====");
|
ESP_LOGI("CANDrv", "===== CAN Toggle Event =====");
|
||||||
ESP_LOGI("CANDrv", "CAN Toggle State: %s", state ? "ON" : "OFF");
|
ESP_LOGI("CANDrv", "CAN Toggle State: %s", state ? "ON" : "OFF");
|
||||||
|
|
||||||
|
|||||||
+47
-98
@@ -1,5 +1,6 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <lvgl.h>
|
#include <lvgl.h>
|
||||||
|
#include <esp_heap_caps.h>
|
||||||
#include "display/lvgl_v8_port.h" // LVGL port layer (for lvgl_port_lock/unlock)
|
#include "display/lvgl_v8_port.h" // LVGL port layer (for lvgl_port_lock/unlock)
|
||||||
#include "modules/display_init.h" // Display initialization module
|
#include "modules/display_init.h" // Display initialization module
|
||||||
#include "modules/wifi_manager.h" // WiFi manager module
|
#include "modules/wifi_manager.h" // WiFi manager module
|
||||||
@@ -9,114 +10,60 @@
|
|||||||
#include "modules/ui_state_manager.h" // UI state manager module
|
#include "modules/ui_state_manager.h" // UI state manager module
|
||||||
#include "modules/driveline_screen.h" // Hand-coded driveline screen (boot screen)
|
#include "modules/driveline_screen.h" // Hand-coded driveline screen (boot screen)
|
||||||
#include "modules/tuning_screen.h" // Hand-coded gauge tuning screen (swipe right from Driveline)
|
#include "modules/tuning_screen.h" // Hand-coded gauge tuning screen (swipe right from Driveline)
|
||||||
|
#include "modules/settings_screen.h" // Hand-coded settings screen (swipe left from Driveline)
|
||||||
#include "modules/serial_lock.h" // Global serial write mutex
|
#include "modules/serial_lock.h" // Global serial write mutex
|
||||||
#include "modules/tunables.h" // Gauge calibration + alert thresholds (NVS, serial console)
|
#include "modules/tunables.h" // Gauge calibration + alert thresholds (NVS, serial console)
|
||||||
#include "modules/espnow_link.h" // ESP-NOW transmit leg of the link to Controller B
|
#include "modules/perf_monitor.h" // `perf` console: render fps, flush cost, CPU idle, heap
|
||||||
|
#include "modules/espnow_link.h" // ESP-NOW transmit leg of the link to Inst. Cluster
|
||||||
#include "modules/diag_probe.h" // On-demand OBD-II requests (`diag` console) - the only CAN transmitter
|
#include "modules/diag_probe.h" // On-demand OBD-II requests (`diag` console) - the only CAN transmitter
|
||||||
#include "modules/ota_update.h" // Manual firmware updates from Gitea releases (`ota` console)
|
#include "modules/ota_update.h" // Manual firmware updates from Gitea releases (`ota` console)
|
||||||
|
#include "modules/link_peer.h" // Inst. Cluster status, pairing, credential handoff, B updates (`link` console)
|
||||||
|
#include "modules/status_overlay.h" // Every screen: Wi-Fi chip top-right, blinking alert banner top-centre
|
||||||
|
#include "modules/diff_locks.h" // Diff-lock inputs DI0 rear / DI1 front via the CH422G (`difflock` console)
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// MINIMAL LVGL + UI SETTINGS + WIFI + UART
|
// MINIMAL LVGL + UI SETTINGS + WIFI + UART
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// This is a minimal setup with:
|
// This is a minimal setup with:
|
||||||
// - LVGL display and touch initialization
|
// - LVGL display and touch initialization
|
||||||
// - Hand-coded Driveline (boot) + Gauge Tuning screens, SquareLine Settings screen
|
// - Hand-coded Driveline (boot), Settings and Gauge Tuning screens
|
||||||
// - WiFi module with async scanning (managed by WiFiManager)
|
// - WiFi: one remembered network, scans on request (WiFiManager)
|
||||||
// - UART data transmission at 5Hz (managed by UARTManager)
|
// - UART data transmission at 5Hz (managed by UARTManager)
|
||||||
// - UI state synchronization (managed by UIStateManager)
|
|
||||||
// - Persistent settings storage (managed by SettingsManager)
|
// - Persistent settings storage (managed by SettingsManager)
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
// External UI element references (from ui_Settings_Screen.c)
|
// `mem`: internal heap, PSRAM, and LVGL's own pool (LV_MEM_SIZE, where every
|
||||||
extern "C" {
|
// widget lives). Takes the LVGL lock with a timeout so a hung UI is reported
|
||||||
extern lv_obj_t *uic_Main_Container;
|
// rather than hanging the console too.
|
||||||
extern lv_obj_t *uic_Toggle_Wifi_Switch;
|
static bool memCommand(const char* line) {
|
||||||
extern lv_obj_t *uic_Toggle_UART_Switch;
|
if (strcmp(line, "mem") != 0) return false;
|
||||||
extern lv_obj_t *uic_Toggle_CAN_Bus_Switch;
|
SerialLock::lock();
|
||||||
}
|
Serial.printf("[mem] internal free %u (largest block %u), PSRAM free %u\n",
|
||||||
|
(unsigned)heap_caps_get_free_size(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT),
|
||||||
|
(unsigned)heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT),
|
||||||
// ============================================================================
|
(unsigned)heap_caps_get_free_size(MALLOC_CAP_SPIRAM));
|
||||||
// EVENT HANDLERS (C linkage for SquareLine Studio UI callbacks)
|
SerialLock::unlock();
|
||||||
// ============================================================================
|
if (!lvgl_port_lock(500)) {
|
||||||
|
Serial.println("[mem] LVGL lock busy > 500 ms - UI task stuck?");
|
||||||
extern "C" {
|
return true;
|
||||||
|
|
||||||
// WiFi-related event handlers (delegated to WiFiManager)
|
|
||||||
void onSelectSSID(lv_event_t *e) {
|
|
||||||
WiFiManager::onSelectSSID(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
// WiFi toggle event handler - delegates to WiFiManager module
|
|
||||||
void onWifiToggle(lv_event_t *e)
|
|
||||||
{
|
|
||||||
// Get the actual widget from the event (safer than global variable)
|
|
||||||
lv_obj_t *target = lv_event_get_target(e);
|
|
||||||
|
|
||||||
// Verify the widget is valid
|
|
||||||
if (target == NULL) {
|
|
||||||
Serial.println("ERROR: WiFi toggle target is NULL!");
|
|
||||||
Serial.flush();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
lv_mem_monitor_t m;
|
||||||
// Check the toggle state
|
lv_mem_monitor(&m);
|
||||||
bool state = lv_obj_has_state(target, LV_STATE_CHECKED);
|
lvgl_port_unlock();
|
||||||
|
SerialLock::lock();
|
||||||
Serial.printf("WiFi Toggle RELEASED - State: %s\n", state ? "ON" : "OFF");
|
Serial.printf("[mem] LVGL pool: used %u of %u B (%u%%), frag %u%%, biggest free %u\n",
|
||||||
Serial.flush();
|
(unsigned)(m.total_size - m.free_size), (unsigned)m.total_size,
|
||||||
|
(unsigned)m.used_pct, (unsigned)m.frag_pct, (unsigned)m.free_biggest_size);
|
||||||
// Save state to NVS for persistence across power cycles
|
SerialLock::unlock();
|
||||||
SettingsManager::saveWiFiState(state);
|
return true;
|
||||||
|
|
||||||
// Delegate to WiFiManager module
|
|
||||||
WiFiManager::onWifiToggle(e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// UART toggle event handler - delegates to UARTManager module
|
// Console lines `cfg` doesn't recognise: diagnostic probe, OTA, Wi-Fi, mem, link, difflock.
|
||||||
void onUARTToggle(lv_event_t *e)
|
|
||||||
{
|
|
||||||
// Get the actual widget from the event (safer than global variable)
|
|
||||||
lv_obj_t *target = lv_event_get_target(e);
|
|
||||||
|
|
||||||
// Verify the widget is valid
|
|
||||||
if (target == NULL) {
|
|
||||||
Serial.println("ERROR: UART toggle target is NULL!");
|
|
||||||
Serial.flush();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check the toggle state
|
|
||||||
bool state = lv_obj_has_state(target, LV_STATE_CHECKED);
|
|
||||||
|
|
||||||
Serial.printf("UART Toggle RELEASED - State: %s\n", state ? "ON" : "OFF");
|
|
||||||
Serial.flush();
|
|
||||||
|
|
||||||
// Save state to NVS for persistence across power cycles
|
|
||||||
SettingsManager::saveUARTState(state);
|
|
||||||
|
|
||||||
// Delegate to UARTManager module
|
|
||||||
UARTManager::onUARTToggle(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
// CAN Bus toggle event handler - delegates to CANDriver module
|
|
||||||
void onCANBusToggle(lv_event_t *e)
|
|
||||||
{
|
|
||||||
CANDriver::onCANToggle(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Debug toggle event handler - delegates to UIStateManager module
|
|
||||||
void onDebugToggle(lv_event_t *e)
|
|
||||||
{
|
|
||||||
UIStateManager::onDebugToggle(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // extern "C"
|
|
||||||
|
|
||||||
// Console lines `cfg` doesn't recognise: diagnostic probe, OTA, Wi-Fi.
|
|
||||||
static bool consoleExtraCommand(const char* line) {
|
static bool consoleExtraCommand(const char* line) {
|
||||||
return DiagProbe::handleCommand(line) || Ota::handleCommand(line) ||
|
return DiagProbe::handleCommand(line) || Ota::handleCommand(line) ||
|
||||||
WiFiManager::handleCommand(line);
|
WiFiManager::handleCommand(line) || memCommand(line) ||
|
||||||
|
PerfMon::handleCommand(line) || LinkPeer::handleCommand(line) ||
|
||||||
|
DiffLocks::handleCommand(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -144,6 +91,7 @@ void setup()
|
|||||||
ESP_LOGI("MAIN", "Initializing display and UI...");
|
ESP_LOGI("MAIN", "Initializing display and UI...");
|
||||||
DisplayInit::init();
|
DisplayInit::init();
|
||||||
ESP_LOGI("MAIN", "Display init COMPLETED!");
|
ESP_LOGI("MAIN", "Display init COMPLETED!");
|
||||||
|
StatusOverlay::init(); // Wi-Fi chip + alert banner on lv_layer_top(), above every screen
|
||||||
|
|
||||||
// Initialize Settings Manager
|
// Initialize Settings Manager
|
||||||
ESP_LOGI("MAIN", "Initializing Settings Manager...");
|
ESP_LOGI("MAIN", "Initializing Settings Manager...");
|
||||||
@@ -153,6 +101,7 @@ void setup()
|
|||||||
Tunables::init();
|
Tunables::init();
|
||||||
DiagProbe::init();
|
DiagProbe::init();
|
||||||
Tunables::setExtraCommandHandler(consoleExtraCommand);
|
Tunables::setExtraCommandHandler(consoleExtraCommand);
|
||||||
|
PerfMon::init();
|
||||||
|
|
||||||
// Load saved switch states from NVS
|
// Load saved switch states from NVS
|
||||||
ESP_LOGI("MAIN", "Loading saved switch states from NVS...");
|
ESP_LOGI("MAIN", "Loading saved switch states from NVS...");
|
||||||
@@ -160,6 +109,7 @@ void setup()
|
|||||||
bool saved_uart_state = SettingsManager::loadUARTState();
|
bool saved_uart_state = SettingsManager::loadUARTState();
|
||||||
bool saved_can_state = SettingsManager::loadCANState();
|
bool saved_can_state = SettingsManager::loadCANState();
|
||||||
bool saved_debug_state = SettingsManager::loadDebugState();
|
bool saved_debug_state = SettingsManager::loadDebugState();
|
||||||
|
DiffLocks::init(SettingsManager::loadDiffLockState(), SettingsManager::loadDiffLockInvert()); // CH422G bus is up since DisplayInit
|
||||||
ESP_LOGI("MAIN", "Saved states loaded (UI will be updated when Settings screen opens)");
|
ESP_LOGI("MAIN", "Saved states loaded (UI will be updated when Settings screen opens)");
|
||||||
|
|
||||||
// Initialize UI State Manager
|
// Initialize UI State Manager
|
||||||
@@ -173,6 +123,7 @@ void setup()
|
|||||||
// ESP-NOW transmit leg (needs the radio in STA mode, which WiFiManager keeps)
|
// ESP-NOW transmit leg (needs the radio in STA mode, which WiFiManager keeps)
|
||||||
ESP_LOGI("MAIN", "Initializing ESP-NOW link...");
|
ESP_LOGI("MAIN", "Initializing ESP-NOW link...");
|
||||||
EspNowLink::init();
|
EspNowLink::init();
|
||||||
|
LinkPeer::init(); // B's STATUS frames, pairing key, credential handoff
|
||||||
|
|
||||||
// Initialize UART subsystem using UARTManager module
|
// Initialize UART subsystem using UARTManager module
|
||||||
ESP_LOGI("MAIN", "Initializing UART subsystem...");
|
ESP_LOGI("MAIN", "Initializing UART subsystem...");
|
||||||
@@ -194,8 +145,7 @@ void setup()
|
|||||||
ESP_LOGI("MAIN", "- Link: UART1 TX GPIO44 (RS485 A/B) + ESP-NOW broadcast, protocol v%u", PACKET_VERSION);
|
ESP_LOGI("MAIN", "- Link: UART1 TX GPIO44 (RS485 A/B) + ESP-NOW broadcast, protocol v%u", PACKET_VERSION);
|
||||||
ESP_LOGI("MAIN", "- Console: type 'cfg help' to tune the Patrol gauge outputs");
|
ESP_LOGI("MAIN", "- Console: type 'cfg help' to tune the Patrol gauge outputs");
|
||||||
ESP_LOGI("MAIN", "- Screens: Driveline (boot) <- left: Settings | right: Gauge tuning ->");
|
ESP_LOGI("MAIN", "- Screens: Driveline (boot) <- left: Settings | right: Gauge tuning ->");
|
||||||
ESP_LOGI("MAIN", "- Settings screen has WiFi and UART toggles");
|
ESP_LOGI("MAIN", "- Settings: Wi-Fi (remembered network), Updates, System");
|
||||||
ESP_LOGI("MAIN", "- WiFi scan updates every 10 seconds when enabled");
|
|
||||||
ESP_LOGI("MAIN", "- UART transmits at 5Hz (200ms) when enabled");
|
ESP_LOGI("MAIN", "- UART transmits at 5Hz (200ms) when enabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,20 +161,19 @@ void loop()
|
|||||||
last_print = millis();
|
last_print = millis();
|
||||||
}
|
}
|
||||||
|
|
||||||
// LVGL task runs automatically in separate task
|
// LVGL renders in its own task; the screen ticks below only refresh values.
|
||||||
// Keep loop() minimal and empty to avoid interfering with LVGL rendering
|
|
||||||
|
|
||||||
// Continuously sync UI switches with actual service states
|
|
||||||
// (Settings screen gets destroyed/recreated when swiping)
|
|
||||||
UIStateManager::applySavedStatesToUI();
|
|
||||||
|
|
||||||
// Serial console: gauge tunables (cfg ...), diagnostic probe (diag ...), updates (ota ...)
|
// Serial console: gauge tunables (cfg ...), diagnostic probe (diag ...), updates (ota ...)
|
||||||
Tunables::pollSerial();
|
Tunables::pollSerial();
|
||||||
|
PerfMon::tick();
|
||||||
DiagProbe::tick();
|
DiagProbe::tick();
|
||||||
Ota::tick(); // confirms a freshly installed image after healthy uptime
|
Ota::tick(); // confirms a freshly installed image after healthy uptime
|
||||||
|
LinkPeer::tick(); // Inst. Cluster heard/lost, credential sync
|
||||||
|
DiffLocks::tick(); // DI0/DI1 at 4 Hz, only when the Settings switch is on
|
||||||
|
|
||||||
DrivelineScreen::tick();
|
DrivelineScreen::tick();
|
||||||
TuningScreen::tick();
|
TuningScreen::tick();
|
||||||
|
SettingsScreen::tick();
|
||||||
|
StatusOverlay::tick();
|
||||||
|
|
||||||
delay(100); // Check frequently to catch screen changes quickly
|
delay(100); // Check frequently to catch screen changes quickly
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,163 @@
|
|||||||
|
/*
|
||||||
|
* Differential lock inputs - see diff_locks.h
|
||||||
|
*
|
||||||
|
* Schematic (V1.2, sheet 1): DINx -> PC814 LED -> 3.6 kOhm -> DI_COM. The
|
||||||
|
* optocoupler's transistor pulls DIx (4.7 kOhm to 3V3) LOW while current flows,
|
||||||
|
* so a LOCKED diff reads 0 on its EXIO bit. The PC814 LED is bidirectional:
|
||||||
|
* +12 V on DINx with DI_COM on ground is the "PNP / high-level" wiring.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "diff_locks.h"
|
||||||
|
#include "settings_manager.h"
|
||||||
|
#include "serial_lock.h"
|
||||||
|
#include "display/lvgl_v8_port.h"
|
||||||
|
#include <driver/i2c.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
namespace DiffLocks {
|
||||||
|
|
||||||
|
// CH422G on the panel library's I2C host 0. Its "registers" are I2C addresses.
|
||||||
|
static const i2c_port_t CH422G_PORT = I2C_NUM_0;
|
||||||
|
static const uint8_t ADDR_WR_SET = 0x24; // system parameter byte
|
||||||
|
static const uint8_t ADDR_RD_IO = 0x26; // IO0-7 pin levels
|
||||||
|
// WR_SET as the board config leaves it (ESP_PANEL_BOARD_EXPANDER_POST_BEGIN_FUNCTION:
|
||||||
|
// enableAllIO_Output -> IO_OE only; OC push-pull, no sleep). Input = IO_OE cleared.
|
||||||
|
static const uint8_t WR_SET_OUTPUT = 0x01;
|
||||||
|
static const uint8_t WR_SET_INPUT = 0x00;
|
||||||
|
|
||||||
|
static const uint8_t BIT_REAR = 1 << 0; // DI0 = EXIO0
|
||||||
|
static const uint8_t BIT_FRONT = 1 << 5; // DI1 = EXIO5
|
||||||
|
|
||||||
|
static const uint32_t POLL_MS = 250;
|
||||||
|
static const uint8_t FAULT_AFTER = 3; // failed reads in a row
|
||||||
|
|
||||||
|
static bool g_enabled = false;
|
||||||
|
static bool g_inverted = false;
|
||||||
|
static bool g_rear = false, g_front = false; // debounced
|
||||||
|
static bool g_have_state = false;
|
||||||
|
static uint8_t g_last_raw = 0xFF;
|
||||||
|
static bool g_have_raw = false;
|
||||||
|
static uint8_t g_fail_run = 0;
|
||||||
|
static uint32_t g_reads = 0, g_fails = 0;
|
||||||
|
static uint32_t g_last_poll = 0;
|
||||||
|
|
||||||
|
static void print(const char* fmt, ...) {
|
||||||
|
char buf[160];
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
SerialLock::lock();
|
||||||
|
Serial.println(buf);
|
||||||
|
SerialLock::unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
static esp_err_t writeSet(uint8_t v) {
|
||||||
|
return i2c_master_write_to_device(CH422G_PORT, ADDR_WR_SET, &v, 1, pdMS_TO_TICKS(10));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One raw read of IO0-7. The bank is an input only between the two WR_SET
|
||||||
|
* writes (three short I2C transactions); the output is restored even when the
|
||||||
|
* read fails, and retried, because touch reset, backlight and LCD reset live on
|
||||||
|
* the same bank. The caller holds the LVGL lock, so no touch read (same bus)
|
||||||
|
* can land in the middle.
|
||||||
|
*/
|
||||||
|
static bool readBank(uint8_t* out) {
|
||||||
|
if (writeSet(WR_SET_INPUT) != ESP_OK) {
|
||||||
|
writeSet(WR_SET_OUTPUT); // a half-done write: make sure we are back
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
esp_err_t r = i2c_master_read_from_device(CH422G_PORT, ADDR_RD_IO, out, 1, pdMS_TO_TICKS(10));
|
||||||
|
for (int i = 0; i < 3 && writeSet(WR_SET_OUTPUT) != ESP_OK; i++) {}
|
||||||
|
return r == ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void init(bool enabled, bool inverted) {
|
||||||
|
g_enabled = enabled;
|
||||||
|
g_inverted = inverted;
|
||||||
|
print("[difflock] %s (DI0 = rear, DI1 = front, %s)", enabled ? "ON" : "OFF - Settings > System to enable",
|
||||||
|
inverted ? "INVERTED: no current = locked" : "current = locked");
|
||||||
|
}
|
||||||
|
|
||||||
|
void setEnabled(bool enabled) {
|
||||||
|
if (enabled == g_enabled) return;
|
||||||
|
g_enabled = enabled;
|
||||||
|
g_have_state = g_have_raw = false;
|
||||||
|
g_rear = g_front = false;
|
||||||
|
g_fail_run = 0;
|
||||||
|
SettingsManager::saveDiffLockState(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setInverted(bool inverted) {
|
||||||
|
if (inverted == g_inverted) return;
|
||||||
|
g_inverted = inverted;
|
||||||
|
g_have_state = g_have_raw = false; // re-evaluate from the next two reads
|
||||||
|
SettingsManager::saveDiffLockInvert(inverted);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isInverted() { return g_inverted; }
|
||||||
|
bool isEnabled() { return g_enabled; }
|
||||||
|
bool isValid() { return g_enabled && g_have_state && g_fail_run < FAULT_AFTER; }
|
||||||
|
bool rearLocked() { return isValid() && g_rear; }
|
||||||
|
bool frontLocked() { return isValid() && g_front; }
|
||||||
|
|
||||||
|
void tick() {
|
||||||
|
if (!g_enabled || millis() - g_last_poll < POLL_MS) return;
|
||||||
|
g_last_poll = millis();
|
||||||
|
|
||||||
|
if (!lvgl_port_lock(100)) return; // UI busy: try again next poll
|
||||||
|
uint8_t raw = 0xFF;
|
||||||
|
bool ok = readBank(&raw);
|
||||||
|
lvgl_port_unlock();
|
||||||
|
|
||||||
|
g_reads++;
|
||||||
|
if (!ok) {
|
||||||
|
g_fails++;
|
||||||
|
if (g_fail_run < 255) g_fail_run++;
|
||||||
|
if (g_fail_run == FAULT_AFTER) print("[difflock] CH422G read failing - lock states unknown");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
g_fail_run = 0;
|
||||||
|
|
||||||
|
// Accept a state only when two reads in a row agree (<= 0.5 s latency).
|
||||||
|
uint8_t bits = raw & (BIT_REAR | BIT_FRONT);
|
||||||
|
if (g_have_raw && bits == (g_last_raw & (BIT_REAR | BIT_FRONT))) {
|
||||||
|
// opto conducting = pin low; that is "locked" unless the polarity is inverted
|
||||||
|
bool rear = !(bits & BIT_REAR) != g_inverted;
|
||||||
|
bool front = !(bits & BIT_FRONT) != g_inverted;
|
||||||
|
if (!g_have_state || rear != g_rear || front != g_front) {
|
||||||
|
g_rear = rear;
|
||||||
|
g_front = front;
|
||||||
|
g_have_state = true;
|
||||||
|
print("[difflock] rear %s, front %s%s", rear ? "LOCKED" : "open", front ? "LOCKED" : "open",
|
||||||
|
(front && !rear) ? " (front without rear - check the DI0 wiring)" : "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_last_raw = raw;
|
||||||
|
g_have_raw = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool handleCommand(const char* line) {
|
||||||
|
if (strncmp(line, "difflock", 8) != 0 || (line[8] != 0 && line[8] != ' ')) return false;
|
||||||
|
const char* a = line + 8;
|
||||||
|
while (*a == ' ') a++;
|
||||||
|
|
||||||
|
if (!strcmp(a, "on")) { setEnabled(true); print("[difflock] ON (saved)"); return true; }
|
||||||
|
if (!strcmp(a, "off")) { setEnabled(false); print("[difflock] OFF (saved)"); return true; }
|
||||||
|
if (!strcmp(a, "invert on")) { setInverted(true); print("[difflock] INVERTED: no current = locked (saved)"); return true; }
|
||||||
|
if (!strcmp(a, "invert off")) { setInverted(false); print("[difflock] normal: current (+12 V) = locked (saved)"); return true; }
|
||||||
|
if (!*a || !strcmp(a, "status")) {
|
||||||
|
if (!g_enabled) { print("[difflock] OFF - inputs not read ('difflock on' or Settings > System)"); return true; }
|
||||||
|
print("[difflock] rear %s, front %s | %s | raw IO0-7 0x%02X | %lu reads, %lu failed%s",
|
||||||
|
!isValid() ? "?" : g_rear ? "LOCKED" : "open",
|
||||||
|
!isValid() ? "?" : g_front ? "LOCKED" : "open",
|
||||||
|
g_inverted ? "inverted" : "normal", g_last_raw, (unsigned long)g_reads, (unsigned long)g_fails,
|
||||||
|
g_fail_run >= FAULT_AFTER ? " | READ FAULT" : "");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
print("[difflock] usage: difflock status | on | off | invert on|off (DI0 = rear, DI1 = front)");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace DiffLocks
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Differential lock inputs - DI0 = rear, DI1 = front
|
||||||
|
*
|
||||||
|
* The Patrol's lock switches put +12 V on a wire while a diff is locked. Those
|
||||||
|
* wires go to the board's isolated inputs (PC814 optocouplers, 5-36 V, DI_COM to
|
||||||
|
* vehicle ground). The inputs reach the ESP32 only through the CH422G expander
|
||||||
|
* (DI0 = EXIO0, DI1 = EXIO5), whose IO0-7 are all-in or all-out as ONE bank - and
|
||||||
|
* the same bank drives touch reset, backlight enable and LCD reset. So each read
|
||||||
|
* switches the bank to input for ~0.1 ms and straight back (output latches are
|
||||||
|
* kept by the chip). That is why the whole feature sits behind a Settings switch,
|
||||||
|
* default OFF: a board without diff-lock wiring never touches the bank.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
namespace DiffLocks {
|
||||||
|
|
||||||
|
/** Call once after DisplayInit (the CH422G's I2C bus is installed by the panel library). */
|
||||||
|
void init(bool enabled, bool inverted);
|
||||||
|
|
||||||
|
/** Settings switch / `difflock on|off`. Saved to NVS (SettingsManager). */
|
||||||
|
void setEnabled(bool enabled);
|
||||||
|
bool isEnabled();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Polarity. Normal: current through the input (+12 V on DINx) = locked.
|
||||||
|
* Inverted: NO current = locked - the Patrol's ground-switched lock lamps give
|
||||||
|
* 12 V through the lamp while unlocked and 0 V once the diff switch closes
|
||||||
|
* (seen in the car, 2026-09-29). Saved to NVS.
|
||||||
|
*/
|
||||||
|
void setInverted(bool inverted);
|
||||||
|
bool isInverted();
|
||||||
|
|
||||||
|
/** Poll the inputs (4 Hz, debounced over two reads). Call from loop(). */
|
||||||
|
void tick();
|
||||||
|
|
||||||
|
/** Enabled AND the last reads succeeded - otherwise the lock states mean nothing. */
|
||||||
|
bool isValid();
|
||||||
|
bool rearLocked();
|
||||||
|
bool frontLocked();
|
||||||
|
|
||||||
|
/** `difflock status | on | off | invert on|off`. Returns true if the line was ours. */
|
||||||
|
bool handleCommand(const char* line);
|
||||||
|
|
||||||
|
} // namespace DiffLocks
|
||||||
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
#include "display_init.h"
|
#include "display_init.h"
|
||||||
#include "display/lvgl_v8_port.h"
|
#include "display/lvgl_v8_port.h"
|
||||||
#include "ui/ui.h"
|
|
||||||
#include "driveline_screen.h"
|
#include "driveline_screen.h"
|
||||||
#include "config/ota_config.h" // FW_VERSION
|
#include "config/ota_config.h" // FW_VERSION
|
||||||
|
|
||||||
@@ -90,18 +89,20 @@ DisplayObjects init() {
|
|||||||
Serial.println("[DisplayInit] Step 11: LVGL initialized successfully!");
|
Serial.println("[DisplayInit] Step 11: LVGL initialized successfully!");
|
||||||
Serial.flush();
|
Serial.flush();
|
||||||
|
|
||||||
// Step 12-13: Load SquareLine Studio UI
|
// Step 12-13: Theme + boot screen
|
||||||
Serial.println("[DisplayInit] Step 12: Loading SquareLine Studio UI...");
|
Serial.println("[DisplayInit] Step 12: Loading UI...");
|
||||||
lvgl_port_lock(-1);
|
lvgl_port_lock(-1);
|
||||||
ui_init(); // Initialize the SquareLine Studio generated UI
|
// Dark default theme, blue primary. The hand-coded screens override most
|
||||||
// Note: onSelectSSID event handler is registered in ui_Settings_Screen.c
|
// styles, but the keyboard, dialogs, text areas, switches and sliders take
|
||||||
// Boot screen: the hand-coded Driveline screen. ui_init() only loads an
|
// their base look from it.
|
||||||
// empty placeholder now (the SquareLine Home screen was removed 2026-09-21);
|
lv_disp_t* disp = lv_disp_get_default();
|
||||||
// swap while the backlight is still off so there's no flash.
|
lv_disp_set_theme(disp, lv_theme_default_init(disp, lv_palette_main(LV_PALETTE_BLUE),
|
||||||
|
lv_palette_main(LV_PALETTE_RED), true, LV_FONT_DEFAULT));
|
||||||
|
// Boot screen, loaded while the backlight is still off so there's no flash.
|
||||||
DrivelineScreen::show();
|
DrivelineScreen::show();
|
||||||
createVersionLabel();
|
createVersionLabel();
|
||||||
lvgl_port_unlock();
|
lvgl_port_unlock();
|
||||||
Serial.println("[DisplayInit] Step 13: SquareLine UI loaded successfully!");
|
Serial.println("[DisplayInit] Step 13: UI loaded");
|
||||||
|
|
||||||
// Small delay to ensure UI is rendered
|
// Small delay to ensure UI is rendered
|
||||||
delay(100);
|
delay(100);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
* Handles hardware-specific initialization for the Waveshare ESP32-S3-Touch-LCD-5B:
|
* Handles hardware-specific initialization for the Waveshare ESP32-S3-Touch-LCD-5B:
|
||||||
* - Board initialization (LCD panel, touch controller)
|
* - Board initialization (LCD panel, touch controller)
|
||||||
* - LVGL initialization and configuration
|
* - LVGL initialization and configuration
|
||||||
* - SquareLine Studio UI loading
|
* - LVGL theme and the boot (Driveline) screen
|
||||||
* - Backlight control to prevent white flash during startup
|
* - Backlight control to prevent white flash during startup
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ struct DisplayObjects {
|
|||||||
* 3. Initialize backlight (off initially to prevent white flash)
|
* 3. Initialize backlight (off initially to prevent white flash)
|
||||||
* 4. Start the board
|
* 4. Start the board
|
||||||
* 5. Initialize LVGL porting layer
|
* 5. Initialize LVGL porting layer
|
||||||
* 6. Load SquareLine Studio UI
|
* 6. Set the LVGL theme and show the Driveline screen
|
||||||
* 7. Turn on backlight after UI is ready
|
* 7. Turn on backlight after UI is ready
|
||||||
*
|
*
|
||||||
* @return DisplayObjects containing board and backlight pointers
|
* @return DisplayObjects containing board and backlight pointers
|
||||||
|
|||||||
@@ -4,15 +4,15 @@
|
|||||||
|
|
||||||
#include "driveline_screen.h"
|
#include "driveline_screen.h"
|
||||||
#include "uart_manager.h"
|
#include "uart_manager.h"
|
||||||
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
#include "display/lvgl_v8_port.h"
|
#include "display/lvgl_v8_port.h"
|
||||||
#include "drivers/can_driver.h"
|
#include "drivers/can_driver.h"
|
||||||
#include "tuning_screen.h"
|
#include "tuning_screen.h"
|
||||||
|
#include "settings_screen.h"
|
||||||
|
#include "diff_locks.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
#include "ui.h"
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace DrivelineScreen {
|
namespace DrivelineScreen {
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -26,6 +26,8 @@ namespace DrivelineScreen {
|
|||||||
#define COL_ACCENT lv_color_hex(0x3DA9FC)
|
#define COL_ACCENT lv_color_hex(0x3DA9FC)
|
||||||
#define COL_OK lv_color_hex(0x3DD68C)
|
#define COL_OK lv_color_hex(0x3DD68C)
|
||||||
#define COL_WARN lv_color_hex(0xE5484D)
|
#define COL_WARN lv_color_hex(0xE5484D)
|
||||||
|
#define COL_ALERT lv_color_hex(0xFF3B30) // threshold crossed: value + title
|
||||||
|
#define COL_AMBER lv_color_hex(0xF5A524)
|
||||||
|
|
||||||
#define RPM_MAX 5000 // M57N redline is ~4500; a little headroom
|
#define RPM_MAX 5000 // M57N redline is ~4500; a little headroom
|
||||||
|
|
||||||
@@ -38,6 +40,8 @@ static lv_obj_t* g_gear_lbl = NULL;
|
|||||||
static lv_obj_t* g_gear_ring = NULL;
|
static lv_obj_t* g_gear_ring = NULL;
|
||||||
static lv_obj_t* g_coolant_lbl = NULL;
|
static lv_obj_t* g_coolant_lbl = NULL;
|
||||||
static lv_obj_t* g_gearbox_lbl = NULL;
|
static lv_obj_t* g_gearbox_lbl = NULL;
|
||||||
|
static lv_obj_t* g_coolant_title = NULL;
|
||||||
|
static lv_obj_t* g_gearbox_title = NULL;
|
||||||
static lv_obj_t* g_rpm_bar = NULL;
|
static lv_obj_t* g_rpm_bar = NULL;
|
||||||
static lv_obj_t* g_rpm_lbl = NULL;
|
static lv_obj_t* g_rpm_lbl = NULL;
|
||||||
static lv_obj_t* g_torque_lbl = NULL;
|
static lv_obj_t* g_torque_lbl = NULL;
|
||||||
@@ -47,7 +51,7 @@ static lv_obj_t* g_ign_chip = NULL;
|
|||||||
static lv_obj_t* g_eng_chip = NULL;
|
static lv_obj_t* g_eng_chip = NULL;
|
||||||
static lv_obj_t* g_clutch_chip = NULL;
|
static lv_obj_t* g_clutch_chip = NULL;
|
||||||
static lv_obj_t* g_cool_chip = NULL;
|
static lv_obj_t* g_cool_chip = NULL;
|
||||||
static lv_obj_t* g_mismatch_lbl = NULL;
|
static lv_obj_t* g_diff_box = NULL; // top-right: chassis top view, locked axles lit
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// PRIVATE HELPERS
|
// PRIVATE HELPERS
|
||||||
@@ -70,12 +74,180 @@ static lv_obj_t* makeChip(lv_obj_t* parent, const char* text) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set a chip's text and colour in one go.
|
* @brief lv_label_set_text() only if the text differs. lv_label_set_text()
|
||||||
|
* re-lays-out and invalidates the label even when the string is the
|
||||||
|
* same, and this screen refreshes at 10 Hz - with constant data that was
|
||||||
|
* ~40 kpx redrawn 10x a second for nothing, a third of core 1 and 50 ms/s
|
||||||
|
* of PSRAM writes (perf baseline 2026-09-27).
|
||||||
|
*/
|
||||||
|
static void setText(lv_obj_t* lbl, const char* text) {
|
||||||
|
if (lbl == NULL) return;
|
||||||
|
const char* cur = lv_label_get_text(lbl);
|
||||||
|
if (cur != NULL && strcmp(cur, text) == 0) return;
|
||||||
|
lv_label_set_text(lbl, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Text colour, written only on change (a style write invalidates regardless). */
|
||||||
|
static void setColour(lv_obj_t* o, lv_color_t colour) {
|
||||||
|
if (o == NULL) return;
|
||||||
|
if (lv_color_to32(lv_obj_get_style_text_color(o, 0)) != lv_color_to32(colour)) {
|
||||||
|
lv_obj_set_style_text_color(o, colour, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Ring border colour, written only on change. */
|
||||||
|
static void setRing(lv_color_t colour) {
|
||||||
|
if (lv_color_to32(lv_obj_get_style_border_color(g_gear_ring, 0)) != lv_color_to32(colour)) {
|
||||||
|
lv_obj_set_style_border_color(g_gear_ring, colour, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set a chip's text and colour, touching the object only on a change
|
||||||
|
* (a style write invalidates the object even for an identical value).
|
||||||
*/
|
*/
|
||||||
static void setChip(lv_obj_t* chip, const char* text, lv_color_t colour) {
|
static void setChip(lv_obj_t* chip, const char* text, lv_color_t colour) {
|
||||||
if (chip == NULL) return;
|
if (chip == NULL) return;
|
||||||
lv_label_set_text(chip, text);
|
setText(chip, text);
|
||||||
lv_obj_set_style_text_color(chip, colour, 0);
|
if (lv_color_to32(lv_obj_get_style_text_color(chip, 0)) != lv_color_to32(colour)) {
|
||||||
|
lv_obj_set_style_text_color(chip, colour, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- diff-lock drawing ------------------------------------------------------
|
||||||
|
// A top view of the chassis, after the user's sketch (front up): steered front
|
||||||
|
// tyres on the front axle, prop shaft, rear axle on straight tyres. All four
|
||||||
|
// tyres are the same square-cornered 24 x 76 rectangle. A locked axle lights up:
|
||||||
|
// axle, tyres filled, and an X on its diff. Geometry is in sketch pixels, scaled
|
||||||
|
// by DL_S. Wheelbase 151 = the sketch's 189 shortened by 20 % (user, 2026-09-29).
|
||||||
|
|
||||||
|
static const float DL_S = 0.46f; // sketch -> screen
|
||||||
|
static const lv_coord_t DL_BOX_W = 110; // hugs the drawing (dl(DL_W) = 98)
|
||||||
|
static const float DL_W = 212; // sketch width the drawing is centred in
|
||||||
|
static const float DL_SHAFT_X = 106;
|
||||||
|
static const float DL_FRONT_Y = 45;
|
||||||
|
static const float DL_REAR_Y = DL_FRONT_Y + 151;
|
||||||
|
static const float DL_TRACK_L = 45, DL_TRACK_R = 167; // tyre centres, symmetric about the shaft
|
||||||
|
static const float DL_TYRE_W = 24, DL_TYRE_L = 76;
|
||||||
|
static const float DL_STEER = 25; // front tyres, degrees, top leaning right
|
||||||
|
|
||||||
|
static lv_coord_t dl(float v) { return (lv_coord_t)lroundf(v * DL_S); }
|
||||||
|
|
||||||
|
/** Sketch point -> box point (drawing centred horizontally in the box). */
|
||||||
|
static lv_point_t dlPoint(float x, float y) {
|
||||||
|
lv_point_t pt;
|
||||||
|
pt.x = (DL_BOX_W - dl(DL_W)) / 2 + dl(x);
|
||||||
|
pt.y = dl(y) + 2;
|
||||||
|
return pt;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct TyreView {
|
||||||
|
lv_obj_t* outline;
|
||||||
|
lv_obj_t* fill; // shown only while the axle is locked
|
||||||
|
};
|
||||||
|
|
||||||
|
struct AxleView {
|
||||||
|
lv_obj_t* axle;
|
||||||
|
TyreView tyre[2];
|
||||||
|
lv_obj_t* cross[2]; // the X on the diff, shown only while locked
|
||||||
|
};
|
||||||
|
static AxleView g_front_axle, g_rear_axle;
|
||||||
|
|
||||||
|
// lv_line keeps a pointer to its points: they must outlive the objects.
|
||||||
|
static lv_point_t g_pts_shaft[2];
|
||||||
|
static lv_point_t g_pts_axle[2][2]; // [front, rear][end]
|
||||||
|
static lv_point_t g_pts_tyre[2][2][5]; // [front, rear][left, right] closed outline
|
||||||
|
static lv_point_t g_pts_fill[2][2][2]; // [front, rear][left, right] centre line of the fill
|
||||||
|
static lv_point_t g_pts_cross[2][2][2]; // [front, rear][stroke][end]
|
||||||
|
|
||||||
|
static lv_obj_t* makeLine(lv_obj_t* parent, lv_point_t* pts, uint16_t n, lv_coord_t width, bool rounded) {
|
||||||
|
lv_obj_t* l = lv_line_create(parent);
|
||||||
|
lv_line_set_points(l, pts, n);
|
||||||
|
lv_obj_set_style_line_width(l, width, 0);
|
||||||
|
lv_obj_set_style_line_rounded(l, rounded, 0);
|
||||||
|
lv_obj_set_style_line_color(l, COL_MUTED, 0);
|
||||||
|
lv_obj_clear_flag(l, LV_OBJ_FLAG_CLICKABLE);
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A tyre centred on (cx, cy), `steer` degrees from straight (top leaning right).
|
||||||
|
* The fill is ONE line as wide as the tyre with square ends, which is exactly
|
||||||
|
* the filled rectangle, rotated or not (LVGL 8 cannot rotate a plain box).
|
||||||
|
*/
|
||||||
|
static TyreView makeTyre(lv_obj_t* parent, lv_point_t* outline, lv_point_t* fill,
|
||||||
|
float cx, float cy, float steer) {
|
||||||
|
const float a = DL_TYRE_W / 2, b = DL_TYRE_L / 2, t = steer * (float)M_PI / 180.0f;
|
||||||
|
const float ux = sinf(t), uy = -cosf(t); // long axis, towards the top
|
||||||
|
const float vx = cosf(t), vy = sinf(t); // short axis
|
||||||
|
const float k[4][2] = {{b, a}, {b, -a}, {-b, -a}, {-b, a}};
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
outline[i] = dlPoint(cx + k[i][0] * ux + k[i][1] * vx, cy + k[i][0] * uy + k[i][1] * vy);
|
||||||
|
}
|
||||||
|
outline[4] = outline[0];
|
||||||
|
fill[0] = dlPoint(cx + b * ux, cy + b * uy);
|
||||||
|
fill[1] = dlPoint(cx - b * ux, cy - b * uy);
|
||||||
|
|
||||||
|
TyreView v;
|
||||||
|
v.fill = makeLine(parent, fill, 2, dl(DL_TYRE_W), false);
|
||||||
|
lv_obj_add_flag(v.fill, LV_OBJ_FLAG_HIDDEN);
|
||||||
|
v.outline = makeLine(parent, outline, 5, 2, true); // 2 px rounded joins read as square corners
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The X on a diff at (cx, cy); idx 0 = front, 1 = rear. */
|
||||||
|
static void diffCross(lv_obj_t* parent, AxleView& a, int idx, float cx, float cy) {
|
||||||
|
const float r = 16;
|
||||||
|
g_pts_cross[idx][0][0] = dlPoint(cx - r, cy - r); g_pts_cross[idx][0][1] = dlPoint(cx + r, cy + r);
|
||||||
|
g_pts_cross[idx][1][0] = dlPoint(cx + r, cy - r); g_pts_cross[idx][1][1] = dlPoint(cx - r, cy + r);
|
||||||
|
for (int k = 0; k < 2; k++) {
|
||||||
|
a.cross[k] = makeLine(parent, g_pts_cross[idx][k], 2, 4, true);
|
||||||
|
lv_obj_add_flag(a.cross[k], LV_OBJ_FLAG_HIDDEN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Line colour, written only on change. */
|
||||||
|
static void setPartColour(lv_obj_t* o, lv_color_t c) {
|
||||||
|
if (lv_color_to32(lv_obj_get_style_line_color(o, 0)) != lv_color_to32(c)) {
|
||||||
|
lv_obj_set_style_line_color(o, c, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setHidden(lv_obj_t* o, bool hidden) {
|
||||||
|
if (lv_obj_has_flag(o, LV_OBJ_FLAG_HIDDEN) == hidden) return;
|
||||||
|
if (hidden) lv_obj_add_flag(o, LV_OBJ_FLAG_HIDDEN);
|
||||||
|
else lv_obj_clear_flag(o, LV_OBJ_FLAG_HIDDEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setAxle(AxleView& a, bool locked, lv_color_t colour) {
|
||||||
|
lv_color_t c = locked ? colour : COL_MUTED;
|
||||||
|
setPartColour(a.axle, c);
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
setPartColour(a.tyre[i].outline, c);
|
||||||
|
setPartColour(a.tyre[i].fill, c);
|
||||||
|
setHidden(a.tyre[i].fill, !locked);
|
||||||
|
setPartColour(a.cross[i], c);
|
||||||
|
setHidden(a.cross[i], !locked);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Diff locks, from the isolated inputs (not CAN - shown with CAN off too).
|
||||||
|
* Locked axle = amber. The front can only lock after the rear, so FRONT
|
||||||
|
* without REAR is a wiring/switch fault and shows red.
|
||||||
|
*/
|
||||||
|
static void refreshDiffLocks() {
|
||||||
|
bool on = DiffLocks::isEnabled();
|
||||||
|
setHidden(g_diff_box, !on);
|
||||||
|
if (!on) return;
|
||||||
|
if (!DiffLocks::isValid()) {
|
||||||
|
setAxle(g_front_axle, false, COL_MUTED);
|
||||||
|
setAxle(g_rear_axle, false, COL_MUTED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
bool rear = DiffLocks::rearLocked(), front = DiffLocks::frontLocked();
|
||||||
|
setAxle(g_rear_axle, rear, COL_AMBER);
|
||||||
|
setAxle(g_front_axle, front, rear ? COL_AMBER : COL_ALERT); // no caption: the drawing says it all (user)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -137,18 +309,15 @@ static lv_obj_t* makeStat(lv_obj_t* parent, const char* title,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Gesture handler on OUR screen: swipe LEFT opens Settings (SquareLine),
|
* @brief Gesture handler: swipe LEFT opens Settings, swipe RIGHT the Gauge
|
||||||
* swipe RIGHT continues to the Gauge Tuning screen.
|
* Tuning screen (both hand-coded, instant switches).
|
||||||
*/
|
*/
|
||||||
static void onScreenGesture(lv_event_t* e) {
|
static void onScreenGesture(lv_event_t* e) {
|
||||||
if (lv_event_get_code(e) != LV_EVENT_GESTURE) return;
|
if (lv_event_get_code(e) != LV_EVENT_GESTURE) return;
|
||||||
lv_dir_t dir = lv_indev_get_gesture_dir(lv_indev_get_act());
|
lv_dir_t dir = lv_indev_get_gesture_dir(lv_indev_get_act());
|
||||||
if (dir == LV_DIR_LEFT) {
|
if (dir == LV_DIR_LEFT) {
|
||||||
lv_indev_wait_release(lv_indev_get_act());
|
lv_indev_wait_release(lv_indev_get_act());
|
||||||
// No transition animation: a full-screen fade is re-rendered and blended
|
SettingsScreen::show();
|
||||||
// in software every frame and stutters on this 1024x600 panel.
|
|
||||||
_ui_screen_change(&ui_Settings_Screen, LV_SCR_LOAD_ANIM_NONE, 0, 0,
|
|
||||||
&ui_Settings_Screen_screen_init);
|
|
||||||
} else if (dir == LV_DIR_RIGHT) {
|
} else if (dir == LV_DIR_RIGHT) {
|
||||||
lv_indev_wait_release(lv_indev_get_act());
|
lv_indev_wait_release(lv_indev_get_act());
|
||||||
TuningScreen::show();
|
TuningScreen::show();
|
||||||
@@ -172,20 +341,48 @@ static void build() {
|
|||||||
lv_obj_set_size(bar, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
|
lv_obj_set_size(bar, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
|
||||||
lv_obj_set_flex_flow(bar, LV_FLEX_FLOW_ROW);
|
lv_obj_set_flex_flow(bar, LV_FLEX_FLOW_ROW);
|
||||||
lv_obj_set_style_pad_column(bar, 8, 0);
|
lv_obj_set_style_pad_column(bar, 8, 0);
|
||||||
lv_obj_align(bar, LV_ALIGN_TOP_LEFT, 24, 18);
|
// y 60: the top 56 px belong to the StatusOverlay (alert banner centre, Wi-Fi chip right)
|
||||||
|
lv_obj_align(bar, LV_ALIGN_TOP_LEFT, 24, 60);
|
||||||
lv_obj_clear_flag(bar, LV_OBJ_FLAG_SCROLLABLE);
|
lv_obj_clear_flag(bar, LV_OBJ_FLAG_SCROLLABLE);
|
||||||
|
|
||||||
g_ign_chip = makeChip(bar, "IGN --");
|
g_ign_chip = makeChip(bar, "IGN --");
|
||||||
g_eng_chip = makeChip(bar, "ENG --");
|
g_eng_chip = makeChip(bar, "ENG --");
|
||||||
g_clutch_chip = makeChip(bar, "CLUTCH --");
|
g_clutch_chip = makeChip(bar, "CLUTCH --");
|
||||||
g_cool_chip = makeChip(bar, "COOLING --");
|
g_cool_chip = makeChip(bar, "COOLING --");
|
||||||
|
// Gear mismatch: the ring and the gear letter turn red, and the overlay banner says so.
|
||||||
|
|
||||||
|
// ---- diff locks, top-right under the overlay's Wi-Fi chip (hidden until enabled).
|
||||||
|
// Box bottom stays above the GEARBOX OIL stat (its top is at y ~227).
|
||||||
|
g_diff_box = lv_obj_create(g_screen);
|
||||||
|
lv_obj_remove_style_all(g_diff_box);
|
||||||
|
lv_obj_set_size(g_diff_box, DL_BOX_W, dl(DL_REAR_Y + DL_TYRE_L / 2) + 6); // drawing only, no caption
|
||||||
|
lv_obj_align(g_diff_box, LV_ALIGN_TOP_RIGHT, -16, 60);
|
||||||
|
lv_obj_clear_flag(g_diff_box, LV_OBJ_FLAG_SCROLLABLE);
|
||||||
|
lv_obj_clear_flag(g_diff_box, LV_OBJ_FLAG_CLICKABLE); // swipes pass through to the screen
|
||||||
|
lv_obj_add_flag(g_diff_box, LV_OBJ_FLAG_HIDDEN);
|
||||||
|
|
||||||
|
g_pts_shaft[0] = dlPoint(DL_SHAFT_X, DL_FRONT_Y);
|
||||||
|
g_pts_shaft[1] = dlPoint(DL_SHAFT_X, DL_REAR_Y);
|
||||||
|
makeLine(g_diff_box, g_pts_shaft, 2, 3, true);
|
||||||
|
|
||||||
|
// axles run between the tyres' inner edges (a steered tyre's edge sits a little further out)
|
||||||
|
const float half = DL_TYRE_W / 2;
|
||||||
|
const float half_steered = half / cosf(DL_STEER * (float)M_PI / 180.0f);
|
||||||
|
g_pts_axle[0][0] = dlPoint(DL_TRACK_L + half_steered, DL_FRONT_Y);
|
||||||
|
g_pts_axle[0][1] = dlPoint(DL_TRACK_R - half_steered, DL_FRONT_Y);
|
||||||
|
g_pts_axle[1][0] = dlPoint(DL_TRACK_L + half, DL_REAR_Y);
|
||||||
|
g_pts_axle[1][1] = dlPoint(DL_TRACK_R - half, DL_REAR_Y);
|
||||||
|
g_front_axle.axle = makeLine(g_diff_box, g_pts_axle[0], 2, 3, true);
|
||||||
|
g_rear_axle.axle = makeLine(g_diff_box, g_pts_axle[1], 2, 3, true);
|
||||||
|
|
||||||
|
g_front_axle.tyre[0] = makeTyre(g_diff_box, g_pts_tyre[0][0], g_pts_fill[0][0], DL_TRACK_L, DL_FRONT_Y, DL_STEER);
|
||||||
|
g_front_axle.tyre[1] = makeTyre(g_diff_box, g_pts_tyre[0][1], g_pts_fill[0][1], DL_TRACK_R, DL_FRONT_Y, DL_STEER);
|
||||||
|
g_rear_axle.tyre[0] = makeTyre(g_diff_box, g_pts_tyre[1][0], g_pts_fill[1][0], DL_TRACK_L, DL_REAR_Y, 0);
|
||||||
|
g_rear_axle.tyre[1] = makeTyre(g_diff_box, g_pts_tyre[1][1], g_pts_fill[1][1], DL_TRACK_R, DL_REAR_Y, 0);
|
||||||
|
|
||||||
|
diffCross(g_diff_box, g_front_axle, 0, DL_SHAFT_X, DL_FRONT_Y);
|
||||||
|
diffCross(g_diff_box, g_rear_axle, 1, DL_SHAFT_X, DL_REAR_Y);
|
||||||
|
|
||||||
g_mismatch_lbl = lv_label_create(g_screen);
|
|
||||||
lv_label_set_text(g_mismatch_lbl, LV_SYMBOL_WARNING " GEAR MISMATCH");
|
|
||||||
lv_obj_set_style_text_font(g_mismatch_lbl, &lv_font_montserrat_14, 0);
|
|
||||||
lv_obj_set_style_text_color(g_mismatch_lbl, COL_WARN, 0);
|
|
||||||
lv_obj_align(g_mismatch_lbl, LV_ALIGN_TOP_RIGHT, -24, 24);
|
|
||||||
lv_obj_add_flag(g_mismatch_lbl, LV_OBJ_FLAG_HIDDEN);
|
|
||||||
|
|
||||||
// ---- gear hero -------------------------------------------------------
|
// ---- gear hero -------------------------------------------------------
|
||||||
g_gear_ring = lv_obj_create(g_screen);
|
g_gear_ring = lv_obj_create(g_screen);
|
||||||
@@ -208,6 +405,8 @@ static void build() {
|
|||||||
LV_ALIGN_LEFT_MID, 110, -40);
|
LV_ALIGN_LEFT_MID, 110, -40);
|
||||||
g_gearbox_lbl = makeStat(g_screen, "GEARBOX OIL", &lv_font_montserrat_40,
|
g_gearbox_lbl = makeStat(g_screen, "GEARBOX OIL", &lv_font_montserrat_40,
|
||||||
LV_ALIGN_RIGHT_MID, -110, -40);
|
LV_ALIGN_RIGHT_MID, -110, -40);
|
||||||
|
g_coolant_title = lv_obj_get_child(lv_obj_get_parent(g_coolant_lbl), 0);
|
||||||
|
g_gearbox_title = lv_obj_get_child(lv_obj_get_parent(g_gearbox_lbl), 0);
|
||||||
|
|
||||||
// ---- RPM bar ---------------------------------------------------------
|
// ---- RPM bar ---------------------------------------------------------
|
||||||
lv_obj_t* rpm_title = lv_label_create(g_screen);
|
lv_obj_t* rpm_title = lv_label_create(g_screen);
|
||||||
@@ -279,11 +478,13 @@ void tick() {
|
|||||||
uint8_t gear = GEAR_UNKNOWN;
|
uint8_t gear = GEAR_UNKNOWN;
|
||||||
int16_t coolant = 0, gearbox = 0;
|
int16_t coolant = 0, gearbox = 0;
|
||||||
uint8_t flags = 0;
|
uint8_t flags = 0;
|
||||||
|
uint16_t alerts = 0;
|
||||||
if (xSemaphoreTake(UARTManager::g_data_mutex, pdMS_TO_TICKS(10)) == pdTRUE) {
|
if (xSemaphoreTake(UARTManager::g_data_mutex, pdMS_TO_TICKS(10)) == pdTRUE) {
|
||||||
gear = UARTManager::g_automotive_data.gear_lever;
|
gear = UARTManager::g_automotive_data.gear_lever;
|
||||||
coolant = UARTManager::g_automotive_data.coolant_temp;
|
coolant = UARTManager::g_automotive_data.coolant_temp;
|
||||||
gearbox = UARTManager::g_automotive_data.gearbox_oil_temp;
|
gearbox = UARTManager::g_automotive_data.gearbox_oil_temp;
|
||||||
flags = UARTManager::g_automotive_data.valid_flags;
|
flags = UARTManager::g_automotive_data.valid_flags;
|
||||||
|
alerts = UARTManager::g_automotive_data.alerts;
|
||||||
xSemaphoreGive(UARTManager::g_data_mutex);
|
xSemaphoreGive(UARTManager::g_data_mutex);
|
||||||
} else {
|
} else {
|
||||||
return; // couldn't read; leave the last frame on screen
|
return; // couldn't read; leave the last frame on screen
|
||||||
@@ -293,20 +494,25 @@ void tick() {
|
|||||||
(void)gear; // gear now comes from the driveline pieces, not the UART enum
|
(void)gear; // gear now comes from the driveline pieces, not the UART enum
|
||||||
lvgl_port_lock(-1);
|
lvgl_port_lock(-1);
|
||||||
|
|
||||||
|
refreshDiffLocks(); // hard-wired inputs: live even with CAN or the key off
|
||||||
|
|
||||||
// Blank every readout when there's nothing live to show: CAN off, or the key
|
// Blank every readout when there's nothing live to show: CAN off, or the key
|
||||||
// is off. The user asked for a full reset on ignition-off so the screen goes
|
// is off. The user asked for a full reset on ignition-off so the screen goes
|
||||||
// quiet with the car rather than freezing the last frame. 0x3B4 sends its
|
// quiet with the car rather than freezing the last frame. 0x3B4 sends its
|
||||||
// ignition nibble on-change, so this reset is effectively instant.
|
// ignition nibble on-change, so this reset is effectively instant.
|
||||||
if (!can_up || !dl.ignition_on) {
|
if (!can_up || !dl.ignition_on) {
|
||||||
lv_label_set_text(g_gear_lbl, "--");
|
setText(g_gear_lbl, "--");
|
||||||
lv_label_set_text(g_coolant_lbl, "--");
|
setText(g_coolant_lbl, "--");
|
||||||
lv_label_set_text(g_gearbox_lbl, "--");
|
setText(g_gearbox_lbl, "--");
|
||||||
lv_label_set_text(g_rpm_lbl, "----");
|
setText(g_rpm_lbl, "----");
|
||||||
lv_label_set_text(g_torque_lbl, "--");
|
setText(g_torque_lbl, "--");
|
||||||
lv_label_set_text(g_pedal_lbl, "--");
|
setText(g_pedal_lbl, "--");
|
||||||
lv_label_set_text(g_shaft_lbl, "--");
|
setText(g_shaft_lbl, "--");
|
||||||
lv_bar_set_value(g_rpm_bar, 0, LV_ANIM_OFF);
|
lv_bar_set_value(g_rpm_bar, 0, LV_ANIM_OFF);
|
||||||
lv_obj_add_flag(g_mismatch_lbl, LV_OBJ_FLAG_HIDDEN);
|
setRing(COL_ACCENT);
|
||||||
|
setColour(g_gear_lbl, COL_TEXT);
|
||||||
|
setColour(g_coolant_lbl, COL_TEXT); setColour(g_coolant_title, COL_MUTED);
|
||||||
|
setColour(g_gearbox_lbl, COL_TEXT); setColour(g_gearbox_title, COL_MUTED);
|
||||||
// Leave the ignition chip telling the truth; mute the rest, since their
|
// Leave the ignition chip telling the truth; mute the rest, since their
|
||||||
// values are meaningless with the key out (or absent with CAN off).
|
// values are meaningless with the key out (or absent with CAN off).
|
||||||
if (!can_up) {
|
if (!can_up) {
|
||||||
@@ -325,37 +531,48 @@ void tick() {
|
|||||||
// ---- gear (composed: P/R/N, or D/S/M + engaged number) ---------------
|
// ---- gear (composed: P/R/N, or D/S/M + engaged number) ---------------
|
||||||
if ((gear_position_t)dl.lever != GEAR_UNKNOWN) {
|
if ((gear_position_t)dl.lever != GEAR_UNKNOWN) {
|
||||||
composeGear(dl, buf, sizeof(buf));
|
composeGear(dl, buf, sizeof(buf));
|
||||||
lv_label_set_text(g_gear_lbl, buf);
|
setText(g_gear_lbl, buf);
|
||||||
} else {
|
} else {
|
||||||
lv_label_set_text(g_gear_lbl, "--");
|
setText(g_gear_lbl, "--");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- temperatures (only when the signal is real) ---------------------
|
// ---- temperatures (only when the signal is real) ---------------------
|
||||||
if (flags & VALID_FLAG_COOLANT_TEMP) {
|
if (flags & VALID_FLAG_COOLANT_TEMP) {
|
||||||
snprintf(buf, sizeof(buf), "%d.%d°C", coolant / 10, abs(coolant % 10));
|
snprintf(buf, sizeof(buf), "%d.%d°C", coolant / 10, abs(coolant % 10));
|
||||||
lv_label_set_text(g_coolant_lbl, buf);
|
setText(g_coolant_lbl, buf);
|
||||||
}
|
}
|
||||||
if (flags & VALID_FLAG_GEARBOX_TEMP) {
|
if (flags & VALID_FLAG_GEARBOX_TEMP) {
|
||||||
snprintf(buf, sizeof(buf), "%d.%d°C", gearbox / 10, abs(gearbox % 10));
|
snprintf(buf, sizeof(buf), "%d.%d°C", gearbox / 10, abs(gearbox % 10));
|
||||||
lv_label_set_text(g_gearbox_lbl, buf);
|
setText(g_gearbox_lbl, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---- thresholds crossed: the value AND its title go red (amber while the
|
||||||
|
// box only asks for cooling); the overlay banner blinks on top of it all.
|
||||||
|
if (!(flags & VALID_FLAG_ALERTS)) alerts = 0;
|
||||||
|
bool cool_hot = (alerts & ALERT_COOLANT_HOT) != 0;
|
||||||
|
bool gb_hot = (alerts & ALERT_GEARBOX_HOT) != 0;
|
||||||
|
bool gb_cool = (alerts & ALERT_GEARBOX_COOLING) != 0;
|
||||||
|
setColour(g_coolant_lbl, cool_hot ? COL_ALERT : COL_TEXT);
|
||||||
|
setColour(g_coolant_title, cool_hot ? COL_ALERT : COL_MUTED);
|
||||||
|
setColour(g_gearbox_lbl, gb_hot ? COL_ALERT : gb_cool ? COL_AMBER : COL_TEXT);
|
||||||
|
setColour(g_gearbox_title, gb_hot ? COL_ALERT : gb_cool ? COL_AMBER : COL_MUTED);
|
||||||
|
|
||||||
// ---- speeds ----------------------------------------------------------
|
// ---- speeds ----------------------------------------------------------
|
||||||
snprintf(buf, sizeof(buf), "%u", dl.engine_rpm);
|
snprintf(buf, sizeof(buf), "%u", dl.engine_rpm);
|
||||||
lv_label_set_text(g_rpm_lbl, buf);
|
setText(g_rpm_lbl, buf);
|
||||||
lv_bar_set_value(g_rpm_bar, dl.engine_rpm > RPM_MAX ? RPM_MAX : dl.engine_rpm, LV_ANIM_OFF);
|
lv_bar_set_value(g_rpm_bar, dl.engine_rpm > RPM_MAX ? RPM_MAX : dl.engine_rpm, LV_ANIM_OFF);
|
||||||
|
|
||||||
// Torque is signed (negative under overrun/braking); one decimal, matching
|
// Torque is signed (negative under overrun/braking); one decimal, matching
|
||||||
// the 0.5 Nm resolution of the field.
|
// the 0.5 Nm resolution of the field.
|
||||||
snprintf(buf, sizeof(buf), "%d.%d", dl.engine_torque_x10 / 10, abs(dl.engine_torque_x10 % 10));
|
snprintf(buf, sizeof(buf), "%d.%d", dl.engine_torque_x10 / 10, abs(dl.engine_torque_x10 % 10));
|
||||||
lv_label_set_text(g_torque_lbl, buf);
|
setText(g_torque_lbl, buf);
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "%u", dl.pedal_percent);
|
snprintf(buf, sizeof(buf), "%u", dl.pedal_percent);
|
||||||
lv_label_set_text(g_pedal_lbl, buf);
|
setText(g_pedal_lbl, buf);
|
||||||
|
|
||||||
// Provisional rpm from the single-point Launch factor (see automotive_data.h).
|
// Provisional rpm from the single-point Launch factor (see automotive_data.h).
|
||||||
snprintf(buf, sizeof(buf), "%u", can_output_shaft_rpm(dl.output_shaft_raw));
|
snprintf(buf, sizeof(buf), "%u", can_output_shaft_rpm(dl.output_shaft_raw));
|
||||||
lv_label_set_text(g_shaft_lbl, buf);
|
setText(g_shaft_lbl, buf);
|
||||||
|
|
||||||
// ---- status chips ----------------------------------------------------
|
// ---- status chips ----------------------------------------------------
|
||||||
setChip(g_ign_chip, dl.ignition_on ? "IGN ON" : "IGN OFF",
|
setChip(g_ign_chip, dl.ignition_on ? "IGN ON" : "IGN OFF",
|
||||||
@@ -382,19 +599,11 @@ void tick() {
|
|||||||
default: setChip(g_cool_chip, "COOLING ?", COL_MUTED); break;
|
default: setChip(g_cool_chip, "COOLING ?", COL_MUTED); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dl.gear_mismatch) {
|
// Gear mismatch: the hero ring and the gear letter turn red.
|
||||||
lv_obj_clear_flag(g_mismatch_lbl, LV_OBJ_FLAG_HIDDEN);
|
setRing(dl.gear_mismatch ? COL_ALERT : COL_ACCENT);
|
||||||
} else {
|
setColour(g_gear_lbl, dl.gear_mismatch ? COL_ALERT : COL_TEXT);
|
||||||
lv_obj_add_flag(g_mismatch_lbl, LV_OBJ_FLAG_HIDDEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
lvgl_port_unlock();
|
lvgl_port_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace DrivelineScreen
|
} // namespace DrivelineScreen
|
||||||
|
|
||||||
// C entry point used by the SquareLine-generated Settings screen's back gesture.
|
|
||||||
// Runs inside an LVGL event handler, so the LVGL lock is already held.
|
|
||||||
extern "C" void app_show_driveline(void) {
|
|
||||||
DrivelineScreen::show();
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -5,16 +5,8 @@
|
|||||||
* the swap's bus: gear (hero), coolant, gearbox oil temp, engine RPM, turbine
|
* the swap's bus: gear (hero), coolant, gearbox oil temp, engine RPM, turbine
|
||||||
* speed and output shaft, plus ignition / engine / clutch / mismatch status.
|
* speed and output shaft, plus ignition / engine / clutch / mismatch status.
|
||||||
*
|
*
|
||||||
* WHY THIS IS NOT A SQUARELINE SCREEN
|
* The boot screen. Navigation: swipe LEFT -> Settings, swipe RIGHT -> Gauge
|
||||||
* SquareLine Studio owns include/ui/ and overwrites it on every export. Editing
|
* Tuning (both hand-coded, like this one).
|
||||||
* generated files loses the edit — that is exactly how the CAN toggle's event
|
|
||||||
* handler went missing. This screen lives entirely in src/, which SquareLine
|
|
||||||
* never touches, so it cannot be clobbered. Since 2026-09-21 it IS the boot
|
|
||||||
* screen: the SquareLine Home screen was removed, and the generated Settings
|
|
||||||
* screen's back gesture calls app_show_driveline() (defined at the bottom of
|
|
||||||
* driveline_screen.cpp) to return here.
|
|
||||||
*
|
|
||||||
* Navigation: swipe LEFT -> Settings (SquareLine), swipe RIGHT -> Gauge Tuning.
|
|
||||||
*
|
*
|
||||||
* Signals deliberately NOT shown: engine oil temp (no sensor on this M57N —
|
* Signals deliberately NOT shown: engine oil temp (no sensor on this M57N —
|
||||||
* 0x1D0 byte 1 is permanently 0xFF) and battery voltage (0x3B4 publishes the
|
* 0x1D0 byte 1 is permanently 0xFF) and battery voltage (0x3B4 publishes the
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* ESP-NOW Link Module Implementation (Controller A, transmit only)
|
* ESP-NOW Link Module Implementation (Main CTRL, transmit only)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "espnow_link.h"
|
#include "espnow_link.h"
|
||||||
@@ -16,6 +16,13 @@ static const uint8_t BROADCAST_MAC[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
|
|||||||
static bool g_ready = false;
|
static bool g_ready = false;
|
||||||
static uint32_t g_sent = 0;
|
static uint32_t g_sent = 0;
|
||||||
static uint32_t g_fail = 0;
|
static uint32_t g_fail = 0;
|
||||||
|
static receive_handler_t g_rx_handler = NULL;
|
||||||
|
|
||||||
|
// IDF 5.x receive callback: sender MAC is in the info struct.
|
||||||
|
static void onReceive(const esp_now_recv_info_t* info, const uint8_t* data, int len) {
|
||||||
|
if (g_rx_handler == NULL || info == NULL || len <= 0) return;
|
||||||
|
g_rx_handler(info->src_addr, data, (size_t)len);
|
||||||
|
}
|
||||||
|
|
||||||
// IDF 5.5 (pioarduino / Arduino 3.3) passes wifi_tx_info_t*; older cores passed the MAC.
|
// IDF 5.5 (pioarduino / Arduino 3.3) passes wifi_tx_info_t*; older cores passed the MAC.
|
||||||
static void onSent(const wifi_tx_info_t* info, esp_now_send_status_t status) {
|
static void onSent(const wifi_tx_info_t* info, esp_now_send_status_t status) {
|
||||||
@@ -45,6 +52,7 @@ bool init() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
esp_now_register_send_cb(onSent);
|
esp_now_register_send_cb(onSent);
|
||||||
|
esp_now_register_recv_cb(onReceive);
|
||||||
|
|
||||||
esp_now_peer_info_t peer = {};
|
esp_now_peer_info_t peer = {};
|
||||||
memcpy(peer.peer_addr, BROADCAST_MAC, 6);
|
memcpy(peer.peer_addr, BROADCAST_MAC, 6);
|
||||||
@@ -93,4 +101,26 @@ bool isReady() { return g_ready; }
|
|||||||
uint32_t sentCount() { return g_sent; }
|
uint32_t sentCount() { return g_sent; }
|
||||||
uint32_t failCount() { return g_fail; }
|
uint32_t failCount() { return g_fail; }
|
||||||
|
|
||||||
|
void setReceiveHandler(receive_handler_t handler) { g_rx_handler = handler; }
|
||||||
|
|
||||||
|
bool sendTo(const uint8_t mac[6], const uint8_t* frame, size_t len) {
|
||||||
|
if (len == 0 || len > ESP_NOW_MAX_DATA_LEN) return false;
|
||||||
|
if (!g_ready) {
|
||||||
|
reinitIfDue();
|
||||||
|
if (!g_ready) return false;
|
||||||
|
}
|
||||||
|
if (!esp_now_is_peer_exist(mac)) {
|
||||||
|
esp_now_peer_info_t peer = {};
|
||||||
|
memcpy(peer.peer_addr, mac, 6);
|
||||||
|
peer.channel = 0; // current channel
|
||||||
|
peer.encrypt = false; // SECURE frames carry their own encryption
|
||||||
|
peer.ifidx = WIFI_IF_STA;
|
||||||
|
if (esp_now_add_peer(&peer) != ESP_OK) {
|
||||||
|
ESP_LOGE("EspNow", "esp_now_add_peer(B) failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return esp_now_send(mac, frame, len) == ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace EspNowLink
|
} // namespace EspNowLink
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
/*
|
/*
|
||||||
* ESP-NOW Link Module (Controller A side, transmit only)
|
* ESP-NOW Link Module (Main CTRL side)
|
||||||
*
|
*
|
||||||
* Second transport for the A -> B link: every frame the UART manager builds
|
* Second transport for the A -> B link: every frame the UART manager builds
|
||||||
* is also broadcast over ESP-NOW, so B keeps receiving if the wire is lost.
|
* is also broadcast over ESP-NOW, so B keeps receiving if the wire is lost.
|
||||||
* B dedupes on packet_id, so both paths may be live at once.
|
* B dedupes on packet_id, so both paths may be live at once.
|
||||||
*
|
*
|
||||||
|
* Since 2026-09-27 the radio also listens: B unicasts STATUS frames back and
|
||||||
|
* A unicasts SECURE frames to B (LinkPeer). Frames received are handed to the
|
||||||
|
* handler set with setReceiveHandler(); sendTo() unicasts to one MAC.
|
||||||
|
*
|
||||||
* Radio policy: the Wi-Fi radio stays in STA mode permanently (the WiFi
|
* Radio policy: the Wi-Fi radio stays in STA mode permanently (the WiFi
|
||||||
* manager's "off" only stops scanning). A transmits on ESPNOW_CHANNEL unless
|
* manager's "off" only stops scanning). A transmits on ESPNOW_CHANNEL unless
|
||||||
* associated to an access point, in which case the AP's channel is used and
|
* associated to an access point, in which case the AP's channel is used and
|
||||||
@@ -34,4 +38,11 @@ bool isReady();
|
|||||||
uint32_t sentCount();
|
uint32_t sentCount();
|
||||||
uint32_t failCount();
|
uint32_t failCount();
|
||||||
|
|
||||||
|
/** Frames received from any sender (runs in the Wi-Fi task - copy and return). */
|
||||||
|
typedef void (*receive_handler_t)(const uint8_t mac[6], const uint8_t* frame, size_t len);
|
||||||
|
void setReceiveHandler(receive_handler_t handler);
|
||||||
|
|
||||||
|
/** Unicast one complete frame to a MAC (peer added on first use, unencrypted). */
|
||||||
|
bool sendTo(const uint8_t mac[6], const uint8_t* frame, size_t len);
|
||||||
|
|
||||||
} // namespace EspNowLink
|
} // namespace EspNowLink
|
||||||
|
|||||||
@@ -0,0 +1,370 @@
|
|||||||
|
/*
|
||||||
|
* Link Peer Module Implementation (Main CTRL)
|
||||||
|
*
|
||||||
|
* Threading: onFrame() runs in the Wi-Fi task and only copies the STATUS into
|
||||||
|
* g_peer under a mutex. Everything else (NVS, sending, console) is the loop task.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "link_peer.h"
|
||||||
|
#include "espnow_link.h"
|
||||||
|
#include "uart_manager.h"
|
||||||
|
#include "wifi_manager.h"
|
||||||
|
#include "ota_update.h"
|
||||||
|
#include "serial_lock.h"
|
||||||
|
#include "protocol/link_secure.h"
|
||||||
|
#include <Preferences.h>
|
||||||
|
#include <esp_wifi.h>
|
||||||
|
#include <freertos/FreeRTOS.h>
|
||||||
|
#include <freertos/semphr.h>
|
||||||
|
|
||||||
|
namespace LinkPeer {
|
||||||
|
|
||||||
|
static const char* NVS_LINK = "linkpeer"; // key (32 B)
|
||||||
|
#define CREDS_PUSH_MIN_MS 15000 // never push credentials more often than this
|
||||||
|
#define PAIR_REPEATS 3 // PAIR is sent this many times over the wire
|
||||||
|
|
||||||
|
static bool g_paired = false;
|
||||||
|
static uint8_t g_key[LINK_KEY_LEN];
|
||||||
|
static uint16_t g_key_fp = 0;
|
||||||
|
|
||||||
|
// last STATUS from B (written by the Wi-Fi task)
|
||||||
|
static SemaphoreHandle_t g_mutex = NULL;
|
||||||
|
static link_status_t g_st = {};
|
||||||
|
static uint8_t g_b_mac[6] = {0};
|
||||||
|
static uint32_t g_last_status_ms = 0;
|
||||||
|
static bool g_ever_heard = false;
|
||||||
|
static uint32_t g_status_count = 0, g_secure_sent = 0, g_secure_fail = 0;
|
||||||
|
|
||||||
|
// credential sync
|
||||||
|
static uint32_t g_pushed_hash = 0;
|
||||||
|
static uint32_t g_last_push_ms = 0;
|
||||||
|
|
||||||
|
static void lock() { xSemaphoreTake(g_mutex, portMAX_DELAY); }
|
||||||
|
static void unlock() { xSemaphoreGive(g_mutex); }
|
||||||
|
|
||||||
|
static void print(const char* fmt, ...) {
|
||||||
|
char buf[200];
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
SerialLock::lock();
|
||||||
|
Serial.println(buf);
|
||||||
|
SerialLock::unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char* phaseName(uint8_t p) {
|
||||||
|
switch (p) {
|
||||||
|
case LINK_OTA_CHECKING: return "checking";
|
||||||
|
case LINK_OTA_UP_TO_DATE: return "up to date";
|
||||||
|
case LINK_OTA_AVAILABLE: return "update available";
|
||||||
|
case LINK_OTA_INSTALLING: return "installing";
|
||||||
|
case LINK_OTA_FAILED: return "failed";
|
||||||
|
default: return "idle";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- NVS --------------------------------------------------------------------
|
||||||
|
static void loadKey() {
|
||||||
|
Preferences p;
|
||||||
|
p.begin(NVS_LINK, true);
|
||||||
|
g_paired = p.getBytesLength("key") == LINK_KEY_LEN;
|
||||||
|
if (g_paired) p.getBytes("key", g_key, LINK_KEY_LEN);
|
||||||
|
p.end();
|
||||||
|
g_key_fp = g_paired ? link_key_fingerprint(g_key) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void storeKey() {
|
||||||
|
Preferences p;
|
||||||
|
p.begin(NVS_LINK, false);
|
||||||
|
p.putBytes("key", g_key, LINK_KEY_LEN);
|
||||||
|
p.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void clearKey() {
|
||||||
|
Preferences p;
|
||||||
|
p.begin(NVS_LINK, false);
|
||||||
|
p.clear();
|
||||||
|
p.end();
|
||||||
|
g_paired = false;
|
||||||
|
g_key_fp = 0;
|
||||||
|
memset(g_key, 0, sizeof(g_key));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- inbound (Wi-Fi task) ---------------------------------------------------
|
||||||
|
static void onFrame(const uint8_t mac[6], const uint8_t* frame, size_t len) {
|
||||||
|
uint8_t type = 0, plen = 0;
|
||||||
|
const uint8_t* payload = NULL;
|
||||||
|
if (frame_parse(frame, len, &type, &payload, &plen) != FRAME_OK) return;
|
||||||
|
if (type != PACKET_TYPE_STATUS) return;
|
||||||
|
if (xSemaphoreTake(g_mutex, pdMS_TO_TICKS(10)) != pdTRUE) return;
|
||||||
|
memcpy(&g_st, payload, sizeof(g_st));
|
||||||
|
g_st.version[sizeof(g_st.version) - 1] = 0;
|
||||||
|
g_st.latest[sizeof(g_st.latest) - 1] = 0;
|
||||||
|
g_st.message[sizeof(g_st.message) - 1] = 0;
|
||||||
|
memcpy(g_b_mac, mac, 6);
|
||||||
|
g_last_status_ms = millis();
|
||||||
|
g_ever_heard = true;
|
||||||
|
g_status_count++;
|
||||||
|
xSemaphoreGive(g_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- public: status ---------------------------------------------------------
|
||||||
|
peer_status_t getStatus() {
|
||||||
|
peer_status_t p = {};
|
||||||
|
lock();
|
||||||
|
p.st = g_st;
|
||||||
|
memcpy(p.mac, g_b_mac, 6);
|
||||||
|
uint32_t last = g_last_status_ms;
|
||||||
|
bool ever = g_ever_heard;
|
||||||
|
unlock();
|
||||||
|
p.age_ms = ever ? millis() - last : 0xFFFFFFFF;
|
||||||
|
p.heard = ever && p.age_ms < LINK_STATUS_TIMEOUT_MS;
|
||||||
|
p.paired = g_paired;
|
||||||
|
p.key_fp = g_key_fp;
|
||||||
|
p.key_match = g_paired && p.st.key_fp == g_key_fp;
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- outbound ---------------------------------------------------------------
|
||||||
|
static bool sendSecure(uint8_t inner_type, const void* inner, size_t inner_len, char* why, size_t n) {
|
||||||
|
peer_status_t p = getStatus();
|
||||||
|
if (!p.heard) { snprintf(why, n, "Inst. Cluster not heard"); return false; }
|
||||||
|
if (!p.paired) { snprintf(why, n, "not paired - run `link pair` with the wire connected"); return false; }
|
||||||
|
if (!p.key_match) { snprintf(why, n, "Inst. Cluster holds a different key - run `link pair` again"); return false; }
|
||||||
|
|
||||||
|
uint8_t payload[PACKET_MAX_PAYLOAD], frame[PACKET_MAX_SIZE];
|
||||||
|
size_t plen = link_secure_seal(g_key, inner_type, inner, inner_len, payload);
|
||||||
|
if (!plen) { snprintf(why, n, "encryption failed"); return false; }
|
||||||
|
size_t flen = frame_build(PACKET_TYPE_SECURE, payload, (uint8_t)plen, frame);
|
||||||
|
if (!flen || !EspNowLink::sendTo(p.mac, frame, flen)) {
|
||||||
|
g_secure_fail++;
|
||||||
|
snprintf(why, n, "ESP-NOW send failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
g_secure_sent++;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool sendOtaCmd(uint8_t cmd, uint8_t flags, char* why, size_t n) {
|
||||||
|
link_ota_cmd_t c = {};
|
||||||
|
c.cmd = cmd;
|
||||||
|
c.flags = flags;
|
||||||
|
c.nonce = esp_random();
|
||||||
|
return sendSecure(LINK_INNER_OTA_CMD, &c, sizeof(c), why, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint32_t hashStr(uint32_t h, const char* s) {
|
||||||
|
for (; *s; s++) h = (h ^ (uint8_t)*s) * 16777619u; // FNV-1a
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Push A's remembered network (or a FORGET) to B. */
|
||||||
|
static bool pushCredentials(char* why, size_t n, bool log) {
|
||||||
|
link_wifi_creds_t c = {};
|
||||||
|
char pass[65];
|
||||||
|
bool have = WiFiManager::getSavedCredentials(c.ssid, sizeof(c.ssid), pass, sizeof(pass));
|
||||||
|
if (have) {
|
||||||
|
c.action = LINK_WIFI_SET;
|
||||||
|
strlcpy(c.pass, pass, sizeof(c.pass));
|
||||||
|
} else {
|
||||||
|
c.action = LINK_WIFI_FORGET;
|
||||||
|
}
|
||||||
|
bool ok = sendSecure(LINK_INNER_WIFI_CREDS, &c, sizeof(c), why, n);
|
||||||
|
memset(pass, 0, sizeof(pass));
|
||||||
|
if (ok) {
|
||||||
|
g_pushed_hash = have ? hashStr(hashStr(2166136261u, c.ssid), c.pass) : 1;
|
||||||
|
g_last_push_ms = millis();
|
||||||
|
if (log) print(have ? "[link] Wi-Fi credentials for '%s' sent to Inst. Cluster (encrypted)"
|
||||||
|
: "[link] told Inst. Cluster to forget its Wi-Fi credentials", c.ssid);
|
||||||
|
}
|
||||||
|
memset(&c, 0, sizeof(c));
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
// B lacks credentials A has, or A's changed, or A forgot them while B still has them.
|
||||||
|
static void syncCredentials() {
|
||||||
|
peer_status_t p = getStatus();
|
||||||
|
if (!p.heard || !p.paired || !p.key_match) return;
|
||||||
|
if (millis() - g_last_push_ms < CREDS_PUSH_MIN_MS && g_last_push_ms != 0) return;
|
||||||
|
|
||||||
|
char ssid[33], pass[65];
|
||||||
|
bool have = WiFiManager::getSavedCredentials(ssid, sizeof(ssid), pass, sizeof(pass));
|
||||||
|
uint32_t h = have ? hashStr(hashStr(2166136261u, ssid), pass) : 1;
|
||||||
|
memset(pass, 0, sizeof(pass));
|
||||||
|
bool b_has = (p.st.flags & LINK_STATUS_HAVE_WIFI) != 0;
|
||||||
|
|
||||||
|
bool need = have ? (!b_has || h != g_pushed_hash)
|
||||||
|
: (b_has && g_pushed_hash != 1);
|
||||||
|
if (!need) return;
|
||||||
|
char why[64];
|
||||||
|
pushCredentials(why, sizeof(why), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- pairing ----------------------------------------------------------------
|
||||||
|
static bool pair(char* why, size_t n) {
|
||||||
|
if (UARTManager::getState() == UARTManager::UART_STATE_OFF) {
|
||||||
|
snprintf(why, n, "link is off - enable 'Send to Inst. Cluster' in Settings first");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
link_pair_t pk = {};
|
||||||
|
pk.magic = LINK_PAIR_MAGIC;
|
||||||
|
esp_fill_random(pk.key, LINK_KEY_LEN);
|
||||||
|
esp_wifi_get_mac(WIFI_IF_STA, pk.a_mac);
|
||||||
|
|
||||||
|
uint8_t frame[PACKET_MAX_SIZE];
|
||||||
|
size_t flen = frame_build(PACKET_TYPE_PAIR, &pk, sizeof(pk), frame);
|
||||||
|
int sent = 0;
|
||||||
|
for (int i = 0; i < PAIR_REPEATS; i++) {
|
||||||
|
if (UARTManager::sendWire(frame, flen)) sent++;
|
||||||
|
delay(40);
|
||||||
|
}
|
||||||
|
if (!sent) { snprintf(why, n, "UART write failed"); memset(&pk, 0, sizeof(pk)); return false; }
|
||||||
|
|
||||||
|
memcpy(g_key, pk.key, LINK_KEY_LEN);
|
||||||
|
memset(&pk, 0, sizeof(pk));
|
||||||
|
g_paired = true;
|
||||||
|
g_key_fp = link_key_fingerprint(g_key);
|
||||||
|
storeKey();
|
||||||
|
g_pushed_hash = 0; // re-send the credentials under the new key
|
||||||
|
g_last_push_ms = 0;
|
||||||
|
print("[link] PAIR sent over the wire %d time(s); new key fingerprint %04X. "
|
||||||
|
"Inst. Cluster confirms in its next STATUS (`link status`).", sent, g_key_fp);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- public: requests (UI) --------------------------------------------------
|
||||||
|
static bool bReady(char* why, size_t n, bool need_parked) {
|
||||||
|
peer_status_t p = getStatus();
|
||||||
|
if (!p.heard) { snprintf(why, n, "Inst. Cluster not heard - is it powered?"); return false; }
|
||||||
|
if (!p.paired || !p.key_match) {
|
||||||
|
snprintf(why, n, "Inst. Cluster is not paired with this controller (console: link pair, wire connected)");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!(p.st.flags & LINK_STATUS_HAVE_WIFI)) {
|
||||||
|
snprintf(why, n, "Inst. Cluster has no Wi-Fi credentials yet - join a network on this screen first");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (p.st.ota_phase == LINK_OTA_CHECKING || p.st.ota_phase == LINK_OTA_INSTALLING) {
|
||||||
|
snprintf(why, n, "Inst. Cluster is busy (%s)", phaseName(p.st.ota_phase));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (need_parked && !Ota::isParked(why, n)) return false;
|
||||||
|
// Same network as B => same radio channel, so B's STATUS frames (progress)
|
||||||
|
// keep reaching this screen while B is joined.
|
||||||
|
if (WiFiManager::getStatus().link != WiFiManager::LINK_CONNECTED) {
|
||||||
|
snprintf(why, n, "join Wi-Fi on this controller first, so Inst. Cluster's progress can be followed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool requestCheck(char* why, size_t n) {
|
||||||
|
if (!bReady(why, n, false)) { print("[link] check refused: %s", why); return false; }
|
||||||
|
return sendOtaCmd(LINK_OTA_CMD_CHECK, 0, why, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool requestInstall(char* why, size_t n) {
|
||||||
|
if (!bReady(why, n, true)) { print("[link] install refused: %s", why); return false; }
|
||||||
|
return sendOtaCmd(LINK_OTA_CMD_INSTALL, 0, why, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- lifecycle --------------------------------------------------------------
|
||||||
|
void init() {
|
||||||
|
if (g_mutex == NULL) g_mutex = xSemaphoreCreateMutex();
|
||||||
|
loadKey();
|
||||||
|
EspNowLink::setReceiveHandler(onFrame);
|
||||||
|
print("[link] Inst. Cluster: %s", g_paired ? "pairing key loaded" : "NOT paired - `link pair` with the wire connected");
|
||||||
|
}
|
||||||
|
|
||||||
|
void tick() {
|
||||||
|
static uint32_t last = 0;
|
||||||
|
static bool was_heard = false;
|
||||||
|
static uint8_t last_phase = 0xFF;
|
||||||
|
static bool was_match = false;
|
||||||
|
if (millis() - last < 1000) return;
|
||||||
|
last = millis();
|
||||||
|
|
||||||
|
peer_status_t p = getStatus();
|
||||||
|
if (p.heard != was_heard) {
|
||||||
|
was_heard = p.heard;
|
||||||
|
if (p.heard) print("[link] Inst. Cluster heard: %s, %s, %lu s up", p.st.version,
|
||||||
|
p.key_match ? "paired" : (p.st.key_fp ? "paired with ANOTHER key" : "unpaired"),
|
||||||
|
(unsigned long)p.st.uptime_s);
|
||||||
|
else print("[link] Inst. Cluster silent for %lu s", (unsigned long)(p.age_ms / 1000));
|
||||||
|
}
|
||||||
|
if (p.heard && p.key_match && !was_match) {
|
||||||
|
print("[link] Inst. Cluster confirmed pairing (fingerprint %04X)", p.st.key_fp);
|
||||||
|
}
|
||||||
|
was_match = p.heard && p.key_match;
|
||||||
|
if (p.heard && p.st.ota_phase != last_phase) {
|
||||||
|
if (last_phase != 0xFF || p.st.ota_phase != LINK_OTA_IDLE)
|
||||||
|
print("[link] Inst. Cluster update: %s%s%s%s%s", phaseName(p.st.ota_phase),
|
||||||
|
p.st.latest[0] ? ", latest " : "", p.st.latest,
|
||||||
|
p.st.ota_phase == LINK_OTA_FAILED ? " - " : "",
|
||||||
|
p.st.ota_phase == LINK_OTA_FAILED ? p.st.message : "");
|
||||||
|
last_phase = p.st.ota_phase;
|
||||||
|
}
|
||||||
|
syncCredentials();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- console ----------------------------------------------------------------
|
||||||
|
static void help() {
|
||||||
|
print("link status Inst. Cluster: version, pairing, update phase");
|
||||||
|
print("link pair new shared key -> B over the UART wire (bench, wire connected)");
|
||||||
|
print("link unpair forget the key here (B keeps its own until re-paired)");
|
||||||
|
print("link creds send the remembered Wi-Fi network to B now");
|
||||||
|
print("link ota check|install [force]|rollback drive B's updater");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool handleCommand(const char* line) {
|
||||||
|
if (strncmp(line, "link", 4) != 0 || (line[4] != 0 && line[4] != ' ')) return false;
|
||||||
|
const char* a = line + 4;
|
||||||
|
while (*a == ' ') a++;
|
||||||
|
char why[96] = "";
|
||||||
|
|
||||||
|
if (!*a || !strcmp(a, "help")) { help(); return true; }
|
||||||
|
if (!strcmp(a, "status")) {
|
||||||
|
peer_status_t p = getStatus();
|
||||||
|
print("[link] this side: %s (fingerprint %04X) | STATUS frames %lu | SECURE sent %lu, failed %lu",
|
||||||
|
p.paired ? "paired" : "NOT paired", p.key_fp, (unsigned long)g_status_count,
|
||||||
|
(unsigned long)g_secure_sent, (unsigned long)g_secure_fail);
|
||||||
|
if (!g_ever_heard) { print("[link] Inst. Cluster never heard"); return true; }
|
||||||
|
print("[link] Inst. Cluster %02X:%02X:%02X:%02X:%02X:%02X, %s (%lu s ago)",
|
||||||
|
p.mac[0], p.mac[1], p.mac[2], p.mac[3], p.mac[4], p.mac[5],
|
||||||
|
p.heard ? "alive" : "SILENT", (unsigned long)(p.age_ms / 1000));
|
||||||
|
print("[link] firmware %s | key %04X (%s) | Wi-Fi creds %s%s%s",
|
||||||
|
p.st.version, p.st.key_fp, p.key_match ? "matches" : p.st.key_fp ? "DIFFERENT" : "none",
|
||||||
|
(p.st.flags & LINK_STATUS_HAVE_WIFI) ? "yes" : "no",
|
||||||
|
(p.st.flags & LINK_STATUS_WIFI_JOINED) ? ", joined" : "",
|
||||||
|
(p.st.flags & LINK_STATUS_PENDING_VERIFY) ? " | fresh image, unconfirmed" : "");
|
||||||
|
print("[link] update: %s%s%s%s%s | up %lu s | heap %lu",
|
||||||
|
phaseName(p.st.ota_phase),
|
||||||
|
p.st.latest[0] ? ", latest " : "", p.st.latest,
|
||||||
|
p.st.message[0] ? " - " : "", p.st.message,
|
||||||
|
(unsigned long)p.st.uptime_s, (unsigned long)p.st.free_heap);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!strcmp(a, "pair")) { if (!pair(why, sizeof(why))) print("[link] pair refused: %s", why); return true; }
|
||||||
|
if (!strcmp(a, "unpair")) { clearKey(); print("[link] pairing key removed here"); return true; }
|
||||||
|
if (!strcmp(a, "creds")) {
|
||||||
|
if (!pushCredentials(why, sizeof(why), true)) print("[link] creds refused: %s", why);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!strncmp(a, "ota", 3)) {
|
||||||
|
const char* b = a + 3;
|
||||||
|
while (*b == ' ') b++;
|
||||||
|
bool ok = false;
|
||||||
|
if (!strcmp(b, "check")) ok = requestCheck(why, sizeof(why));
|
||||||
|
else if (!strcmp(b, "install")) ok = requestInstall(why, sizeof(why));
|
||||||
|
else if (!strcmp(b, "install force")) ok = bReady(why, sizeof(why), true) && sendOtaCmd(LINK_OTA_CMD_INSTALL, LINK_OTA_FORCE, why, sizeof(why));
|
||||||
|
else if (!strcmp(b, "rollback")) ok = bReady(why, sizeof(why), true) && sendOtaCmd(LINK_OTA_CMD_ROLLBACK, 0, why, sizeof(why));
|
||||||
|
else { help(); return true; }
|
||||||
|
print(ok ? "[link] command sent to Inst. Cluster - watch `link status`" : "[link] refused: %s", why);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
help();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace LinkPeer
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Link Peer Module (Main CTRL) - what A knows about Inst. Cluster, and the
|
||||||
|
* maintenance traffic that keeps B updatable. See
|
||||||
|
* ESP32-S3-LCD-1.3/wiki/pages/controller-b-ota.md (B's wiki).
|
||||||
|
*
|
||||||
|
* STATUS B -> A ESP-NOW unicast every 5 s: B's version, OTA phase, uptime.
|
||||||
|
* Shown on Settings -> Updates as the "Inst. Cluster" card.
|
||||||
|
* PAIR A -> B `link pair` on the console, UART WIRE ONLY: a fresh random
|
||||||
|
* key, kept in NVS on both sides. Both repos are public, so
|
||||||
|
* this is the only secret and it never travels by radio.
|
||||||
|
* SECURE A -> B ESP-NOW unicast, AES-256-GCM under the pairing key:
|
||||||
|
* the remembered Wi-Fi credentials (pushed automatically
|
||||||
|
* whenever B lacks them or they change) and OTA commands.
|
||||||
|
*
|
||||||
|
* Console: link status | pair | unpair | creds | ota check | ota install [force] | ota rollback
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include "protocol/automotive_data.h"
|
||||||
|
|
||||||
|
namespace LinkPeer {
|
||||||
|
|
||||||
|
/** Load the pairing key, hook the ESP-NOW receive path. After EspNowLink::init(). */
|
||||||
|
void init();
|
||||||
|
|
||||||
|
/** Credential sync + logging. Call from loop(). */
|
||||||
|
void tick();
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
bool heard; // STATUS within LINK_STATUS_TIMEOUT_MS
|
||||||
|
uint32_t age_ms; // since the last STATUS
|
||||||
|
uint8_t mac[6]; // B's STA MAC
|
||||||
|
link_status_t st; // last STATUS as received
|
||||||
|
bool paired; // this controller holds a pairing key
|
||||||
|
bool key_match; // B reports the fingerprint of OUR key
|
||||||
|
uint16_t key_fp; // our key's fingerprint (0 = none)
|
||||||
|
} peer_status_t;
|
||||||
|
|
||||||
|
peer_status_t getStatus();
|
||||||
|
|
||||||
|
/** Ask B to check / install (behind the same parking gate as A's own update). */
|
||||||
|
bool requestCheck(char* why, size_t n);
|
||||||
|
bool requestInstall(char* why, size_t n);
|
||||||
|
|
||||||
|
bool handleCommand(const char* line);
|
||||||
|
|
||||||
|
} // namespace LinkPeer
|
||||||
+160
-29
@@ -40,6 +40,8 @@ extern "C" bool verifyRollbackLater() { return true; }
|
|||||||
|
|
||||||
namespace Ota {
|
namespace Ota {
|
||||||
|
|
||||||
|
static void setNoticeProgress(int pct); // defined with the full-screen notice below
|
||||||
|
|
||||||
#define OTA_CONFIRM_S 30 // healthy uptime before a new image is kept
|
#define OTA_CONFIRM_S 30 // healthy uptime before a new image is kept
|
||||||
#define TOSTR_(x) #x
|
#define TOSTR_(x) #x
|
||||||
#define TOSTR(x) TOSTR_(x)
|
#define TOSTR(x) TOSTR_(x)
|
||||||
@@ -70,19 +72,63 @@ static bool g_job_pending = false;
|
|||||||
static job_t g_job = JOB_CHECK;
|
static job_t g_job = JOB_CHECK;
|
||||||
static bool g_pending_verify = false;
|
static bool g_pending_verify = false;
|
||||||
|
|
||||||
|
// What the Settings screen shows. Written by the loop task (jobs) and the LVGL
|
||||||
|
// task (requests), read by the loop task - a spinlock keeps copies consistent.
|
||||||
|
static portMUX_TYPE g_ui_mux = portMUX_INITIALIZER_UNLOCKED;
|
||||||
|
static ui_status_t g_ui = {PHASE_IDLE, "", ""};
|
||||||
|
static char g_last_msg[96] = ""; // last console line, reused as the failure reason
|
||||||
|
|
||||||
|
static void setPhase(phase_t p, const char* latest = NULL, const char* msg = NULL) {
|
||||||
|
portENTER_CRITICAL(&g_ui_mux);
|
||||||
|
g_ui.phase = p;
|
||||||
|
if (latest) { strncpy(g_ui.latest, latest, sizeof(g_ui.latest) - 1); g_ui.latest[sizeof(g_ui.latest) - 1] = 0; }
|
||||||
|
const char* m = msg ? msg : "";
|
||||||
|
strncpy(g_ui.message, m, sizeof(g_ui.message) - 1);
|
||||||
|
g_ui.message[sizeof(g_ui.message) - 1] = 0;
|
||||||
|
portEXIT_CRITICAL(&g_ui_mux);
|
||||||
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// Helpers
|
// Helpers
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
static void print(const char* fmt, ...) {
|
static void vlog(bool remember, const char* fmt, va_list ap) {
|
||||||
char buf[220];
|
char buf[220];
|
||||||
va_list ap;
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vsnprintf(buf, sizeof(buf), fmt, ap);
|
vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||||
va_end(ap);
|
|
||||||
SerialLock::lock();
|
SerialLock::lock();
|
||||||
Serial.println(buf);
|
Serial.println(buf);
|
||||||
SerialLock::unlock();
|
SerialLock::unlock();
|
||||||
|
if (remember) {
|
||||||
|
const char* m = strncmp(buf, "[ota] ", 6) == 0 ? buf + 6 : buf;
|
||||||
|
portENTER_CRITICAL(&g_ui_mux);
|
||||||
|
strncpy(g_last_msg, m, sizeof(g_last_msg) - 1);
|
||||||
|
g_last_msg[sizeof(g_last_msg) - 1] = 0;
|
||||||
|
portEXIT_CRITICAL(&g_ui_mux);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Console line; also kept as the reason the screen shows if the job fails. */
|
||||||
|
static void print(const char* fmt, ...) {
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
vlog(true, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Console-only diagnostics (heap, stack) that must not replace a failure reason. */
|
||||||
|
static void debug(const char* fmt, ...) {
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
vlog(false, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void failPhase() {
|
||||||
|
char m[96];
|
||||||
|
portENTER_CRITICAL(&g_ui_mux);
|
||||||
|
memcpy(m, g_last_msg, sizeof(m));
|
||||||
|
portEXIT_CRITICAL(&g_ui_mux);
|
||||||
|
setPhase(PHASE_FAILED, NULL, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* stateName(esp_ota_img_states_t s) {
|
static const char* stateName(esp_ota_img_states_t s) {
|
||||||
@@ -98,7 +144,7 @@ static const char* stateName(esp_ota_img_states_t s) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The vehicle must be parked to update: installing ends in a reboot that blanks
|
* The vehicle must be parked to update: installing ends in a reboot that blanks
|
||||||
* Controller B's gauges. A silent bus (ignition off, or the bench) counts as
|
* Inst. Cluster's gauges. A silent bus (ignition off, or the bench) counts as
|
||||||
* parked. Lever UNKNOWN is allowed so a missing gear frame can't block a bench
|
* parked. Lever UNKNOWN is allowed so a missing gear frame can't block a bench
|
||||||
* update; engine and output shaft are the checks that matter.
|
* update; engine and output shaft are the checks that matter.
|
||||||
*/
|
*/
|
||||||
@@ -124,17 +170,20 @@ static bool parked(char* why, size_t n) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool gate(bool need_wifi, bool need_parked = true) {
|
static bool gate(bool need_wifi, bool need_parked = true, char* why_out = NULL, size_t why_n = 0) {
|
||||||
char why[96];
|
char why[96];
|
||||||
|
bool ok = true;
|
||||||
if (need_parked && !parked(why, sizeof(why))) {
|
if (need_parked && !parked(why, sizeof(why))) {
|
||||||
|
ok = false;
|
||||||
|
} else if (need_wifi && WiFi.status() != WL_CONNECTED) {
|
||||||
|
snprintf(why, sizeof(why), "Wi-Fi not connected - join a network first");
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
if (!ok) {
|
||||||
print("[ota] refused: %s", why);
|
print("[ota] refused: %s", why);
|
||||||
return false;
|
if (why_out) snprintf(why_out, why_n, "%s", why);
|
||||||
}
|
}
|
||||||
if (need_wifi && WiFi.status() != WL_CONNECTED) {
|
return ok;
|
||||||
print("[ota] refused: Wi-Fi not connected - join a network on the Settings screen first");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void toHex(const uint8_t* in, size_t n, char* out) {
|
static void toHex(const uint8_t* in, size_t n, char* out) {
|
||||||
@@ -335,7 +384,9 @@ static bool writeImage(const manifest_t& m, const esp_partition_t* part) {
|
|||||||
err = esp_ota_write(h, buf, r);
|
err = esp_ota_write(h, buf, r);
|
||||||
if (err != ESP_OK) { print("[ota] flash write: %s", esp_err_to_name(err)); ok = false; break; }
|
if (err != ESP_OK) { print("[ota] flash write: %s", esp_err_to_name(err)); ok = false; break; }
|
||||||
got += r;
|
got += r;
|
||||||
int decile = (int)((uint64_t)got * 10 / m.size);
|
int pct = (int)((uint64_t)got * 100 / m.size);
|
||||||
|
setNoticeProgress(pct);
|
||||||
|
int decile = pct / 10;
|
||||||
if (decile != last_decile) { print("[ota] %d%%", decile * 10); last_decile = decile; }
|
if (decile != last_decile) { print("[ota] %d%%", decile * 10); last_decile = decile; }
|
||||||
}
|
}
|
||||||
http.end();
|
http.end();
|
||||||
@@ -360,10 +411,18 @@ static bool writeImage(const manifest_t& m, const esp_partition_t* part) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ---- Full-screen notice on lv_layer_top() (above every screen) ----------------
|
// ---- Full-screen notice on lv_layer_top() (above every screen) ----------------
|
||||||
|
// Since the core runs with XIP from PSRAM and an IRAM-safe RGB refill ISR
|
||||||
|
// (2026-09-27), flash writes no longer blank the panel, so the screen stays ON
|
||||||
|
// during the download and shows a progress bar. The user must see that the
|
||||||
|
// update is alive; a dark screen invited switching the ignition off mid-write.
|
||||||
static lv_obj_t* g_notice = NULL;
|
static lv_obj_t* g_notice = NULL;
|
||||||
static lv_obj_t* g_notice_lbl = NULL;
|
static lv_obj_t* g_notice_lbl = NULL;
|
||||||
|
static lv_obj_t* g_notice_bar = NULL;
|
||||||
|
static lv_obj_t* g_notice_pct = NULL;
|
||||||
|
static lv_obj_t* g_notice_warn = NULL;
|
||||||
|
static int g_notice_last_pct = -1;
|
||||||
|
|
||||||
static void showNotice(const char* text) {
|
static void showNotice(const char* text, bool with_progress = false) {
|
||||||
lvgl_port_lock(-1);
|
lvgl_port_lock(-1);
|
||||||
if (g_notice == NULL) {
|
if (g_notice == NULL) {
|
||||||
g_notice = lv_obj_create(lv_layer_top());
|
g_notice = lv_obj_create(lv_layer_top());
|
||||||
@@ -372,17 +431,69 @@ static void showNotice(const char* text) {
|
|||||||
lv_obj_set_style_bg_color(g_notice, lv_color_black(), 0);
|
lv_obj_set_style_bg_color(g_notice, lv_color_black(), 0);
|
||||||
lv_obj_set_style_bg_opa(g_notice, LV_OPA_COVER, 0);
|
lv_obj_set_style_bg_opa(g_notice, LV_OPA_COVER, 0);
|
||||||
lv_obj_add_flag(g_notice, LV_OBJ_FLAG_CLICKABLE); // swallow touches while shown
|
lv_obj_add_flag(g_notice, LV_OBJ_FLAG_CLICKABLE); // swallow touches while shown
|
||||||
|
|
||||||
g_notice_lbl = lv_label_create(g_notice);
|
g_notice_lbl = lv_label_create(g_notice);
|
||||||
lv_obj_set_style_text_font(g_notice_lbl, &lv_font_montserrat_30, 0);
|
lv_obj_set_style_text_font(g_notice_lbl, &lv_font_montserrat_30, 0);
|
||||||
lv_obj_set_style_text_color(g_notice_lbl, lv_color_white(), 0);
|
lv_obj_set_style_text_color(g_notice_lbl, lv_color_white(), 0);
|
||||||
lv_obj_set_style_text_align(g_notice_lbl, LV_TEXT_ALIGN_CENTER, 0);
|
lv_obj_set_style_text_align(g_notice_lbl, LV_TEXT_ALIGN_CENTER, 0);
|
||||||
lv_obj_center(g_notice_lbl);
|
lv_obj_align(g_notice_lbl, LV_ALIGN_CENTER, 0, -90);
|
||||||
|
|
||||||
|
g_notice_bar = lv_bar_create(g_notice);
|
||||||
|
lv_obj_set_size(g_notice_bar, 640, 28);
|
||||||
|
lv_obj_align(g_notice_bar, LV_ALIGN_CENTER, 0, 10);
|
||||||
|
lv_bar_set_range(g_notice_bar, 0, 100);
|
||||||
|
lv_bar_set_value(g_notice_bar, 0, LV_ANIM_OFF);
|
||||||
|
lv_obj_set_style_bg_color(g_notice_bar, lv_color_hex(0x252D36), LV_PART_MAIN);
|
||||||
|
lv_obj_set_style_bg_opa(g_notice_bar, LV_OPA_COVER, LV_PART_MAIN);
|
||||||
|
lv_obj_set_style_radius(g_notice_bar, 14, LV_PART_MAIN);
|
||||||
|
lv_obj_set_style_bg_color(g_notice_bar, lv_color_hex(0x3DA9FC), LV_PART_INDICATOR);
|
||||||
|
lv_obj_set_style_bg_opa(g_notice_bar, LV_OPA_COVER, LV_PART_INDICATOR);
|
||||||
|
lv_obj_set_style_radius(g_notice_bar, 14, LV_PART_INDICATOR);
|
||||||
|
|
||||||
|
g_notice_pct = lv_label_create(g_notice);
|
||||||
|
lv_obj_set_style_text_font(g_notice_pct, &lv_font_montserrat_24, 0);
|
||||||
|
lv_obj_set_style_text_color(g_notice_pct, lv_color_white(), 0);
|
||||||
|
lv_label_set_text(g_notice_pct, "0%");
|
||||||
|
lv_obj_align_to(g_notice_pct, g_notice_bar, LV_ALIGN_OUT_BOTTOM_MID, 0, 12);
|
||||||
|
|
||||||
|
g_notice_warn = lv_label_create(g_notice);
|
||||||
|
lv_obj_set_style_text_font(g_notice_warn, &lv_font_montserrat_24, 0);
|
||||||
|
lv_obj_set_style_text_color(g_notice_warn, lv_color_hex(0xF5A524), 0);
|
||||||
|
lv_obj_set_style_text_align(g_notice_warn, LV_TEXT_ALIGN_CENTER, 0);
|
||||||
|
lv_label_set_text(g_notice_warn, LV_SYMBOL_WARNING " Do not switch off the ignition");
|
||||||
|
lv_obj_align(g_notice_warn, LV_ALIGN_CENTER, 0, 130);
|
||||||
}
|
}
|
||||||
lv_label_set_text(g_notice_lbl, text);
|
lv_label_set_text(g_notice_lbl, text);
|
||||||
|
if (with_progress) {
|
||||||
|
lv_bar_set_value(g_notice_bar, 0, LV_ANIM_OFF);
|
||||||
|
lv_label_set_text(g_notice_pct, "0%");
|
||||||
|
lv_obj_clear_flag(g_notice_bar, LV_OBJ_FLAG_HIDDEN);
|
||||||
|
lv_obj_clear_flag(g_notice_pct, LV_OBJ_FLAG_HIDDEN);
|
||||||
|
lv_obj_clear_flag(g_notice_warn, LV_OBJ_FLAG_HIDDEN);
|
||||||
|
} else {
|
||||||
|
lv_obj_add_flag(g_notice_bar, LV_OBJ_FLAG_HIDDEN);
|
||||||
|
lv_obj_add_flag(g_notice_pct, LV_OBJ_FLAG_HIDDEN);
|
||||||
|
lv_obj_add_flag(g_notice_warn, LV_OBJ_FLAG_HIDDEN);
|
||||||
|
}
|
||||||
|
g_notice_last_pct = -1;
|
||||||
lv_obj_clear_flag(g_notice, LV_OBJ_FLAG_HIDDEN);
|
lv_obj_clear_flag(g_notice, LV_OBJ_FLAG_HIDDEN);
|
||||||
lvgl_port_unlock();
|
lvgl_port_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Progress bar update from the download loop (loop task). Cheap: one bar + label. */
|
||||||
|
static void setNoticeProgress(int pct) {
|
||||||
|
if (pct < 0) pct = 0;
|
||||||
|
if (pct > 100) pct = 100;
|
||||||
|
if (pct == g_notice_last_pct || g_notice_bar == NULL) return;
|
||||||
|
g_notice_last_pct = pct;
|
||||||
|
char t[8];
|
||||||
|
snprintf(t, sizeof(t), "%d%%", pct);
|
||||||
|
if (!lvgl_port_lock(50)) return; // never stall the download on the UI lock
|
||||||
|
lv_bar_set_value(g_notice_bar, pct, LV_ANIM_OFF);
|
||||||
|
lv_label_set_text(g_notice_pct, t);
|
||||||
|
lvgl_port_unlock();
|
||||||
|
}
|
||||||
|
|
||||||
static void hideNotice() {
|
static void hideNotice() {
|
||||||
lvgl_port_lock(-1);
|
lvgl_port_lock(-1);
|
||||||
if (g_notice) lv_obj_add_flag(g_notice, LV_OBJ_FLAG_HIDDEN);
|
if (g_notice) lv_obj_add_flag(g_notice, LV_OBJ_FLAG_HIDDEN);
|
||||||
@@ -391,32 +502,32 @@ static void hideNotice() {
|
|||||||
|
|
||||||
static void install(bool force) {
|
static void install(bool force) {
|
||||||
manifest_t m;
|
manifest_t m;
|
||||||
if (!fetchManifest(m) || !verifySignature(m)) return;
|
if (!fetchManifest(m) || !verifySignature(m)) { failPhase(); return; }
|
||||||
|
|
||||||
if (!force && strcmp(m.version, FW_VERSION) == 0) {
|
if (!force && strcmp(m.version, FW_VERSION) == 0) {
|
||||||
print("[ota] already running %s - nothing to do (`ota install force` to reinstall)", FW_VERSION);
|
print("[ota] already running %s - nothing to do (`ota install force` to reinstall)", FW_VERSION);
|
||||||
|
setPhase(PHASE_UP_TO_DATE, m.version);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const esp_partition_t* part = esp_ota_get_next_update_partition(NULL);
|
const esp_partition_t* part = esp_ota_get_next_update_partition(NULL);
|
||||||
if (!part) { print("[ota] no idle OTA slot (partition table?)"); return; }
|
if (!part) { print("[ota] no idle OTA slot (partition table?)"); failPhase(); return; }
|
||||||
if (m.size > part->size) {
|
if (m.size > part->size) {
|
||||||
print("[ota] image %lu B does not fit slot %s (%lu B)",
|
print("[ota] image %lu B does not fit slot %s (%lu B)",
|
||||||
(unsigned long)m.size, part->label, (unsigned long)part->size);
|
(unsigned long)m.size, part->label, (unsigned long)part->size);
|
||||||
|
failPhase();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
print("[ota] installing %s -> %s (%lu bytes)", m.version, part->label, (unsigned long)m.size);
|
print("[ota] installing %s -> %s (%lu bytes)", m.version, part->label, (unsigned long)m.size);
|
||||||
|
|
||||||
// Flash writes stall the PSRAM-fed RGB panel (flicker), so the screen is
|
// The screen stays on: with XIP from PSRAM + an IRAM-safe RGB refill ISR the
|
||||||
// dark while the image is written, with a notice before and after.
|
// flash writes no longer starve the panel (verified 2026-09-27: 24 frames/s
|
||||||
|
// for the whole download). The bar is driven from the download loop.
|
||||||
char msg[160];
|
char msg[160];
|
||||||
snprintf(msg, sizeof(msg), "Updating to %s\n\nThe screen goes dark for about a minute.\nDo not switch off.", m.version);
|
snprintf(msg, sizeof(msg), "Updating to %s", m.version);
|
||||||
showNotice(msg);
|
showNotice(msg, true);
|
||||||
delay(3000); // time to read it; LVGL renders on its own task
|
|
||||||
DisplayInit::setBacklight(false);
|
|
||||||
bool ok = writeImage(m, part);
|
bool ok = writeImage(m, part);
|
||||||
DisplayInit::setBacklight(true);
|
|
||||||
|
|
||||||
// The download took a while - the driver may have started the engine since.
|
// The download took a while - the driver may have started the engine since.
|
||||||
if (ok && !gate(false)) {
|
if (ok && !gate(false)) {
|
||||||
@@ -428,6 +539,7 @@ static void install(bool force) {
|
|||||||
if (err != ESP_OK) { print("[ota] set boot slot: %s", esp_err_to_name(err)); ok = false; }
|
if (err != ESP_OK) { print("[ota] set boot slot: %s", esp_err_to_name(err)); ok = false; }
|
||||||
}
|
}
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
|
failPhase();
|
||||||
snprintf(msg, sizeof(msg), "Update failed\n\nStill running %s", FW_VERSION);
|
snprintf(msg, sizeof(msg), "Update failed\n\nStill running %s", FW_VERSION);
|
||||||
showNotice(msg);
|
showNotice(msg);
|
||||||
delay(5000);
|
delay(5000);
|
||||||
@@ -446,11 +558,12 @@ static void install(bool force) {
|
|||||||
|
|
||||||
static void check() {
|
static void check() {
|
||||||
manifest_t m;
|
manifest_t m;
|
||||||
if (!fetchManifest(m) || !verifySignature(m)) return;
|
if (!fetchManifest(m) || !verifySignature(m)) { failPhase(); return; }
|
||||||
bool same = strcmp(m.version, FW_VERSION) == 0;
|
bool same = strcmp(m.version, FW_VERSION) == 0;
|
||||||
print("[ota] running %s | latest release %s (%lu bytes, signature OK)%s",
|
print("[ota] running %s | latest release %s (%lu bytes, signature OK)%s",
|
||||||
FW_VERSION, m.version, (unsigned long)m.size,
|
FW_VERSION, m.version, (unsigned long)m.size,
|
||||||
same ? " - up to date" : " - `ota install` to update");
|
same ? " - up to date" : " - `ota install` to update");
|
||||||
|
setPhase(same ? PHASE_UP_TO_DATE : PHASE_AVAILABLE, m.version);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This core's mbedtls is built with CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC: every TLS
|
// This core's mbedtls is built with CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC: every TLS
|
||||||
@@ -466,7 +579,7 @@ static void* tlsCallocInternal(size_t n, size_t size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void printHeap(const char* when) {
|
static void printHeap(const char* when) {
|
||||||
print("[ota] heap %s: internal free %u (largest block %u), PSRAM free %u", when,
|
debug("[ota] heap %s: internal free %u (largest block %u), PSRAM free %u", when,
|
||||||
(unsigned)heap_caps_get_free_size(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT),
|
(unsigned)heap_caps_get_free_size(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT),
|
||||||
(unsigned)heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT),
|
(unsigned)heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT),
|
||||||
(unsigned)heap_caps_get_free_size(MALLOC_CAP_SPIRAM));
|
(unsigned)heap_caps_get_free_size(MALLOC_CAP_SPIRAM));
|
||||||
@@ -477,14 +590,20 @@ static void runJob(job_t job) {
|
|||||||
if (job == JOB_CHECK) check();
|
if (job == JOB_CHECK) check();
|
||||||
else install(job == JOB_INSTALL_FORCE);
|
else install(job == JOB_INSTALL_FORCE);
|
||||||
mbedtls_platform_set_calloc_free(tlsCallocInternal, heap_caps_free);
|
mbedtls_platform_set_calloc_free(tlsCallocInternal, heap_caps_free);
|
||||||
print("[ota] loop stack headroom after job: %u B", (unsigned)uxTaskGetStackHighWaterMark(NULL));
|
debug("[ota] loop stack headroom after job: %u B", (unsigned)uxTaskGetStackHighWaterMark(NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void startJob(job_t job) {
|
static bool startJob(job_t job, char* why = NULL, size_t why_n = 0) {
|
||||||
if (!gate(true, job != JOB_CHECK)) return; // checking is harmless; installing needs parked
|
if (g_job_pending) {
|
||||||
|
if (why) snprintf(why, why_n, "busy");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!gate(true, job != JOB_CHECK, why, why_n)) return false; // checking is harmless; installing needs parked
|
||||||
|
setPhase(job == JOB_CHECK ? PHASE_CHECKING : PHASE_INSTALLING);
|
||||||
g_job = job;
|
g_job = job;
|
||||||
g_job_pending = true; // runs on the next tick(), in the loop task
|
g_job_pending = true; // runs on the next tick(), in the loop task
|
||||||
print("[ota] working - console and screen values pause until done");
|
print("[ota] working - console and screen values pause until done");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -556,6 +675,18 @@ static void help() {
|
|||||||
|
|
||||||
const char* version() { return FW_VERSION; }
|
const char* version() { return FW_VERSION; }
|
||||||
|
|
||||||
|
ui_status_t getStatus() {
|
||||||
|
ui_status_t s;
|
||||||
|
portENTER_CRITICAL(&g_ui_mux);
|
||||||
|
s = g_ui;
|
||||||
|
portEXIT_CRITICAL(&g_ui_mux);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool requestCheck(char* why, size_t n) { return startJob(JOB_CHECK, why, n); }
|
||||||
|
bool requestInstall(char* why, size_t n) { return startJob(JOB_INSTALL, why, n); }
|
||||||
|
bool isParked(char* why, size_t n) { return parked(why, n); }
|
||||||
|
|
||||||
void init() {
|
void init() {
|
||||||
const esp_partition_t* run = esp_ota_get_running_partition();
|
const esp_partition_t* run = esp_ota_get_running_partition();
|
||||||
esp_ota_img_states_t st = ESP_OTA_IMG_UNDEFINED;
|
esp_ota_img_states_t st = ESP_OTA_IMG_UNDEFINED;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* ota_update.h - pull firmware updates from this repo's Gitea releases.
|
* ota_update.h - pull firmware updates from this repo's Gitea releases.
|
||||||
*
|
*
|
||||||
* Manual only: nothing checks or installs by itself. The `ota` serial console
|
* Manual only: nothing checks or installs by itself. Driven from the Settings
|
||||||
* drives it today; the planned password-gated Diagnostics screen will call the
|
* screen (Updates section: check, then install behind a confirm dialog) and the
|
||||||
* same functions (wiki/pages/open-questions.md #12).
|
* `ota` serial console.
|
||||||
*
|
*
|
||||||
* ota status running version, slot, rollback state
|
* ota status running version, slot, rollback state
|
||||||
* ota check ask Gitea for the latest release, compare versions
|
* ota check ask Gitea for the latest release, compare versions
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
* or crash before that makes the bootloader fall back to the old slot.
|
* or crash before that makes the bootloader fall back to the old slot.
|
||||||
*
|
*
|
||||||
* Needs Wi-Fi joined to a network with internet (Settings screen). Joining an
|
* Needs Wi-Fi joined to a network with internet (Settings screen). Joining an
|
||||||
* AP moves the radio channel; the ESP-NOW link to Controller B follows it.
|
* AP moves the radio channel; the ESP-NOW link to Inst. Cluster follows it.
|
||||||
* See wiki/pages/ota-updates.md.
|
* See wiki/pages/ota-updates.md.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -43,6 +43,32 @@ bool handleCommand(const char* line);
|
|||||||
/** Firmware version baked in at build time ("dev" for local builds). */
|
/** Firmware version baked in at build time ("dev" for local builds). */
|
||||||
const char* version();
|
const char* version();
|
||||||
|
|
||||||
|
// ---- Settings screen -------------------------------------------------------
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
PHASE_IDLE, // nothing asked yet this boot
|
||||||
|
PHASE_CHECKING,
|
||||||
|
PHASE_UP_TO_DATE, // latest == running
|
||||||
|
PHASE_AVAILABLE, // latest != running
|
||||||
|
PHASE_INSTALLING,
|
||||||
|
PHASE_FAILED // message says why
|
||||||
|
} phase_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
phase_t phase;
|
||||||
|
char latest[32]; // latest release tag, once known
|
||||||
|
char message[96]; // failure reason
|
||||||
|
} ui_status_t;
|
||||||
|
|
||||||
|
ui_status_t getStatus();
|
||||||
|
|
||||||
|
/** Queue a check / install (runs in the loop task). False + reason if refused now. */
|
||||||
|
bool requestCheck(char* why, size_t n);
|
||||||
|
bool requestInstall(char* why, size_t n);
|
||||||
|
|
||||||
|
/** The parking gate on its own (Inst. Cluster's install is guarded by it too). */
|
||||||
|
bool isParked(char* why, size_t n);
|
||||||
|
|
||||||
} // namespace Ota
|
} // namespace Ota
|
||||||
|
|
||||||
#endif // OTA_UPDATE_H
|
#endif // OTA_UPDATE_H
|
||||||
|
|||||||
@@ -0,0 +1,224 @@
|
|||||||
|
/*
|
||||||
|
* Performance Monitor implementation. See perf_monitor.h.
|
||||||
|
*
|
||||||
|
* onFrame()/onFlush() run in the LVGL task; everything else in loop(). The
|
||||||
|
* counters are plain 32-bit words read under a short critical section, so the
|
||||||
|
* hooks cost nothing measurable.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "perf_monitor.h"
|
||||||
|
#include "serial_lock.h"
|
||||||
|
#include "display/lvgl_v8_port.h"
|
||||||
|
#include <lvgl.h>
|
||||||
|
#include <freertos/FreeRTOS.h>
|
||||||
|
#include <freertos/task.h>
|
||||||
|
#include <esp_heap_caps.h>
|
||||||
|
#include <esp_timer.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
namespace PerfMon {
|
||||||
|
|
||||||
|
// ---- accumulators (LVGL task writes, loop reads) ---------------------------
|
||||||
|
static portMUX_TYPE g_mux = portMUX_INITIALIZER_UNLOCKED;
|
||||||
|
static uint32_t g_frames = 0;
|
||||||
|
static uint32_t g_frame_ms_sum = 0;
|
||||||
|
static uint32_t g_frame_ms_max = 0;
|
||||||
|
static uint32_t g_frame_px_sum = 0;
|
||||||
|
static uint32_t g_flushes = 0;
|
||||||
|
static uint32_t g_flush_us_sum = 0;
|
||||||
|
static uint32_t g_flush_px_sum = 0;
|
||||||
|
|
||||||
|
// vsync counters: written from the panel ISR, read from the reporter. 32-bit
|
||||||
|
// aligned loads/stores are atomic on this core; no lock in the ISR.
|
||||||
|
static volatile uint32_t g_vsync_count = 0;
|
||||||
|
static volatile uint32_t g_vsync_gap_max_us = 0;
|
||||||
|
static volatile uint32_t g_vsync_last_us = 0;
|
||||||
|
|
||||||
|
static esp_timer_handle_t g_timer = NULL;
|
||||||
|
|
||||||
|
// ---- window bookkeeping (loop) --------------------------------------------
|
||||||
|
static int64_t g_window_start_us = 0;
|
||||||
|
static uint64_t g_idle_start[2] = {0, 0};
|
||||||
|
static bool g_periodic = false;
|
||||||
|
static uint32_t g_period_ms = 1000;
|
||||||
|
static uint32_t g_last_report_ms = 0;
|
||||||
|
|
||||||
|
static void print(const char* fmt, ...) {
|
||||||
|
char buf[240];
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
SerialLock::lock();
|
||||||
|
Serial.println(buf);
|
||||||
|
SerialLock::unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint64_t idleCounter(int core) {
|
||||||
|
#if CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS
|
||||||
|
// Run-time counter unit is microseconds (esp_timer) on ESP-IDF.
|
||||||
|
return (uint64_t)ulTaskGetIdleRunTimeCounterForCore(core);
|
||||||
|
#else
|
||||||
|
(void)core;
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void timerCallback(void* arg);
|
||||||
|
|
||||||
|
static void resetWindow() {
|
||||||
|
portENTER_CRITICAL(&g_mux);
|
||||||
|
g_frames = g_frame_ms_sum = g_frame_ms_max = g_frame_px_sum = 0;
|
||||||
|
g_flushes = g_flush_us_sum = g_flush_px_sum = 0;
|
||||||
|
portEXIT_CRITICAL(&g_mux);
|
||||||
|
g_vsync_count = 0;
|
||||||
|
g_vsync_gap_max_us = 0;
|
||||||
|
g_window_start_us = esp_timer_get_time();
|
||||||
|
g_idle_start[0] = idleCounter(0);
|
||||||
|
g_idle_start[1] = idleCounter(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void init() {
|
||||||
|
resetWindow();
|
||||||
|
if (!g_timer) {
|
||||||
|
esp_timer_create_args_t a = {};
|
||||||
|
a.callback = timerCallback;
|
||||||
|
a.arg = NULL;
|
||||||
|
a.dispatch_method = ESP_TIMER_TASK;
|
||||||
|
a.name = "perf";
|
||||||
|
esp_timer_create(&a, &g_timer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void onFrame(uint32_t time_ms, uint32_t px) {
|
||||||
|
portENTER_CRITICAL(&g_mux);
|
||||||
|
g_frames++;
|
||||||
|
g_frame_ms_sum += time_ms;
|
||||||
|
if (time_ms > g_frame_ms_max) g_frame_ms_max = time_ms;
|
||||||
|
g_frame_px_sum += px;
|
||||||
|
portEXIT_CRITICAL(&g_mux);
|
||||||
|
}
|
||||||
|
|
||||||
|
void onFlush(uint32_t time_us, uint32_t px) {
|
||||||
|
portENTER_CRITICAL(&g_mux);
|
||||||
|
g_flushes++;
|
||||||
|
g_flush_us_sum += time_us;
|
||||||
|
g_flush_px_sum += px;
|
||||||
|
portEXIT_CRITICAL(&g_mux);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRAM_ATTR onVsync() {
|
||||||
|
uint32_t now = (uint32_t)esp_timer_get_time();
|
||||||
|
uint32_t last = g_vsync_last_us;
|
||||||
|
g_vsync_last_us = now;
|
||||||
|
g_vsync_count = g_vsync_count + 1;
|
||||||
|
if (last != 0) {
|
||||||
|
uint32_t gap = now - last;
|
||||||
|
if (gap > g_vsync_gap_max_us) g_vsync_gap_max_us = gap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Emit one PERF line for the window since the last reset, then reset. */
|
||||||
|
static void report() {
|
||||||
|
int64_t now_us = esp_timer_get_time();
|
||||||
|
uint64_t win_us = (uint64_t)(now_us - g_window_start_us);
|
||||||
|
if (win_us < 1000) win_us = 1000;
|
||||||
|
|
||||||
|
uint32_t frames, ms_sum, ms_max, px_sum, flushes, fl_us, fl_px;
|
||||||
|
portENTER_CRITICAL(&g_mux);
|
||||||
|
frames = g_frames; ms_sum = g_frame_ms_sum; ms_max = g_frame_ms_max; px_sum = g_frame_px_sum;
|
||||||
|
flushes = g_flushes; fl_us = g_flush_us_sum; fl_px = g_flush_px_sum;
|
||||||
|
portEXIT_CRITICAL(&g_mux);
|
||||||
|
|
||||||
|
uint32_t vsyncs = g_vsync_count;
|
||||||
|
uint32_t vgap = g_vsync_gap_max_us;
|
||||||
|
unsigned vsync_per_s = (unsigned)((uint64_t)vsyncs * 1000000ULL / win_us);
|
||||||
|
|
||||||
|
uint64_t idle0 = idleCounter(0) - g_idle_start[0];
|
||||||
|
uint64_t idle1 = idleCounter(1) - g_idle_start[1];
|
||||||
|
unsigned idle0_pct = (unsigned)((idle0 * 100) / win_us);
|
||||||
|
unsigned idle1_pct = (unsigned)((idle1 * 100) / win_us);
|
||||||
|
if (idle0_pct > 100) idle0_pct = 100;
|
||||||
|
if (idle1_pct > 100) idle1_pct = 100;
|
||||||
|
|
||||||
|
// fps x10 for one decimal without floats in the format
|
||||||
|
unsigned fps10 = (unsigned)((uint64_t)frames * 10000000ULL / win_us);
|
||||||
|
unsigned avg_ms10 = frames ? (ms_sum * 10) / frames : 0;
|
||||||
|
unsigned kpx = frames ? (px_sum / frames) / 1000 : 0;
|
||||||
|
unsigned flush_ms_per_s = (unsigned)(((uint64_t)fl_us * 1000ULL) / win_us); // ms of copying per second
|
||||||
|
|
||||||
|
unsigned lv_idle = 0;
|
||||||
|
if (lvgl_port_lock_available()) {
|
||||||
|
lv_idle = lv_timer_get_idle();
|
||||||
|
}
|
||||||
|
|
||||||
|
print("PERF,%lu,%u.%u,%u.%u,%lu,%u,%u,%u,%u,%u,%u,%u,%u,%u,%lu",
|
||||||
|
(unsigned long)millis(),
|
||||||
|
fps10 / 10, fps10 % 10,
|
||||||
|
avg_ms10 / 10, avg_ms10 % 10,
|
||||||
|
(unsigned long)ms_max,
|
||||||
|
kpx,
|
||||||
|
flush_ms_per_s,
|
||||||
|
lv_idle,
|
||||||
|
idle0_pct, idle1_pct,
|
||||||
|
(unsigned)heap_caps_get_free_size(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT),
|
||||||
|
(unsigned)heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT),
|
||||||
|
(unsigned)heap_caps_get_free_size(MALLOC_CAP_SPIRAM),
|
||||||
|
vsync_per_s, (unsigned long)vgap);
|
||||||
|
(void)flushes; (void)fl_px;
|
||||||
|
resetWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void help() {
|
||||||
|
print("perf one PERF line for the window since the last report");
|
||||||
|
print("perf on [sec] PERF line every <sec> seconds (default 1) while you provoke symptoms");
|
||||||
|
print("perf off");
|
||||||
|
print("PERF,ts,fps,avg_ms,max_ms,kpx/frame,flush_ms/s,lvgl_idle%%,idle0%%,idle1%%,int_free,int_largest,psram_free,vsync/s,vsync_gap_max_us");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool handleCommand(const char* line) {
|
||||||
|
char buf[48];
|
||||||
|
strncpy(buf, line, sizeof(buf) - 1);
|
||||||
|
buf[sizeof(buf) - 1] = 0;
|
||||||
|
char* argv[3] = {0};
|
||||||
|
int argc = 0;
|
||||||
|
for (char* tok = strtok(buf, " \t"); tok && argc < 3; tok = strtok(NULL, " \t")) argv[argc++] = tok;
|
||||||
|
if (argc == 0 || strcmp(argv[0], "perf") != 0) return false;
|
||||||
|
|
||||||
|
if (argc == 1) { report(); return true; }
|
||||||
|
if (!strcmp(argv[1], "help")) { help(); return true; }
|
||||||
|
if (!strcmp(argv[1], "on")) {
|
||||||
|
long s = (argc == 3) ? strtol(argv[2], NULL, 10) : 1;
|
||||||
|
if (s < 1) s = 1;
|
||||||
|
if (s > 60) s = 60;
|
||||||
|
g_period_ms = (uint32_t)s * 1000;
|
||||||
|
g_periodic = true;
|
||||||
|
g_last_report_ms = millis();
|
||||||
|
resetWindow();
|
||||||
|
// esp_timer, not loop(): the OTA job blocks loop() for the whole download
|
||||||
|
// and that is exactly when we want to see the panel counters.
|
||||||
|
if (g_timer) esp_timer_stop(g_timer);
|
||||||
|
if (g_timer) esp_timer_start_periodic(g_timer, (uint64_t)g_period_ms * 1000ULL);
|
||||||
|
print("[perf] periodic every %ld s (columns: ts,fps,avg_ms,max_ms,kpx,flush_ms/s,lv_idle,idle0,idle1,int_free,int_largest,psram,vsync/s,vsync_gap_max_us)", s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!strcmp(argv[1], "off")) {
|
||||||
|
g_periodic = false;
|
||||||
|
if (g_timer) esp_timer_stop(g_timer);
|
||||||
|
print("[perf] periodic off");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
help();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void timerCallback(void* arg) {
|
||||||
|
(void)arg;
|
||||||
|
if (g_periodic) report();
|
||||||
|
}
|
||||||
|
|
||||||
|
void tick() {
|
||||||
|
// Reporting moved to the esp_timer (see handleCommand "on").
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace PerfMon
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Performance Monitor
|
||||||
|
*
|
||||||
|
* Measures what the display pipeline actually does, so display experiments
|
||||||
|
* (bounce buffers, draw-buffer size, XIP from PSRAM - wiki open question #13)
|
||||||
|
* can be compared with numbers instead of impressions:
|
||||||
|
*
|
||||||
|
* - render frames/s and ms per frame (LVGL's monitor_cb: render + flush)
|
||||||
|
* - time spent copying pixels into the PSRAM framebuffer (flush_cb)
|
||||||
|
* - LVGL task idle % (lv_timer_get_idle)
|
||||||
|
* - CPU idle % per core (FreeRTOS run-time stats)
|
||||||
|
* - internal heap, largest block, PSRAM free
|
||||||
|
*
|
||||||
|
* Console:
|
||||||
|
* perf one line for the last window
|
||||||
|
* perf on [sec] print a PERF, line every <sec> s (default 1) - use while
|
||||||
|
* provoking symptoms (Wi-Fi scan, tuning save, OTA)
|
||||||
|
* perf off
|
||||||
|
*
|
||||||
|
* PERF line (CSV, greppable like CANRAW):
|
||||||
|
* PERF,<ts_ms>,<fps>,<avg_ms>,<max_ms>,<kpx/frame>,<flush_ms/s>,
|
||||||
|
* <lvgl_idle%>,<idle0%>,<idle1%>,<int_free>,<int_largest>,<psram_free>,
|
||||||
|
* <vsync/s>,<vsync_gap_max_us>
|
||||||
|
* vsync/s is the panel's own refresh rate (constant when healthy);
|
||||||
|
* vsync_gap_max_us is the longest interval between two refreshes in the
|
||||||
|
* window - a DMA underrun/restart stretches it.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
namespace PerfMon {
|
||||||
|
|
||||||
|
/** Call once in setup(), before the LVGL port starts. */
|
||||||
|
void init();
|
||||||
|
|
||||||
|
/** Hook for lv_disp_drv_t::monitor_cb - one rendered frame (ms, pixels). */
|
||||||
|
void onFrame(uint32_t time_ms, uint32_t px);
|
||||||
|
|
||||||
|
/** Hook for the flush callback - one pixel copy into the framebuffer. */
|
||||||
|
void onFlush(uint32_t time_us, uint32_t px);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook for the RGB panel's refresh-finished (vsync) interrupt. ISR context:
|
||||||
|
* counts frames the panel actually completed and the longest gap between two,
|
||||||
|
* which is where a DMA underrun / restart (flicker, dots) shows up.
|
||||||
|
*/
|
||||||
|
void onVsync();
|
||||||
|
|
||||||
|
/** Console line beginning with "perf". */
|
||||||
|
bool handleCommand(const char* line);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kept for compatibility; periodic reporting now runs from an esp_timer so it
|
||||||
|
* survives a blocked loop() (the OTA job). Safe to call, does nothing.
|
||||||
|
*/
|
||||||
|
void tick();
|
||||||
|
|
||||||
|
} // namespace PerfMon
|
||||||
@@ -19,6 +19,8 @@ static const char* NVS_KEY_WIFI_ENABLED = "wifi_en";
|
|||||||
static const char* NVS_KEY_UART_ENABLED = "uart_en";
|
static const char* NVS_KEY_UART_ENABLED = "uart_en";
|
||||||
static const char* NVS_KEY_DEBUG_ENABLED = "debug_en";
|
static const char* NVS_KEY_DEBUG_ENABLED = "debug_en";
|
||||||
static const char* NVS_KEY_CAN_ENABLED = "can_en";
|
static const char* NVS_KEY_CAN_ENABLED = "can_en";
|
||||||
|
static const char* NVS_KEY_DIFFLOCK_ENABLED = "difflock_en";
|
||||||
|
static const char* NVS_KEY_DIFFLOCK_INVERT = "difflock_inv";
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// PUBLIC API IMPLEMENTATION
|
// PUBLIC API IMPLEMENTATION
|
||||||
@@ -89,4 +91,32 @@ bool loadCANState() {
|
|||||||
return enabled;
|
return enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void saveDiffLockState(bool enabled) {
|
||||||
|
preferences.begin(NVS_NAMESPACE, false); // read-write mode
|
||||||
|
preferences.putBool(NVS_KEY_DIFFLOCK_ENABLED, enabled);
|
||||||
|
preferences.end();
|
||||||
|
Serial.printf("[SettingsManager] Saved DiffLock state = %s\n", enabled ? "ON" : "OFF");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool loadDiffLockState() {
|
||||||
|
preferences.begin(NVS_NAMESPACE, true); // read-only mode
|
||||||
|
bool enabled = preferences.getBool(NVS_KEY_DIFFLOCK_ENABLED, false); // default: OFF
|
||||||
|
preferences.end();
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void saveDiffLockInvert(bool inverted) {
|
||||||
|
preferences.begin(NVS_NAMESPACE, false); // read-write mode
|
||||||
|
preferences.putBool(NVS_KEY_DIFFLOCK_INVERT, inverted);
|
||||||
|
preferences.end();
|
||||||
|
Serial.printf("[SettingsManager] Saved DiffLock polarity = %s\n", inverted ? "INVERTED" : "normal");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool loadDiffLockInvert() {
|
||||||
|
preferences.begin(NVS_NAMESPACE, true); // read-only mode
|
||||||
|
bool inverted = preferences.getBool(NVS_KEY_DIFFLOCK_INVERT, false); // default: current = locked
|
||||||
|
preferences.end();
|
||||||
|
return inverted;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace SettingsManager
|
} // namespace SettingsManager
|
||||||
|
|||||||
@@ -66,4 +66,12 @@ void saveCANState(bool enabled);
|
|||||||
*/
|
*/
|
||||||
bool loadCANState();
|
bool loadCANState();
|
||||||
|
|
||||||
|
/** Diff-lock inputs DI0/DI1 read (DiffLocks). Default OFF. */
|
||||||
|
void saveDiffLockState(bool enabled);
|
||||||
|
bool loadDiffLockState();
|
||||||
|
|
||||||
|
/** Diff-lock polarity: true = no current means locked. Default false. */
|
||||||
|
void saveDiffLockInvert(bool inverted);
|
||||||
|
bool loadDiffLockInvert();
|
||||||
|
|
||||||
} // namespace SettingsManager
|
} // namespace SettingsManager
|
||||||
|
|||||||
@@ -0,0 +1,944 @@
|
|||||||
|
/*
|
||||||
|
* Settings Screen Module Implementation - see settings_screen.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "settings_screen.h"
|
||||||
|
#include "ui_kit.h"
|
||||||
|
#include "driveline_screen.h"
|
||||||
|
#include "wifi_manager.h"
|
||||||
|
#include "ota_update.h"
|
||||||
|
#include "link_peer.h"
|
||||||
|
#include "diff_locks.h"
|
||||||
|
#include "uart_manager.h"
|
||||||
|
#include "espnow_link.h"
|
||||||
|
#include "settings_manager.h"
|
||||||
|
#include "ui_state_manager.h"
|
||||||
|
#include "drivers/can_driver.h"
|
||||||
|
#include "display/lvgl_v8_port.h"
|
||||||
|
#include "config/ota_config.h"
|
||||||
|
#include <esp_ota_ops.h>
|
||||||
|
#include <esp_heap_caps.h>
|
||||||
|
|
||||||
|
namespace SettingsScreen {
|
||||||
|
|
||||||
|
using namespace UiKit;
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// LAYOUT
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
static const lv_coord_t NAV_X = 16, NAV_W = 240, NAV_H = 100;
|
||||||
|
static const lv_coord_t TOP_Y = 88;
|
||||||
|
static const lv_coord_t PAGE_X = 272, PAGE_W = 736, PAGE_H = 600 - TOP_Y - 28; // version label below
|
||||||
|
|
||||||
|
typedef enum { PAGE_WIFI, PAGE_UPDATES, PAGE_SYSTEM, PAGE_COUNT } page_t;
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// MODULE STATE
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
static lv_obj_t* g_screen = NULL;
|
||||||
|
static lv_obj_t* g_nav[PAGE_COUNT];
|
||||||
|
static lv_obj_t* g_nav_sub[PAGE_COUNT];
|
||||||
|
static lv_obj_t* g_page[PAGE_COUNT];
|
||||||
|
static page_t g_cur = PAGE_WIFI;
|
||||||
|
static bool g_refreshing = false; // setting widget states from code: ignore their events
|
||||||
|
|
||||||
|
// Wi-Fi page
|
||||||
|
static lv_obj_t* g_wifi_sw = NULL;
|
||||||
|
static lv_obj_t* g_wifi_off_note = NULL;
|
||||||
|
static lv_obj_t* g_wifi_body = NULL;
|
||||||
|
static lv_obj_t* g_st_icon = NULL;
|
||||||
|
static lv_obj_t* g_st_spinner = NULL;
|
||||||
|
static lv_obj_t* g_st_title = NULL;
|
||||||
|
static lv_obj_t* g_st_detail = NULL;
|
||||||
|
static lv_obj_t* g_st_connect = NULL;
|
||||||
|
static lv_obj_t* g_st_forget = NULL;
|
||||||
|
static lv_obj_t* g_scan_btn = NULL;
|
||||||
|
static lv_obj_t* g_list = NULL;
|
||||||
|
static lv_obj_t* g_list_note = NULL;
|
||||||
|
static WiFiManager::network_t g_rows[WIFI_SCAN_MAX_NETWORKS];
|
||||||
|
static uint8_t g_row_count = 0;
|
||||||
|
static uint32_t g_list_gen = 0xFFFFFFFF;
|
||||||
|
static char g_list_connected[33] = "";
|
||||||
|
static bool g_want_scan = false;
|
||||||
|
|
||||||
|
// Password entry (full-screen overlay on this screen)
|
||||||
|
static lv_obj_t* g_pw = NULL;
|
||||||
|
static lv_obj_t* g_pw_title = NULL;
|
||||||
|
static lv_obj_t* g_pw_ta = NULL;
|
||||||
|
static lv_obj_t* g_pw_show = NULL;
|
||||||
|
static char g_pw_ssid[33] = "";
|
||||||
|
|
||||||
|
// Updates page
|
||||||
|
static lv_obj_t* g_upd_latest = NULL;
|
||||||
|
static lv_obj_t* g_upd_state = NULL;
|
||||||
|
static lv_obj_t* g_upd_check = NULL;
|
||||||
|
static lv_obj_t* g_upd_install = NULL;
|
||||||
|
static lv_obj_t* g_upd_wifi = NULL;
|
||||||
|
static char g_upd_refusal[96] = "";
|
||||||
|
static Ota::phase_t g_upd_refusal_phase = Ota::PHASE_IDLE;
|
||||||
|
|
||||||
|
// System page
|
||||||
|
static lv_obj_t* g_sys_can = NULL;
|
||||||
|
static lv_obj_t* g_sys_link = NULL;
|
||||||
|
static lv_obj_t* g_sys_dbg = NULL;
|
||||||
|
static lv_obj_t* g_sys_diff = NULL;
|
||||||
|
static lv_obj_t* g_sys_diff_inv = NULL; // polarity: no current = locked
|
||||||
|
static lv_obj_t* g_sys_diff_sub = NULL; // sub-line of the diff-lock row: live state
|
||||||
|
static lv_obj_t* g_sys_info = NULL; // values column; keys are static
|
||||||
|
|
||||||
|
static void refresh(bool force);
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// NAVIGATION
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
static void selectPage(page_t p) {
|
||||||
|
g_cur = p;
|
||||||
|
for (int i = 0; i < PAGE_COUNT; i++) {
|
||||||
|
bool on = (i == p);
|
||||||
|
setVisible(g_page[i], on);
|
||||||
|
lv_obj_set_style_bg_opa(g_nav[i], on ? LV_OPA_COVER : LV_OPA_TRANSP, 0);
|
||||||
|
lv_obj_set_style_border_width(g_nav[i], on ? 5 : 0, 0);
|
||||||
|
}
|
||||||
|
if (p == PAGE_WIFI) g_want_scan = true;
|
||||||
|
refresh(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void onNav(lv_event_t* e) {
|
||||||
|
selectPage((page_t)(uintptr_t)lv_event_get_user_data(e));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void onBack(lv_event_t* e) {
|
||||||
|
(void)e;
|
||||||
|
DrivelineScreen::show();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void onGesture(lv_event_t* e) {
|
||||||
|
(void)e;
|
||||||
|
if (g_pw && !lv_obj_has_flag(g_pw, LV_OBJ_FLAG_HIDDEN)) return; // typing a password
|
||||||
|
if (lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_RIGHT) {
|
||||||
|
lv_indev_wait_release(lv_indev_get_act());
|
||||||
|
DrivelineScreen::show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static lv_obj_t* makeNav(lv_obj_t* parent, page_t p, const char* title) {
|
||||||
|
lv_obj_t* n = lv_obj_create(parent);
|
||||||
|
lv_obj_set_size(n, NAV_W, NAV_H);
|
||||||
|
lv_obj_set_pos(n, NAV_X, TOP_Y + p * (NAV_H + 12));
|
||||||
|
lv_obj_set_style_radius(n, 12, 0);
|
||||||
|
lv_obj_set_style_bg_color(n, UI_COL_PANEL, 0);
|
||||||
|
lv_obj_set_style_bg_opa(n, LV_OPA_TRANSP, 0);
|
||||||
|
lv_obj_set_style_bg_color(n, UI_COL_PANEL2, LV_STATE_PRESSED);
|
||||||
|
lv_obj_set_style_bg_opa(n, LV_OPA_COVER, LV_STATE_PRESSED);
|
||||||
|
lv_obj_set_style_border_side(n, LV_BORDER_SIDE_LEFT, 0);
|
||||||
|
lv_obj_set_style_border_color(n, UI_COL_ACCENT, 0);
|
||||||
|
lv_obj_set_style_border_width(n, 0, 0);
|
||||||
|
lv_obj_set_style_shadow_width(n, 0, 0);
|
||||||
|
lv_obj_set_style_pad_left(n, 20, 0);
|
||||||
|
lv_obj_set_style_pad_ver(n, 18, 0);
|
||||||
|
lv_obj_set_flex_flow(n, LV_FLEX_FLOW_COLUMN);
|
||||||
|
lv_obj_set_flex_align(n, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START);
|
||||||
|
lv_obj_set_style_pad_row(n, 6, 0);
|
||||||
|
lv_obj_clear_flag(n, LV_OBJ_FLAG_SCROLLABLE);
|
||||||
|
lv_obj_add_flag(n, LV_OBJ_FLAG_CLICKABLE);
|
||||||
|
lv_obj_add_event_cb(n, onNav, LV_EVENT_CLICKED, (void*)(uintptr_t)p);
|
||||||
|
|
||||||
|
label(n, title, &lv_font_montserrat_24, UI_COL_TEXT);
|
||||||
|
g_nav_sub[p] = label(n, "", &lv_font_montserrat_20, UI_COL_MUTED);
|
||||||
|
lv_label_set_long_mode(g_nav_sub[p], LV_LABEL_LONG_DOT);
|
||||||
|
lv_obj_set_width(g_nav_sub[p], NAV_W - 40);
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
static lv_obj_t* makePage(lv_obj_t* parent) {
|
||||||
|
lv_obj_t* p = box(parent, LV_FLEX_FLOW_COLUMN);
|
||||||
|
lv_obj_set_size(p, PAGE_W, PAGE_H);
|
||||||
|
lv_obj_set_pos(p, PAGE_X, TOP_Y);
|
||||||
|
lv_obj_set_style_pad_row(p, 12, 0);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** "Title" on the left, a widget (switch) on the right, optional sub-line. */
|
||||||
|
static lv_obj_t* makeSettingRow(lv_obj_t* parent, const char* title, const char* sub, lv_obj_t** right_parent) {
|
||||||
|
lv_obj_t* row = box(parent, LV_FLEX_FLOW_ROW);
|
||||||
|
lv_obj_set_size(row, LV_PCT(100), LV_SIZE_CONTENT);
|
||||||
|
lv_obj_set_flex_align(row, LV_FLEX_ALIGN_SPACE_BETWEEN, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
|
||||||
|
lv_obj_set_style_min_height(row, 64, 0);
|
||||||
|
|
||||||
|
lv_obj_t* col = box(row, LV_FLEX_FLOW_COLUMN);
|
||||||
|
lv_obj_set_size(col, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
|
||||||
|
lv_obj_set_style_pad_row(col, 4, 0);
|
||||||
|
label(col, title, &lv_font_montserrat_24, UI_COL_TEXT);
|
||||||
|
if (sub) label(col, sub, &lv_font_montserrat_20, UI_COL_MUTED);
|
||||||
|
*right_parent = row;
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// WI-FI PAGE
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
static void onWifiSwitch(lv_event_t* e) {
|
||||||
|
if (g_refreshing) return;
|
||||||
|
bool on = lv_obj_has_state(lv_event_get_target(e), LV_STATE_CHECKED);
|
||||||
|
WiFiManager::setEnabled(on);
|
||||||
|
if (on) g_want_scan = true;
|
||||||
|
refresh(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void onScan(lv_event_t* e) {
|
||||||
|
(void)e;
|
||||||
|
WiFiManager::requestScan();
|
||||||
|
refresh(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void onConnectSaved(lv_event_t* e) {
|
||||||
|
(void)e;
|
||||||
|
WiFiManager::connectSaved();
|
||||||
|
refresh(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void onForgetConfirmed(bool ok, void* user) {
|
||||||
|
(void)user;
|
||||||
|
if (!ok) return;
|
||||||
|
WiFiManager::forget();
|
||||||
|
g_want_scan = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void onForget(lv_event_t* e) {
|
||||||
|
(void)e;
|
||||||
|
WiFiManager::status_t s = WiFiManager::getStatus();
|
||||||
|
char text[128];
|
||||||
|
snprintf(text, sizeof(text), "Main CTRL will no longer join \"%s\" by itself.", s.saved_ssid);
|
||||||
|
confirm("Forget this network?", text, "Forget", onForgetConfirmed, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void openPassword(const char* ssid) {
|
||||||
|
snprintf(g_pw_ssid, sizeof(g_pw_ssid), "%s", ssid);
|
||||||
|
char t[64];
|
||||||
|
snprintf(t, sizeof(t), "Join \"%s\"", ssid);
|
||||||
|
lv_label_set_text(g_pw_title, t);
|
||||||
|
lv_textarea_set_text(g_pw_ta, "");
|
||||||
|
lv_textarea_set_password_mode(g_pw_ta, true);
|
||||||
|
setButtonText(g_pw_show, LV_SYMBOL_EYE_OPEN " Show");
|
||||||
|
setVisible(g_pw, true);
|
||||||
|
lv_obj_move_foreground(g_pw);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void closePassword() {
|
||||||
|
lv_textarea_set_text(g_pw_ta, ""); // don't leave the password in a widget
|
||||||
|
setVisible(g_pw, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void submitPassword() {
|
||||||
|
const char* pw = lv_textarea_get_text(g_pw_ta);
|
||||||
|
if (pw == NULL || pw[0] == 0) return;
|
||||||
|
WiFiManager::connect(g_pw_ssid, pw);
|
||||||
|
closePassword();
|
||||||
|
refresh(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void onPwKeyboard(lv_event_t* e) {
|
||||||
|
lv_event_code_t code = lv_event_get_code(e);
|
||||||
|
if (code == LV_EVENT_READY) submitPassword();
|
||||||
|
else if (code == LV_EVENT_CANCEL) closePassword();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void onPwConnect(lv_event_t* e) { (void)e; submitPassword(); }
|
||||||
|
static void onPwCancel(lv_event_t* e) { (void)e; closePassword(); }
|
||||||
|
|
||||||
|
static void onPwShow(lv_event_t* e) {
|
||||||
|
(void)e;
|
||||||
|
bool hidden = lv_textarea_get_password_mode(g_pw_ta);
|
||||||
|
lv_textarea_set_password_mode(g_pw_ta, !hidden);
|
||||||
|
setButtonText(g_pw_show, hidden ? LV_SYMBOL_EYE_CLOSE " Hide" : LV_SYMBOL_EYE_OPEN " Show");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void onNetworkRow(lv_event_t* e) {
|
||||||
|
uint8_t i = (uint8_t)(uintptr_t)lv_event_get_user_data(e);
|
||||||
|
if (i >= g_row_count) return;
|
||||||
|
const WiFiManager::network_t& n = g_rows[i];
|
||||||
|
if (strcmp(n.ssid, g_list_connected) == 0) return; // already on it
|
||||||
|
if (n.secured) {
|
||||||
|
openPassword(n.ssid);
|
||||||
|
} else {
|
||||||
|
WiFiManager::connect(n.ssid, "");
|
||||||
|
refresh(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char* strengthWord(int rssi) {
|
||||||
|
if (rssi >= -55) return "Strong";
|
||||||
|
if (rssi >= -67) return "Good";
|
||||||
|
if (rssi >= -77) return "Fair";
|
||||||
|
return "Weak";
|
||||||
|
}
|
||||||
|
|
||||||
|
static lv_color_t strengthColour(int rssi) {
|
||||||
|
if (rssi >= -67) return UI_COL_OK;
|
||||||
|
if (rssi >= -77) return UI_COL_AMBER;
|
||||||
|
return UI_COL_WARN;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rebuildList(const WiFiManager::status_t& s) {
|
||||||
|
g_row_count = WiFiManager::getNetworks(g_rows, WIFI_SCAN_MAX_NETWORKS);
|
||||||
|
g_list_gen = s.scan_gen;
|
||||||
|
snprintf(g_list_connected, sizeof(g_list_connected), "%s", s.link == WiFiManager::LINK_CONNECTED ? s.ssid : "");
|
||||||
|
|
||||||
|
lv_obj_clean(g_list);
|
||||||
|
for (uint8_t i = 0; i < g_row_count; i++) {
|
||||||
|
const WiFiManager::network_t& n = g_rows[i];
|
||||||
|
bool connected = strcmp(n.ssid, g_list_connected) == 0;
|
||||||
|
|
||||||
|
lv_obj_t* row = lv_obj_create(g_list);
|
||||||
|
lv_obj_set_size(row, LV_PCT(100), 64);
|
||||||
|
lv_obj_set_style_bg_color(row, UI_COL_PANEL, 0);
|
||||||
|
lv_obj_set_style_bg_color(row, UI_COL_PANEL2, LV_STATE_PRESSED);
|
||||||
|
lv_obj_set_style_border_width(row, 0, 0);
|
||||||
|
lv_obj_set_style_shadow_width(row, 0, 0);
|
||||||
|
lv_obj_set_style_radius(row, 10, 0);
|
||||||
|
lv_obj_set_style_pad_hor(row, 18, 0);
|
||||||
|
lv_obj_set_style_pad_ver(row, 0, 0);
|
||||||
|
lv_obj_set_style_pad_column(row, 16, 0);
|
||||||
|
lv_obj_set_flex_flow(row, LV_FLEX_FLOW_ROW);
|
||||||
|
lv_obj_set_flex_align(row, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
|
||||||
|
lv_obj_clear_flag(row, LV_OBJ_FLAG_SCROLLABLE);
|
||||||
|
lv_obj_add_flag(row, LV_OBJ_FLAG_CLICKABLE);
|
||||||
|
lv_obj_add_event_cb(row, onNetworkRow, LV_EVENT_CLICKED, (void*)(uintptr_t)i);
|
||||||
|
|
||||||
|
label(row, LV_SYMBOL_WIFI, &lv_font_montserrat_24, strengthColour(n.rssi));
|
||||||
|
lv_obj_t* name = label(row, n.ssid, &lv_font_montserrat_24, UI_COL_TEXT);
|
||||||
|
lv_label_set_long_mode(name, LV_LABEL_LONG_DOT);
|
||||||
|
lv_obj_set_flex_grow(name, 1);
|
||||||
|
|
||||||
|
char right[40];
|
||||||
|
if (connected) snprintf(right, sizeof(right), LV_SYMBOL_OK " Connected");
|
||||||
|
else snprintf(right, sizeof(right), "%s %s", strengthWord(n.rssi), n.secured ? "Secured" : "Open");
|
||||||
|
label(row, right, &lv_font_montserrat_20, connected ? UI_COL_OK : UI_COL_MUTED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void refreshWifi() {
|
||||||
|
WiFiManager::status_t s = WiFiManager::getStatus();
|
||||||
|
bool on = s.link != WiFiManager::LINK_OFF;
|
||||||
|
|
||||||
|
setChecked(g_wifi_sw, on);
|
||||||
|
setVisible(g_wifi_off_note, !on);
|
||||||
|
setVisible(g_wifi_body, on);
|
||||||
|
if (!on) return;
|
||||||
|
|
||||||
|
// Scan when the page opens (not while connected: a scan hops channels
|
||||||
|
// under the ESP-NOW link - the Scan button still works then).
|
||||||
|
if (g_want_scan && (s.link == WiFiManager::LINK_IDLE || s.link == WiFiManager::LINK_FAILED)) {
|
||||||
|
g_want_scan = false;
|
||||||
|
WiFiManager::requestScan();
|
||||||
|
s = WiFiManager::getStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- status card
|
||||||
|
char title[80], detail[96];
|
||||||
|
bool spinner = false, show_connect = false, show_forget = s.saved_ssid[0] != 0;
|
||||||
|
const char* icon = LV_SYMBOL_WIFI;
|
||||||
|
lv_color_t icon_col = UI_COL_MUTED;
|
||||||
|
switch (s.link) {
|
||||||
|
case WiFiManager::LINK_CONNECTED:
|
||||||
|
snprintf(title, sizeof(title), "Connected to %s", s.ssid);
|
||||||
|
snprintf(detail, sizeof(detail), "IP %s \xE2\x80\xA2 signal %s (%d dBm)", s.ip, strengthWord(s.rssi), s.rssi);
|
||||||
|
icon_col = UI_COL_OK;
|
||||||
|
break;
|
||||||
|
case WiFiManager::LINK_CONNECTING:
|
||||||
|
snprintf(title, sizeof(title), "Connecting to %s...", s.ssid);
|
||||||
|
snprintf(detail, sizeof(detail), "This takes up to 15 seconds.");
|
||||||
|
spinner = true;
|
||||||
|
show_forget = false;
|
||||||
|
break;
|
||||||
|
case WiFiManager::LINK_FAILED:
|
||||||
|
snprintf(title, sizeof(title), "Couldn't connect to %s", s.ssid);
|
||||||
|
snprintf(detail, sizeof(detail), "%s", s.error);
|
||||||
|
icon = LV_SYMBOL_WARNING;
|
||||||
|
icon_col = UI_COL_WARN;
|
||||||
|
show_connect = s.saved_ssid[0] != 0;
|
||||||
|
break;
|
||||||
|
default: // IDLE
|
||||||
|
if (s.saved_ssid[0]) {
|
||||||
|
snprintf(title, sizeof(title), "Not connected");
|
||||||
|
snprintf(detail, sizeof(detail), "Saved network: %s", s.saved_ssid);
|
||||||
|
show_connect = true;
|
||||||
|
} else {
|
||||||
|
snprintf(title, sizeof(title), "Not connected");
|
||||||
|
snprintf(detail, sizeof(detail), "Pick a network below. It is remembered once it works.");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
setText(g_st_title, title);
|
||||||
|
setText(g_st_detail, detail);
|
||||||
|
setText(g_st_icon, icon);
|
||||||
|
setTextColor(g_st_icon, icon_col);
|
||||||
|
setVisible(g_st_icon, !spinner);
|
||||||
|
setVisible(g_st_spinner, spinner);
|
||||||
|
setVisible(g_st_connect, show_connect);
|
||||||
|
setVisible(g_st_forget, show_forget);
|
||||||
|
|
||||||
|
// ---- scan button + list
|
||||||
|
setButtonText(g_scan_btn, s.scanning ? "Scanning..." : LV_SYMBOL_REFRESH " Scan");
|
||||||
|
if (s.scanning || s.link == WiFiManager::LINK_CONNECTING) lv_obj_add_state(g_scan_btn, LV_STATE_DISABLED);
|
||||||
|
else lv_obj_clear_state(g_scan_btn, LV_STATE_DISABLED);
|
||||||
|
|
||||||
|
const char* connected_now = s.link == WiFiManager::LINK_CONNECTED ? s.ssid : "";
|
||||||
|
if (s.scan_gen != g_list_gen || strcmp(connected_now, g_list_connected) != 0) rebuildList(s);
|
||||||
|
|
||||||
|
if (g_row_count == 0) {
|
||||||
|
setText(g_list_note, s.scanning ? "Looking for networks..." :
|
||||||
|
s.link == WiFiManager::LINK_CONNECTED ? "Tap Scan to see other networks." :
|
||||||
|
"No networks found. Tap Scan to look again.");
|
||||||
|
setVisible(g_list_note, true);
|
||||||
|
} else {
|
||||||
|
setVisible(g_list_note, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void buildWifiPage(lv_obj_t* page) {
|
||||||
|
lv_obj_t* right;
|
||||||
|
makeSettingRow(page, "Wi-Fi", "Used for firmware updates", &right);
|
||||||
|
g_wifi_sw = toggle(right, onWifiSwitch, NULL);
|
||||||
|
|
||||||
|
g_wifi_off_note = label(page,
|
||||||
|
"Wi-Fi is off.\n\nTurn it on to join a network for firmware updates. "
|
||||||
|
"The link to Inst. Cluster works without it.",
|
||||||
|
&lv_font_montserrat_20, UI_COL_MUTED);
|
||||||
|
lv_label_set_long_mode(g_wifi_off_note, LV_LABEL_LONG_WRAP);
|
||||||
|
lv_obj_set_width(g_wifi_off_note, LV_PCT(100));
|
||||||
|
|
||||||
|
g_wifi_body = box(page, LV_FLEX_FLOW_COLUMN);
|
||||||
|
lv_obj_set_width(g_wifi_body, LV_PCT(100));
|
||||||
|
lv_obj_set_flex_grow(g_wifi_body, 1);
|
||||||
|
lv_obj_set_style_pad_row(g_wifi_body, 12, 0);
|
||||||
|
|
||||||
|
// status card: [icon|spinner] [title / detail] [Connect] [Forget]
|
||||||
|
lv_obj_t* c = card(g_wifi_body);
|
||||||
|
lv_obj_set_size(c, LV_PCT(100), LV_SIZE_CONTENT);
|
||||||
|
lv_obj_set_flex_flow(c, LV_FLEX_FLOW_ROW);
|
||||||
|
lv_obj_set_flex_align(c, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
|
||||||
|
lv_obj_set_style_pad_column(c, 16, 0);
|
||||||
|
lv_obj_set_style_min_height(c, 96, 0);
|
||||||
|
|
||||||
|
g_st_icon = label(c, LV_SYMBOL_WIFI, &lv_font_montserrat_30, UI_COL_MUTED);
|
||||||
|
g_st_spinner = lv_spinner_create(c, 1000, 60);
|
||||||
|
lv_obj_set_size(g_st_spinner, 40, 40);
|
||||||
|
lv_obj_set_style_arc_width(g_st_spinner, 5, LV_PART_MAIN);
|
||||||
|
lv_obj_set_style_arc_width(g_st_spinner, 5, LV_PART_INDICATOR);
|
||||||
|
lv_obj_set_style_arc_color(g_st_spinner, UI_COL_ACCENT, LV_PART_INDICATOR);
|
||||||
|
lv_obj_add_flag(g_st_spinner, LV_OBJ_FLAG_HIDDEN);
|
||||||
|
|
||||||
|
lv_obj_t* txt = box(c, LV_FLEX_FLOW_COLUMN);
|
||||||
|
lv_obj_set_height(txt, LV_SIZE_CONTENT);
|
||||||
|
lv_obj_set_flex_grow(txt, 1);
|
||||||
|
lv_obj_set_style_pad_row(txt, 6, 0);
|
||||||
|
g_st_title = label(txt, "", &lv_font_montserrat_24, UI_COL_TEXT);
|
||||||
|
lv_label_set_long_mode(g_st_title, LV_LABEL_LONG_DOT);
|
||||||
|
lv_obj_set_width(g_st_title, LV_PCT(100));
|
||||||
|
g_st_detail = label(txt, "", &lv_font_montserrat_20, UI_COL_MUTED);
|
||||||
|
lv_label_set_long_mode(g_st_detail, LV_LABEL_LONG_WRAP);
|
||||||
|
lv_obj_set_width(g_st_detail, LV_PCT(100));
|
||||||
|
|
||||||
|
g_st_connect = button(c, "Connect", 140, 56, BTN_PRIMARY, onConnectSaved, NULL);
|
||||||
|
g_st_forget = button(c, "Forget", 120, 56, BTN_SECONDARY, onForget, NULL);
|
||||||
|
|
||||||
|
// list header
|
||||||
|
lv_obj_t* hdr = box(g_wifi_body, LV_FLEX_FLOW_ROW);
|
||||||
|
lv_obj_set_size(hdr, LV_PCT(100), LV_SIZE_CONTENT);
|
||||||
|
lv_obj_set_flex_align(hdr, LV_FLEX_ALIGN_SPACE_BETWEEN, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
|
||||||
|
label(hdr, "Networks nearby", &lv_font_montserrat_20, UI_COL_MUTED);
|
||||||
|
g_scan_btn = button(hdr, LV_SYMBOL_REFRESH " Scan", 180, 52, BTN_SECONDARY, onScan, NULL);
|
||||||
|
|
||||||
|
g_list_note = label(g_wifi_body, "", &lv_font_montserrat_20, UI_COL_MUTED);
|
||||||
|
|
||||||
|
g_list = box(g_wifi_body, LV_FLEX_FLOW_COLUMN);
|
||||||
|
lv_obj_set_width(g_list, LV_PCT(100));
|
||||||
|
lv_obj_set_flex_grow(g_list, 1);
|
||||||
|
lv_obj_set_style_pad_row(g_list, 8, 0);
|
||||||
|
lv_obj_add_flag(g_list, LV_OBJ_FLAG_SCROLLABLE);
|
||||||
|
lv_obj_set_scroll_dir(g_list, LV_DIR_VER);
|
||||||
|
lv_obj_set_scrollbar_mode(g_list, LV_SCROLLBAR_MODE_ACTIVE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void buildPasswordOverlay() {
|
||||||
|
g_pw = lv_obj_create(g_screen);
|
||||||
|
lv_obj_remove_style_all(g_pw);
|
||||||
|
lv_obj_set_size(g_pw, 1024, 600);
|
||||||
|
lv_obj_set_style_bg_color(g_pw, UI_COL_BG, 0);
|
||||||
|
lv_obj_set_style_bg_opa(g_pw, LV_OPA_COVER, 0);
|
||||||
|
lv_obj_clear_flag(g_pw, LV_OBJ_FLAG_SCROLLABLE);
|
||||||
|
lv_obj_add_flag(g_pw, LV_OBJ_FLAG_CLICKABLE); // swallow touches meant for the page below
|
||||||
|
lv_obj_add_flag(g_pw, LV_OBJ_FLAG_HIDDEN);
|
||||||
|
|
||||||
|
g_pw_title = label(g_pw, "", &lv_font_montserrat_30, UI_COL_TEXT);
|
||||||
|
lv_label_set_long_mode(g_pw_title, LV_LABEL_LONG_DOT);
|
||||||
|
lv_obj_set_width(g_pw_title, 760);
|
||||||
|
lv_obj_set_pos(g_pw_title, 24, 22);
|
||||||
|
|
||||||
|
lv_obj_t* cancel = button(g_pw, "Cancel", 180, 56, BTN_SECONDARY, onPwCancel, NULL);
|
||||||
|
lv_obj_align(cancel, LV_ALIGN_TOP_RIGHT, -16, 10);
|
||||||
|
|
||||||
|
g_pw_ta = lv_textarea_create(g_pw);
|
||||||
|
lv_textarea_set_one_line(g_pw_ta, true);
|
||||||
|
lv_textarea_set_password_mode(g_pw_ta, true);
|
||||||
|
lv_textarea_set_placeholder_text(g_pw_ta, "Password");
|
||||||
|
lv_textarea_set_max_length(g_pw_ta, 63);
|
||||||
|
lv_obj_set_style_text_font(g_pw_ta, &lv_font_montserrat_30, 0);
|
||||||
|
lv_obj_set_style_bg_color(g_pw_ta, UI_COL_PANEL, 0);
|
||||||
|
lv_obj_set_style_text_color(g_pw_ta, UI_COL_TEXT, 0);
|
||||||
|
lv_obj_set_style_border_color(g_pw_ta, UI_COL_ACCENT, 0);
|
||||||
|
lv_obj_set_width(g_pw_ta, 640);
|
||||||
|
lv_obj_set_pos(g_pw_ta, 24, 100);
|
||||||
|
lv_obj_add_state(g_pw_ta, LV_STATE_FOCUSED); // keep the cursor visible
|
||||||
|
|
||||||
|
g_pw_show = button(g_pw, LV_SYMBOL_EYE_OPEN " Show", 150, 60, BTN_SECONDARY, onPwShow, NULL);
|
||||||
|
lv_obj_set_pos(g_pw_show, 680, 100);
|
||||||
|
lv_obj_t* go = button(g_pw, "Connect", 170, 60, BTN_PRIMARY, onPwConnect, NULL);
|
||||||
|
lv_obj_set_pos(go, 842, 100);
|
||||||
|
|
||||||
|
lv_obj_t* kb = lv_keyboard_create(g_pw);
|
||||||
|
lv_obj_set_size(kb, 1024, 360);
|
||||||
|
lv_obj_align(kb, LV_ALIGN_BOTTOM_MID, 0, 0);
|
||||||
|
lv_obj_set_style_text_font(kb, &lv_font_montserrat_24, 0);
|
||||||
|
lv_obj_set_style_bg_color(kb, UI_COL_PANEL, 0);
|
||||||
|
lv_obj_set_style_bg_color(kb, UI_COL_PANEL2, LV_PART_ITEMS);
|
||||||
|
lv_obj_set_style_text_color(kb, UI_COL_TEXT, LV_PART_ITEMS);
|
||||||
|
lv_obj_set_style_shadow_width(kb, 0, LV_PART_ITEMS);
|
||||||
|
lv_keyboard_set_textarea(kb, g_pw_ta);
|
||||||
|
lv_obj_add_event_cb(kb, onPwKeyboard, LV_EVENT_READY, NULL);
|
||||||
|
lv_obj_add_event_cb(kb, onPwKeyboard, LV_EVENT_CANCEL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// UPDATES PAGE - Main CTRL (this board) and Inst. Cluster (over the link)
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
static lv_obj_t* g_b_installed = NULL;
|
||||||
|
static lv_obj_t* g_b_latest = NULL;
|
||||||
|
static lv_obj_t* g_b_state = NULL;
|
||||||
|
static lv_obj_t* g_b_check = NULL;
|
||||||
|
static lv_obj_t* g_b_install = NULL;
|
||||||
|
static char g_b_refusal[96] = "";
|
||||||
|
static uint8_t g_b_refusal_phase = LINK_OTA_IDLE;
|
||||||
|
|
||||||
|
static void onInstallConfirmed(bool ok, void* user) {
|
||||||
|
(void)user;
|
||||||
|
if (!ok) return;
|
||||||
|
Ota::phase_t before = Ota::getStatus().phase;
|
||||||
|
if (!Ota::requestInstall(g_upd_refusal, sizeof(g_upd_refusal))) g_upd_refusal_phase = before;
|
||||||
|
else g_upd_refusal[0] = 0;
|
||||||
|
refresh(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void onInstall(lv_event_t* e) {
|
||||||
|
(void)e;
|
||||||
|
Ota::ui_status_t o = Ota::getStatus();
|
||||||
|
char title[64];
|
||||||
|
snprintf(title, sizeof(title), "Install %s?", o.latest);
|
||||||
|
confirm(title,
|
||||||
|
"This Controller will restart after successful update.\n\nInstrument Cluster's gauges will drop out for a few seconds.\n\n"
|
||||||
|
"DO NOT SWITCH OFF THE IGNITION!\n\nOnly while parked with the engine off!",
|
||||||
|
"Install", onInstallConfirmed, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void onCheck(lv_event_t* e) {
|
||||||
|
(void)e;
|
||||||
|
Ota::phase_t before = Ota::getStatus().phase;
|
||||||
|
if (!Ota::requestCheck(g_upd_refusal, sizeof(g_upd_refusal))) g_upd_refusal_phase = before;
|
||||||
|
else g_upd_refusal[0] = 0;
|
||||||
|
refresh(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void onGoWifi(lv_event_t* e) {
|
||||||
|
(void)e;
|
||||||
|
selectPage(PAGE_WIFI);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void onBInstallConfirmed(bool ok, void* user) {
|
||||||
|
(void)user;
|
||||||
|
if (!ok) return;
|
||||||
|
uint8_t before = LinkPeer::getStatus().st.ota_phase;
|
||||||
|
if (!LinkPeer::requestInstall(g_b_refusal, sizeof(g_b_refusal))) g_b_refusal_phase = before;
|
||||||
|
else g_b_refusal[0] = 0;
|
||||||
|
refresh(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void onBInstall(lv_event_t* e) {
|
||||||
|
(void)e;
|
||||||
|
LinkPeer::peer_status_t p = LinkPeer::getStatus();
|
||||||
|
char title[64];
|
||||||
|
snprintf(title, sizeof(title), "Install %s on Inst. Cluster?", p.st.latest);
|
||||||
|
confirm(title,
|
||||||
|
"Inst. Cluster joins the Wi-Fi network, downloads its new firmware and restarts; "
|
||||||
|
"its gauges hold still meanwhile and this card shows the progress.\n\n"
|
||||||
|
"Only while parked with the engine off.",
|
||||||
|
"Install", onBInstallConfirmed, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void onBCheck(lv_event_t* e) {
|
||||||
|
(void)e;
|
||||||
|
uint8_t before = LinkPeer::getStatus().st.ota_phase;
|
||||||
|
if (!LinkPeer::requestCheck(g_b_refusal, sizeof(g_b_refusal))) g_b_refusal_phase = before;
|
||||||
|
else g_b_refusal[0] = 0;
|
||||||
|
refresh(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void refreshUpdatesA() {
|
||||||
|
Ota::ui_status_t o = Ota::getStatus();
|
||||||
|
bool wifi_ok = WiFiManager::getStatus().link == WiFiManager::LINK_CONNECTED;
|
||||||
|
if (g_upd_refusal[0] && o.phase != g_upd_refusal_phase) g_upd_refusal[0] = 0; // superseded
|
||||||
|
|
||||||
|
char msg[140];
|
||||||
|
lv_color_t col = UI_COL_MUTED;
|
||||||
|
switch (o.phase) {
|
||||||
|
case Ota::PHASE_CHECKING: snprintf(msg, sizeof(msg), "Checking for updates..."); break;
|
||||||
|
case Ota::PHASE_INSTALLING: snprintf(msg, sizeof(msg), "Installing %s...", o.latest); break;
|
||||||
|
case Ota::PHASE_UP_TO_DATE: snprintf(msg, sizeof(msg), LV_SYMBOL_OK " You're up to date."); col = UI_COL_OK; break;
|
||||||
|
case Ota::PHASE_AVAILABLE: snprintf(msg, sizeof(msg), "Version %s is available.", o.latest); col = UI_COL_ACCENT; break;
|
||||||
|
case Ota::PHASE_FAILED: snprintf(msg, sizeof(msg), LV_SYMBOL_WARNING " %s", o.message); col = UI_COL_WARN; break;
|
||||||
|
default:
|
||||||
|
snprintf(msg, sizeof(msg), "%s", wifi_ok ? "Tap Check to look for a new version." : "Connect to Wi-Fi to check for updates.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (g_upd_refusal[0]) {
|
||||||
|
snprintf(msg, sizeof(msg), LV_SYMBOL_WARNING " %s", g_upd_refusal);
|
||||||
|
col = UI_COL_WARN;
|
||||||
|
} else if (!wifi_ok && o.phase != Ota::PHASE_IDLE && o.phase != Ota::PHASE_CHECKING) {
|
||||||
|
// keep the last result, but say why the buttons are off
|
||||||
|
size_t n = strlen(msg);
|
||||||
|
snprintf(msg + n, sizeof(msg) - n, " Connect to Wi-Fi to check again.");
|
||||||
|
}
|
||||||
|
setText(g_upd_state, msg);
|
||||||
|
setTextColor(g_upd_state, col);
|
||||||
|
|
||||||
|
setText(g_upd_latest, o.latest[0] ? o.latest : "-");
|
||||||
|
|
||||||
|
bool busy = o.phase == Ota::PHASE_CHECKING || o.phase == Ota::PHASE_INSTALLING;
|
||||||
|
setButtonText(g_upd_check, busy ? "Working..." : LV_SYMBOL_REFRESH " Check for updates");
|
||||||
|
if (busy || !wifi_ok) lv_obj_add_state(g_upd_check, LV_STATE_DISABLED);
|
||||||
|
else lv_obj_clear_state(g_upd_check, LV_STATE_DISABLED);
|
||||||
|
|
||||||
|
bool can_install = o.phase == Ota::PHASE_AVAILABLE && wifi_ok;
|
||||||
|
char inst[48];
|
||||||
|
snprintf(inst, sizeof(inst), LV_SYMBOL_DOWNLOAD " Install %s", o.latest);
|
||||||
|
setButtonText(g_upd_install, inst);
|
||||||
|
setVisible(g_upd_install, can_install);
|
||||||
|
setVisible(g_upd_wifi, !wifi_ok);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void refreshUpdatesB() {
|
||||||
|
LinkPeer::peer_status_t p = LinkPeer::getStatus();
|
||||||
|
if (g_b_refusal[0] && p.st.ota_phase != g_b_refusal_phase) g_b_refusal[0] = 0;
|
||||||
|
|
||||||
|
bool has_wifi = (p.st.flags & LINK_STATUS_HAVE_WIFI) != 0;
|
||||||
|
bool ready = p.heard && p.paired && p.key_match && has_wifi;
|
||||||
|
char msg[160];
|
||||||
|
lv_color_t col = UI_COL_MUTED;
|
||||||
|
if (!p.heard) {
|
||||||
|
snprintf(msg, sizeof(msg), "Inst. Cluster not heard.%s",
|
||||||
|
p.paired ? "" : " Not paired yet: connect the wire and run 'link pair' on the console.");
|
||||||
|
} else if (!p.paired || !p.key_match) {
|
||||||
|
snprintf(msg, sizeof(msg), LV_SYMBOL_WARNING " Not paired with this controller. "
|
||||||
|
"Connect the wire and run 'link pair' on the console.");
|
||||||
|
col = UI_COL_AMBER;
|
||||||
|
} else if (!has_wifi) {
|
||||||
|
snprintf(msg, sizeof(msg), "Inst. Cluster has no Wi-Fi credentials yet. Join a network here; "
|
||||||
|
"they are passed on by themselves.");
|
||||||
|
} else {
|
||||||
|
switch (p.st.ota_phase) {
|
||||||
|
case LINK_OTA_CHECKING: snprintf(msg, sizeof(msg), "Inst. Cluster is checking..."); break;
|
||||||
|
case LINK_OTA_INSTALLING: snprintf(msg, sizeof(msg), "Installing %s on Inst. Cluster... %u %%",
|
||||||
|
p.st.latest, p.st.ota_progress); col = UI_COL_ACCENT; break;
|
||||||
|
case LINK_OTA_UP_TO_DATE: snprintf(msg, sizeof(msg), LV_SYMBOL_OK " Inst. Cluster is up to date."); col = UI_COL_OK; break;
|
||||||
|
case LINK_OTA_AVAILABLE: snprintf(msg, sizeof(msg), "Version %s is available for Inst. Cluster.", p.st.latest); col = UI_COL_ACCENT; break;
|
||||||
|
case LINK_OTA_FAILED: snprintf(msg, sizeof(msg), LV_SYMBOL_WARNING " %s", p.st.message); col = UI_COL_WARN; break;
|
||||||
|
default: snprintf(msg, sizeof(msg), "Tap Check to look for a new version"); break;
|
||||||
|
}
|
||||||
|
if (p.st.flags & LINK_STATUS_PENDING_VERIFY) {
|
||||||
|
size_t n = strlen(msg);
|
||||||
|
snprintf(msg + n, sizeof(msg) - n, " (new firmware, confirming...)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (g_b_refusal[0]) {
|
||||||
|
snprintf(msg, sizeof(msg), LV_SYMBOL_WARNING " %s", g_b_refusal);
|
||||||
|
col = UI_COL_WARN;
|
||||||
|
}
|
||||||
|
setText(g_b_state, msg);
|
||||||
|
setTextColor(g_b_state, col);
|
||||||
|
setText(g_b_installed, p.heard ? p.st.version : "-");
|
||||||
|
setText(g_b_latest, (p.heard && p.st.latest[0]) ? p.st.latest : "-");
|
||||||
|
|
||||||
|
bool busy = p.heard && (p.st.ota_phase == LINK_OTA_CHECKING || p.st.ota_phase == LINK_OTA_INSTALLING);
|
||||||
|
setButtonText(g_b_check, busy ? "Working..." : LV_SYMBOL_REFRESH " Check for updates");
|
||||||
|
if (busy || !ready) lv_obj_add_state(g_b_check, LV_STATE_DISABLED);
|
||||||
|
else lv_obj_clear_state(g_b_check, LV_STATE_DISABLED);
|
||||||
|
|
||||||
|
bool can_install = ready && p.st.ota_phase == LINK_OTA_AVAILABLE;
|
||||||
|
char inst[48];
|
||||||
|
snprintf(inst, sizeof(inst), LV_SYMBOL_DOWNLOAD " Install %s", p.st.latest);
|
||||||
|
setButtonText(g_b_install, inst);
|
||||||
|
setVisible(g_b_install, can_install);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void refreshUpdates() {
|
||||||
|
refreshUpdatesA();
|
||||||
|
refreshUpdatesB();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** One controller's card: "Name Installed vX Latest vY", a status line, a button row. */
|
||||||
|
static lv_obj_t* controllerCard(lv_obj_t* page, const char* name, const char* installed,
|
||||||
|
lv_obj_t** installed_lbl, lv_obj_t** latest_lbl, lv_obj_t** state_lbl) {
|
||||||
|
lv_obj_t* c = card(page);
|
||||||
|
lv_obj_set_size(c, LV_PCT(100), LV_SIZE_CONTENT);
|
||||||
|
lv_obj_set_flex_flow(c, LV_FLEX_FLOW_COLUMN);
|
||||||
|
lv_obj_set_style_pad_row(c, 8, 0);
|
||||||
|
|
||||||
|
lv_obj_t* row = box(c, LV_FLEX_FLOW_ROW);
|
||||||
|
lv_obj_set_size(row, LV_PCT(100), LV_SIZE_CONTENT);
|
||||||
|
lv_obj_set_flex_align(row, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_END, LV_FLEX_ALIGN_END);
|
||||||
|
lv_obj_set_style_pad_column(row, 36, 0);
|
||||||
|
lv_obj_t* title = label(row, name, &lv_font_montserrat_24, UI_COL_TEXT);
|
||||||
|
lv_obj_set_width(title, 190);
|
||||||
|
|
||||||
|
lv_obj_t* a = box(row, LV_FLEX_FLOW_ROW);
|
||||||
|
lv_obj_set_size(a, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
|
||||||
|
lv_obj_set_flex_align(a, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_END, LV_FLEX_ALIGN_END);
|
||||||
|
lv_obj_set_style_pad_column(a, 10, 0);
|
||||||
|
label(a, "Installed", &lv_font_montserrat_20, UI_COL_MUTED);
|
||||||
|
*installed_lbl = label(a, installed, &lv_font_montserrat_24, UI_COL_TEXT);
|
||||||
|
|
||||||
|
lv_obj_t* b = box(row, LV_FLEX_FLOW_ROW);
|
||||||
|
lv_obj_set_size(b, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
|
||||||
|
lv_obj_set_flex_align(b, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_END, LV_FLEX_ALIGN_END);
|
||||||
|
lv_obj_set_style_pad_column(b, 10, 0);
|
||||||
|
label(b, "Latest", &lv_font_montserrat_20, UI_COL_MUTED);
|
||||||
|
*latest_lbl = label(b, "-", &lv_font_montserrat_24, UI_COL_TEXT);
|
||||||
|
|
||||||
|
*state_lbl = label(c, "", &lv_font_montserrat_20, UI_COL_MUTED);
|
||||||
|
lv_label_set_long_mode(*state_lbl, LV_LABEL_LONG_WRAP);
|
||||||
|
lv_obj_set_width(*state_lbl, LV_PCT(100));
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void buildUpdatesPage(lv_obj_t* page) {
|
||||||
|
label(page, "Firmware updates", &lv_font_montserrat_24, UI_COL_TEXT);
|
||||||
|
|
||||||
|
lv_obj_t* installed_a = NULL;
|
||||||
|
lv_obj_t* a = controllerCard(page, "Main CTRL", FW_VERSION, &installed_a, &g_upd_latest, &g_upd_state);
|
||||||
|
lv_obj_t* btns = box(a, LV_FLEX_FLOW_ROW);
|
||||||
|
lv_obj_set_size(btns, LV_PCT(100), LV_SIZE_CONTENT);
|
||||||
|
lv_obj_set_style_pad_column(btns, 16, 0);
|
||||||
|
g_upd_check = button(btns, LV_SYMBOL_REFRESH " Check for updates", 300, 56, BTN_PRIMARY, onCheck, NULL);
|
||||||
|
g_upd_install = button(btns, "Install", 280, 56, BTN_SUCCESS, onInstall, NULL);
|
||||||
|
g_upd_wifi = button(btns, LV_SYMBOL_WIFI " Wi-Fi settings", 260, 56, BTN_SECONDARY, onGoWifi, NULL);
|
||||||
|
|
||||||
|
lv_obj_t* b = controllerCard(page, "Inst. Cluster", "-", &g_b_installed, &g_b_latest, &g_b_state);
|
||||||
|
btns = box(b, LV_FLEX_FLOW_ROW);
|
||||||
|
lv_obj_set_size(btns, LV_PCT(100), LV_SIZE_CONTENT);
|
||||||
|
lv_obj_set_style_pad_column(btns, 16, 0);
|
||||||
|
g_b_check = button(btns, LV_SYMBOL_REFRESH " Check for updates", 300, 56, BTN_PRIMARY, onBCheck, NULL);
|
||||||
|
g_b_install = button(btns, "Install", 280, 56, BTN_SUCCESS, onBInstall, NULL);
|
||||||
|
|
||||||
|
lv_obj_t* note = label(page,
|
||||||
|
"Each controller restarts after updating. DO NOT TURN OFF THE IGNITION DURING THE UPDATE",
|
||||||
|
&lv_font_montserrat_20, UI_COL_MUTED);
|
||||||
|
lv_label_set_long_mode(note, LV_LABEL_LONG_WRAP);
|
||||||
|
lv_obj_set_width(note, LV_PCT(100));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// SYSTEM PAGE
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
static void onCanSwitch(lv_event_t* e) {
|
||||||
|
if (g_refreshing) return;
|
||||||
|
CANDriver::setEnabled(lv_obj_has_state(lv_event_get_target(e), LV_STATE_CHECKED));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void onLinkSwitch(lv_event_t* e) {
|
||||||
|
if (g_refreshing) return;
|
||||||
|
UARTManager::setEnabled(lv_obj_has_state(lv_event_get_target(e), LV_STATE_CHECKED));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void onDebugSwitch(lv_event_t* e) {
|
||||||
|
if (g_refreshing) return;
|
||||||
|
bool on = lv_obj_has_state(lv_event_get_target(e), LV_STATE_CHECKED);
|
||||||
|
SettingsManager::saveDebugState(on);
|
||||||
|
UIStateManager::setDebugEnabled(on);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void onDiffSwitch(lv_event_t* e) {
|
||||||
|
if (g_refreshing) return;
|
||||||
|
DiffLocks::setEnabled(lv_obj_has_state(lv_event_get_target(e), LV_STATE_CHECKED));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void onDiffInvertSwitch(lv_event_t* e) {
|
||||||
|
if (g_refreshing) return;
|
||||||
|
DiffLocks::setInverted(lv_obj_has_state(lv_event_get_target(e), LV_STATE_CHECKED));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void refreshSystem(bool force) {
|
||||||
|
setChecked(g_sys_can, CANDriver::isActive());
|
||||||
|
setChecked(g_sys_link, UARTManager::getState() != UARTManager::UART_STATE_OFF);
|
||||||
|
setChecked(g_sys_dbg, UIStateManager::isDebugEnabled());
|
||||||
|
setChecked(g_sys_diff, DiffLocks::isEnabled());
|
||||||
|
setChecked(g_sys_diff_inv, DiffLocks::isInverted());
|
||||||
|
// live state in the sub-line, so the wiring can be tested from this page
|
||||||
|
if (!DiffLocks::isEnabled()) setText(g_sys_diff_sub, DiffLocks::isInverted()
|
||||||
|
? "DI0 rear, DI1 front - 0 V = locked"
|
||||||
|
: "DI0 rear, DI1 front - 12 V = locked");
|
||||||
|
else if (!DiffLocks::isValid()) setText(g_sys_diff_sub, "Now: reading...");
|
||||||
|
else setText(g_sys_diff_sub, DiffLocks::frontLocked()
|
||||||
|
? (DiffLocks::rearLocked() ? "Now: rear LOCKED, front LOCKED" : "Now: FRONT only - check DI0 wiring")
|
||||||
|
: (DiffLocks::rearLocked() ? "Now: rear LOCKED, front open" : "Now: both open"));
|
||||||
|
|
||||||
|
static uint32_t last = 0; // the figures below change slowly; 1 Hz is plenty
|
||||||
|
if (!force && millis() - last < 1000) return;
|
||||||
|
last = millis();
|
||||||
|
|
||||||
|
can_stats_t cs = CANDriver::getStats();
|
||||||
|
const esp_partition_t* run = esp_ota_get_running_partition();
|
||||||
|
uint32_t up = millis() / 1000;
|
||||||
|
char buf[400];
|
||||||
|
snprintf(buf, sizeof(buf),
|
||||||
|
"%s (slot %s), up %lu h %02lu min\n"
|
||||||
|
"ESP-NOW %s, %lu frames sent, %lu failed\n"
|
||||||
|
"%lu frames received\n"
|
||||||
|
"%u KB internal free, %u KB PSRAM free",
|
||||||
|
FW_VERSION, run ? run->label : "?",
|
||||||
|
(unsigned long)(up / 3600), (unsigned long)((up / 60) % 60),
|
||||||
|
EspNowLink::isReady() ? "up" : "DOWN",
|
||||||
|
(unsigned long)EspNowLink::sentCount(), (unsigned long)EspNowLink::failCount(),
|
||||||
|
(unsigned long)cs.messages_received,
|
||||||
|
(unsigned)(heap_caps_get_free_size(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT) / 1024),
|
||||||
|
(unsigned)(heap_caps_get_free_size(MALLOC_CAP_SPIRAM) / 1024));
|
||||||
|
setText(g_sys_info, buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void buildSystemPage(lv_obj_t* page) {
|
||||||
|
lv_obj_t* c = card(page);
|
||||||
|
lv_obj_set_size(c, LV_PCT(100), LV_SIZE_CONTENT);
|
||||||
|
lv_obj_set_flex_flow(c, LV_FLEX_FLOW_COLUMN);
|
||||||
|
lv_obj_set_style_pad_row(c, 10, 0);
|
||||||
|
|
||||||
|
lv_obj_t* right;
|
||||||
|
makeSettingRow(c, "CAN bus", "Read the car's data bus", &right);
|
||||||
|
g_sys_can = toggle(right, onCanSwitch, NULL);
|
||||||
|
makeSettingRow(c, "Send to Inst. Cluster", "Gauge data over the wire and ESP-NOW", &right);
|
||||||
|
g_sys_link = toggle(right, onLinkSwitch, NULL);
|
||||||
|
makeSettingRow(c, "Performance overlay", "Frame rate and CPU load in the corner", &right);
|
||||||
|
g_sys_dbg = toggle(right, onDebugSwitch, NULL);
|
||||||
|
lv_obj_t* diff_row = makeSettingRow(c, "Diff lock inputs", "DI0 rear, DI1 front - 12 V = locked", &right);
|
||||||
|
g_sys_diff_sub = lv_obj_get_child(lv_obj_get_child(diff_row, 0), 1);
|
||||||
|
// two switches on the right: polarity ("Inverted") and on/off; the page has no room for a fifth row
|
||||||
|
lv_obj_t* diff_right = box(right, LV_FLEX_FLOW_ROW);
|
||||||
|
lv_obj_set_size(diff_right, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
|
||||||
|
// START, not END: with END, LVGL 8's content-size pass measures only the last child
|
||||||
|
// (the earlier ones sit at negative x) and clips "Inverted" away - seen on the board.
|
||||||
|
// The row's SPACE_BETWEEN already pushes this box to the right edge.
|
||||||
|
lv_obj_set_flex_align(diff_right, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
|
||||||
|
lv_obj_set_style_pad_column(diff_right, 12, 0);
|
||||||
|
label(diff_right, "Inverted", &lv_font_montserrat_20, UI_COL_MUTED);
|
||||||
|
g_sys_diff_inv = toggle(diff_right, onDiffInvertSwitch, NULL);
|
||||||
|
lv_obj_t* gap = box(diff_right, LV_FLEX_FLOW_ROW);
|
||||||
|
lv_obj_set_size(gap, 12, 1);
|
||||||
|
g_sys_diff = toggle(diff_right, onDiffSwitch, NULL);
|
||||||
|
|
||||||
|
// two labels side by side, same line spacing, so keys and values line up
|
||||||
|
lv_obj_t* info = card(page);
|
||||||
|
lv_obj_set_size(info, LV_PCT(100), LV_SIZE_CONTENT);
|
||||||
|
lv_obj_set_flex_flow(info, LV_FLEX_FLOW_ROW);
|
||||||
|
lv_obj_set_style_pad_column(info, 24, 0);
|
||||||
|
// Uptime shares the firmware line: a fourth switch row leaves no room for a fifth line (484 px page)
|
||||||
|
lv_obj_t* keys = label(info, "Firmware\nLink to B\nCAN bus\nMemory", &lv_font_montserrat_20, UI_COL_MUTED);
|
||||||
|
lv_obj_set_style_text_line_space(keys, 6, 0);
|
||||||
|
g_sys_info = label(info, "", &lv_font_montserrat_20, UI_COL_TEXT);
|
||||||
|
lv_obj_set_style_text_line_space(g_sys_info, 6, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// BUILD / REFRESH
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
static void build() {
|
||||||
|
if (g_screen != NULL) return;
|
||||||
|
|
||||||
|
g_screen = screen();
|
||||||
|
lv_obj_add_event_cb(g_screen, onGesture, LV_EVENT_GESTURE, NULL);
|
||||||
|
header(g_screen, "SETTINGS", onBack);
|
||||||
|
|
||||||
|
g_nav[PAGE_WIFI] = makeNav(g_screen, PAGE_WIFI, "Wi-Fi");
|
||||||
|
g_nav[PAGE_UPDATES] = makeNav(g_screen, PAGE_UPDATES, "Updates");
|
||||||
|
g_nav[PAGE_SYSTEM] = makeNav(g_screen, PAGE_SYSTEM, "System");
|
||||||
|
|
||||||
|
for (int i = 0; i < PAGE_COUNT; i++) g_page[i] = makePage(g_screen);
|
||||||
|
buildWifiPage(g_page[PAGE_WIFI]);
|
||||||
|
buildUpdatesPage(g_page[PAGE_UPDATES]);
|
||||||
|
buildSystemPage(g_page[PAGE_SYSTEM]);
|
||||||
|
buildPasswordOverlay();
|
||||||
|
|
||||||
|
ESP_LOGI("Settings", "Settings screen built");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void refreshNav() {
|
||||||
|
WiFiManager::status_t s = WiFiManager::getStatus();
|
||||||
|
const char* w = "Not connected";
|
||||||
|
if (s.link == WiFiManager::LINK_OFF) w = "Off";
|
||||||
|
else if (s.link == WiFiManager::LINK_CONNECTED) w = s.ssid;
|
||||||
|
else if (s.link == WiFiManager::LINK_CONNECTING) w = "Connecting...";
|
||||||
|
setText(g_nav_sub[PAGE_WIFI], w);
|
||||||
|
setTextColor(g_nav_sub[PAGE_WIFI], s.link == WiFiManager::LINK_CONNECTED ? UI_COL_OK : UI_COL_MUTED);
|
||||||
|
|
||||||
|
Ota::ui_status_t o = Ota::getStatus();
|
||||||
|
bool avail = o.phase == Ota::PHASE_AVAILABLE;
|
||||||
|
setText(g_nav_sub[PAGE_UPDATES], avail ? "Update available" : FW_VERSION);
|
||||||
|
setTextColor(g_nav_sub[PAGE_UPDATES], avail ? UI_COL_ACCENT : UI_COL_MUTED);
|
||||||
|
|
||||||
|
char sys[40];
|
||||||
|
snprintf(sys, sizeof(sys), "CAN %s \xE2\x80\xA2 Link %s", CANDriver::isActive() ? "on" : "off",
|
||||||
|
UARTManager::getState() != UARTManager::UART_STATE_OFF ? "on" : "off");
|
||||||
|
setText(g_nav_sub[PAGE_SYSTEM], sys);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Caller holds the LVGL lock. */
|
||||||
|
static void refresh(bool force) {
|
||||||
|
g_refreshing = true;
|
||||||
|
refreshNav();
|
||||||
|
switch (g_cur) {
|
||||||
|
case PAGE_WIFI: refreshWifi(); break;
|
||||||
|
case PAGE_UPDATES: refreshUpdates(); break;
|
||||||
|
case PAGE_SYSTEM: refreshSystem(force); break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
g_refreshing = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// PUBLIC API
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
void show() {
|
||||||
|
bool first = (g_screen == NULL);
|
||||||
|
build();
|
||||||
|
if (first) selectPage(PAGE_WIFI);
|
||||||
|
else if (g_cur == PAGE_WIFI) g_want_scan = true;
|
||||||
|
refresh(true);
|
||||||
|
lv_scr_load_anim(g_screen, LV_SCR_LOAD_ANIM_NONE, 0, 0, false); // instant: fades stutter at 1024x600
|
||||||
|
}
|
||||||
|
|
||||||
|
void tick() {
|
||||||
|
if (g_screen == NULL || lv_scr_act() != g_screen) return;
|
||||||
|
static uint32_t last = 0;
|
||||||
|
if (millis() - last < 250) return;
|
||||||
|
last = millis();
|
||||||
|
lvgl_port_lock(-1);
|
||||||
|
refresh(false);
|
||||||
|
lvgl_port_unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace SettingsScreen
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Settings Screen Module
|
||||||
|
*
|
||||||
|
* Sidebar with three sections:
|
||||||
|
* Wi-Fi - switch, connection status, networks nearby, full-screen password
|
||||||
|
* entry; the joined network is remembered (WiFiManager)
|
||||||
|
* Updates - installed vs latest release, Check, Install behind a confirm
|
||||||
|
* dialog (Ota)
|
||||||
|
* System - CAN bus / link to Inst. Cluster / performance overlay switches,
|
||||||
|
* live link and memory figures
|
||||||
|
*
|
||||||
|
* Reached by swiping LEFT on the Driveline screen; swipe right or the
|
||||||
|
* Driveline button goes back. Built once and kept (never deleted), so nothing
|
||||||
|
* elsewhere ever holds a pointer into a destroyed screen.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <lvgl.h>
|
||||||
|
|
||||||
|
namespace SettingsScreen {
|
||||||
|
|
||||||
|
/** Build (idempotent), refresh and load. Caller holds the LVGL lock. */
|
||||||
|
void show();
|
||||||
|
|
||||||
|
/** Refresh live values while the screen is shown. Call from loop(); takes its own lock. */
|
||||||
|
void tick();
|
||||||
|
|
||||||
|
} // namespace SettingsScreen
|
||||||
@@ -0,0 +1,147 @@
|
|||||||
|
/*
|
||||||
|
* Status Overlay implementation. See status_overlay.h.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "status_overlay.h"
|
||||||
|
#include "wifi_manager.h"
|
||||||
|
#include "uart_manager.h"
|
||||||
|
#include "ui_kit.h"
|
||||||
|
#include "drivers/can_driver.h"
|
||||||
|
#include "display/lvgl_v8_port.h"
|
||||||
|
#include "protocol/automotive_data.h"
|
||||||
|
#include <lvgl.h>
|
||||||
|
|
||||||
|
namespace StatusOverlay {
|
||||||
|
|
||||||
|
#define BLINK_MS 500
|
||||||
|
|
||||||
|
static lv_obj_t* g_wifi = NULL;
|
||||||
|
static lv_obj_t* g_banner = NULL;
|
||||||
|
static bool g_banner_shown = false;
|
||||||
|
|
||||||
|
static const lv_color_t COL_RED_HI = lv_color_hex(0xFF3B30);
|
||||||
|
static const lv_color_t COL_RED_LO = lv_color_hex(0x8F1A14);
|
||||||
|
|
||||||
|
static void setText(lv_obj_t* lbl, const char* text) {
|
||||||
|
const char* cur = lv_label_get_text(lbl);
|
||||||
|
if (cur != NULL && strcmp(cur, text) == 0) return;
|
||||||
|
lv_label_set_text(lbl, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setTextColour(lv_obj_t* o, lv_color_t c) {
|
||||||
|
if (lv_color_to32(lv_obj_get_style_text_color(o, 0)) != lv_color_to32(c)) lv_obj_set_style_text_color(o, c, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setBgColour(lv_obj_t* o, lv_color_t c) {
|
||||||
|
if (lv_color_to32(lv_obj_get_style_bg_color(o, 0)) != lv_color_to32(c)) lv_obj_set_style_bg_color(o, c, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void init() {
|
||||||
|
lvgl_port_lock(-1);
|
||||||
|
|
||||||
|
// Wi-Fi chip, fixed width so the header layout never moves
|
||||||
|
g_wifi = lv_label_create(lv_layer_top());
|
||||||
|
lv_obj_set_width(g_wifi, 150);
|
||||||
|
lv_label_set_long_mode(g_wifi, LV_LABEL_LONG_DOT);
|
||||||
|
lv_label_set_text(g_wifi, LV_SYMBOL_WIFI " --");
|
||||||
|
lv_obj_set_style_text_font(g_wifi, &lv_font_montserrat_14, 0);
|
||||||
|
lv_obj_set_style_text_color(g_wifi, UI_COL_MUTED, 0);
|
||||||
|
lv_obj_set_style_bg_color(g_wifi, UI_COL_PANEL, 0);
|
||||||
|
lv_obj_set_style_bg_opa(g_wifi, LV_OPA_COVER, 0);
|
||||||
|
lv_obj_set_style_radius(g_wifi, 13, 0);
|
||||||
|
lv_obj_set_style_pad_hor(g_wifi, 10, 0);
|
||||||
|
lv_obj_set_style_pad_ver(g_wifi, 5, 0);
|
||||||
|
lv_obj_align(g_wifi, LV_ALIGN_TOP_RIGHT, -16, 25);
|
||||||
|
|
||||||
|
// Alert banner, top centre
|
||||||
|
g_banner = lv_label_create(lv_layer_top());
|
||||||
|
lv_label_set_text(g_banner, "");
|
||||||
|
lv_obj_set_style_text_font(g_banner, &lv_font_montserrat_20, 0);
|
||||||
|
lv_obj_set_style_text_color(g_banner, lv_color_white(), 0);
|
||||||
|
lv_obj_set_style_bg_color(g_banner, COL_RED_HI, 0);
|
||||||
|
lv_obj_set_style_bg_opa(g_banner, LV_OPA_COVER, 0);
|
||||||
|
lv_obj_set_style_radius(g_banner, 10, 0);
|
||||||
|
lv_obj_set_style_pad_hor(g_banner, 18, 0);
|
||||||
|
lv_obj_set_style_pad_ver(g_banner, 8, 0);
|
||||||
|
lv_obj_align(g_banner, LV_ALIGN_TOP_MID, -20, 10);
|
||||||
|
lv_obj_add_flag(g_banner, LV_OBJ_FLAG_HIDDEN);
|
||||||
|
|
||||||
|
lvgl_port_unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void refreshWifi() {
|
||||||
|
WiFiManager::status_t w = WiFiManager::getStatus();
|
||||||
|
char txt[64];
|
||||||
|
lv_color_t col = UI_COL_MUTED;
|
||||||
|
switch (w.link) {
|
||||||
|
case WiFiManager::LINK_CONNECTED: snprintf(txt, sizeof(txt), LV_SYMBOL_WIFI " %s", w.ssid); col = UI_COL_TEXT; break;
|
||||||
|
case WiFiManager::LINK_CONNECTING: snprintf(txt, sizeof(txt), LV_SYMBOL_WIFI " joining..."); col = UI_COL_ACCENT; break;
|
||||||
|
case WiFiManager::LINK_FAILED: snprintf(txt, sizeof(txt), LV_SYMBOL_WIFI " failed"); col = UI_COL_AMBER; break;
|
||||||
|
case WiFiManager::LINK_OFF: snprintf(txt, sizeof(txt), LV_SYMBOL_WIFI " off"); break;
|
||||||
|
default: snprintf(txt, sizeof(txt), LV_SYMBOL_WIFI " not connected"); break;
|
||||||
|
}
|
||||||
|
setText(g_wifi, txt);
|
||||||
|
setTextColour(g_wifi, col);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void refreshAlerts() {
|
||||||
|
bool can_up = CANDriver::isActive();
|
||||||
|
driveline_t dl = CANDriver::getDriveline();
|
||||||
|
|
||||||
|
uint16_t alerts = 0;
|
||||||
|
uint8_t flags = 0;
|
||||||
|
int16_t coolant = 0, gearbox = 0;
|
||||||
|
uint16_t batt = 0;
|
||||||
|
if (xSemaphoreTake(UARTManager::g_data_mutex, pdMS_TO_TICKS(10)) == pdTRUE) {
|
||||||
|
alerts = UARTManager::g_automotive_data.alerts;
|
||||||
|
flags = UARTManager::g_automotive_data.valid_flags;
|
||||||
|
coolant = UARTManager::g_automotive_data.coolant_temp;
|
||||||
|
gearbox = UARTManager::g_automotive_data.gearbox_oil_temp;
|
||||||
|
batt = UARTManager::g_automotive_data.battery_voltage;
|
||||||
|
xSemaphoreGive(UARTManager::g_data_mutex);
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool live = can_up && dl.ignition_on && (flags & VALID_FLAG_ALERTS);
|
||||||
|
bool red = live && (alerts & ALERTS_RED);
|
||||||
|
bool amber = live && !red && (alerts & ALERTS_AMBER);
|
||||||
|
bool show = red || amber;
|
||||||
|
|
||||||
|
if (show != g_banner_shown) {
|
||||||
|
g_banner_shown = show;
|
||||||
|
if (show) lv_obj_clear_flag(g_banner, LV_OBJ_FLAG_HIDDEN);
|
||||||
|
else lv_obj_add_flag(g_banner, LV_OBJ_FLAG_HIDDEN);
|
||||||
|
}
|
||||||
|
if (!show) return;
|
||||||
|
|
||||||
|
char txt[64];
|
||||||
|
if (alerts & ALERT_COOLANT_HOT) snprintf(txt, sizeof(txt), LV_SYMBOL_WARNING " COOLANT %d °C HOT", coolant / 10);
|
||||||
|
else if (alerts & ALERT_GEARBOX_HOT) snprintf(txt, sizeof(txt), LV_SYMBOL_WARNING " GEARBOX OIL %d °C HOT", gearbox / 10);
|
||||||
|
else if (alerts & ALERT_GEAR_MISMATCH) snprintf(txt, sizeof(txt), LV_SYMBOL_WARNING " GEAR MISMATCH");
|
||||||
|
else if (alerts & ALERT_BATTERY_LOW) snprintf(txt, sizeof(txt), LV_SYMBOL_WARNING " BATTERY %d.%02d V LOW", batt / 100, batt % 100);
|
||||||
|
else snprintf(txt, sizeof(txt), LV_SYMBOL_WARNING " GEARBOX COOLING");
|
||||||
|
setText(g_banner, txt);
|
||||||
|
|
||||||
|
if (red) {
|
||||||
|
bool hi = (millis() / BLINK_MS) & 1;
|
||||||
|
setBgColour(g_banner, hi ? COL_RED_HI : COL_RED_LO);
|
||||||
|
setTextColour(g_banner, lv_color_white());
|
||||||
|
} else {
|
||||||
|
setBgColour(g_banner, UI_COL_AMBER);
|
||||||
|
setTextColour(g_banner, lv_color_hex(0x1A1200));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void tick() {
|
||||||
|
if (g_wifi == NULL) return;
|
||||||
|
static uint32_t last = 0;
|
||||||
|
if (millis() - last < 250) return;
|
||||||
|
last = millis();
|
||||||
|
lvgl_port_lock(-1);
|
||||||
|
refreshWifi();
|
||||||
|
refreshAlerts();
|
||||||
|
lvgl_port_unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace StatusOverlay
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Status Overlay - what every screen shows, on lv_layer_top():
|
||||||
|
*
|
||||||
|
* top-right Wi-Fi chip: off / not connected / joining / <network>
|
||||||
|
* top-centre ALERT BANNER: red and blinking (2 Hz) while any red alert from
|
||||||
|
* Tunables' thresholds is on (coolant hot, gearbox oil hot,
|
||||||
|
* gear mismatch, battery low), steady amber while the gearbox
|
||||||
|
* asks for cooling. Hidden with CAN off or ignition off.
|
||||||
|
*
|
||||||
|
* Both are labels, so they never take touches from the screen below. tick()
|
||||||
|
* runs from loop() and only touches an object when its text/colour changes.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
namespace StatusOverlay {
|
||||||
|
|
||||||
|
/** Build the two labels. Call after DisplayInit::init(), before the screens tick. */
|
||||||
|
void init();
|
||||||
|
|
||||||
|
/** Refresh from WiFiManager / the shared automotive data. Call from loop(). */
|
||||||
|
void tick();
|
||||||
|
|
||||||
|
} // namespace StatusOverlay
|
||||||
@@ -102,6 +102,7 @@ static void help() {
|
|||||||
print("cfg override off | rpm <n> | duty <n> | both <rpm> <duty>");
|
print("cfg override off | rpm <n> | duty <n> | both <rpm> <duty>");
|
||||||
print("cfg reset back to defaults");
|
print("cfg reset back to defaults");
|
||||||
print("diag help OBD-II diagnostic probe (transmits on the bus)");
|
print("diag help OBD-II diagnostic probe (transmits on the bus)");
|
||||||
|
print("link help Inst. Cluster: pairing, credentials, its updates");
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool setField(const char* name, long v) {
|
static bool setField(const char* name, long v) {
|
||||||
@@ -268,6 +269,10 @@ void flush() {
|
|||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isDirty() {
|
||||||
|
return g_dirty;
|
||||||
|
}
|
||||||
|
|
||||||
void pollSerial() {
|
void pollSerial() {
|
||||||
if (g_dirty && millis() - g_dirty_ms > SAVE_IDLE_MS) flush();
|
if (g_dirty && millis() - g_dirty_ms > SAVE_IDLE_MS) flush();
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Tunables Module
|
* Tunables Module
|
||||||
*
|
*
|
||||||
* Owns the link_config_t that Controller A pushes to Controller B: Patrol gauge
|
* Owns the link_config_t that Main CTRL pushes to Inst. Cluster: Patrol gauge
|
||||||
* calibration (tach pulses/rev, coolant PWM law) and the alert thresholds A
|
* calibration (tach pulses/rev, coolant PWM law) and the alert thresholds A
|
||||||
* evaluates. Persisted in NVS. Editable at runtime over the USB serial console
|
* evaluates. Persisted in NVS. Editable at runtime over the USB serial console
|
||||||
* ("cfg help") until a settings-screen UI exists.
|
* ("cfg help") until a settings-screen UI exists.
|
||||||
@@ -65,6 +65,9 @@ void pollSerial();
|
|||||||
*/
|
*/
|
||||||
void flush();
|
void flush();
|
||||||
|
|
||||||
|
/** True while edits are waiting for their deferred NVS write. */
|
||||||
|
bool isDirty();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a second console command handler (e.g. DiagProbe::handleCommand)
|
* Register a second console command handler (e.g. DiagProbe::handleCommand)
|
||||||
* that gets lines `cfg` does not recognise. Returns true if it consumed the line.
|
* that gets lines `cfg` does not recognise. Returns true if it consumed the line.
|
||||||
|
|||||||
+342
-360
@@ -1,35 +1,25 @@
|
|||||||
/*
|
/*
|
||||||
* Gauge Tuning Screen Module Implementation
|
* Gauge Tuning Screen Module Implementation
|
||||||
|
*
|
||||||
|
* Four tabs (Tachometer / Coolant gauge / Alerts / Simulation), one value per
|
||||||
|
* row with a plain-language hint, car-sized -/+ buttons (hold to repeat,
|
||||||
|
* speeding up the longer you hold). Tabs are plain buttons + hidden panels:
|
||||||
|
* no sliding tabview animation, which re-renders the whole panel per frame.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "tuning_screen.h"
|
#include "tuning_screen.h"
|
||||||
#include "tunables.h"
|
#include "tunables.h"
|
||||||
|
#include "ui_kit.h"
|
||||||
#include "driveline_screen.h"
|
#include "driveline_screen.h"
|
||||||
#include "display/lvgl_v8_port.h"
|
#include "display/lvgl_v8_port.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#include "ui.h"
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace TuningScreen
|
namespace TuningScreen
|
||||||
{
|
{
|
||||||
|
using namespace UiKit;
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// THEME
|
// FIELD TABLE - one row per numeric tunable
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
#define COL_BG lv_color_hex(0x101418)
|
|
||||||
#define COL_PANEL lv_color_hex(0x1B2128)
|
|
||||||
#define COL_TEXT lv_color_hex(0xE8EDF2)
|
|
||||||
#define COL_MUTED lv_color_hex(0x6E7B88)
|
|
||||||
#define COL_ACCENT lv_color_hex(0x3DA9FC)
|
|
||||||
#define COL_OK lv_color_hex(0x3DD68C)
|
|
||||||
#define COL_WARN lv_color_hex(0xE5484D)
|
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// FIELD TABLE — one row per numeric tunable
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
@@ -48,11 +38,14 @@ namespace TuningScreen
|
|||||||
F_COUNT
|
F_COUNT
|
||||||
} field_t;
|
} field_t;
|
||||||
|
|
||||||
|
typedef enum { TAB_TACH, TAB_COOLANT, TAB_ALERTS, TAB_SIM, TAB_COUNT } tab_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
field_t id;
|
field_t id;
|
||||||
|
tab_t tab;
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *unit;
|
const char *hint;
|
||||||
int32_t step;
|
int32_t step;
|
||||||
int32_t min;
|
int32_t min;
|
||||||
int32_t max;
|
int32_t max;
|
||||||
@@ -60,47 +53,37 @@ namespace TuningScreen
|
|||||||
} row_t;
|
} row_t;
|
||||||
|
|
||||||
static row_t g_rows[F_COUNT] = {
|
static row_t g_rows[F_COUNT] = {
|
||||||
{F_TACH_PPR, "Pulses / rev", "", 1, 1, 32, NULL},
|
{F_TACH_PPR, TAB_TACH, "Pulses per revolution", "Pulses per engine revolution the Patrol tach expects", 1, 1, 32, NULL},
|
||||||
{F_TACH_TRIM, "Trim", "%", 1, -50, 50, NULL},
|
{F_TACH_TRIM, TAB_TACH, "Trim", "Fine correction if the needle reads high or low", 1, -50, 50, NULL},
|
||||||
{F_TACH_MAX_HZ, "Max output", "Hz", 10, 0, 5000, NULL},
|
{F_TACH_MAX_HZ, TAB_TACH, "Maximum output", "Highest tach frequency sent (0 = no limit)", 10, 0, 5000, NULL},
|
||||||
{F_TEMP_HZ, "PWM frequency", "Hz", 50, 20, 20000, NULL},
|
{F_TEMP_HZ, TAB_COOLANT, "PWM frequency", "Drive frequency of the coolant gauge signal", 50, 20, 20000, NULL},
|
||||||
{F_TEMP_SLOPE, "Slope", "x100", 5, 0, 5000, NULL},
|
{F_TEMP_SLOPE, TAB_COOLANT, "Slope", "Duty added per \xC2\xB0" "C of coolant", 5, 0, 5000, NULL},
|
||||||
{F_TEMP_OFFSET, "Offset", "", 1, -1000, 1000, NULL},
|
{F_TEMP_OFFSET, TAB_COOLANT, "Offset", "Duty at 0 \xC2\xB0" "C (duty = slope x temp + offset)", 1, -1000, 1000, NULL},
|
||||||
{F_TEMP_MIN, "Min temp", "C", 1, -50, 200, NULL},
|
{F_TEMP_MIN, TAB_COOLANT, "Minimum temperature", "Needle stays at rest below this", 1, -50, 200, NULL},
|
||||||
{F_TEMP_DUTY_MAX, "Duty clamp", "", 5, 0, 255, NULL},
|
{F_TEMP_DUTY_MAX, TAB_COOLANT, "Duty limit", "Highest duty sent (255 = full scale)", 5, 0, 255, NULL},
|
||||||
{F_COOLANT_HOT, "Coolant hot", "C", 1, 0, 200, NULL},
|
{F_COOLANT_HOT, TAB_ALERTS, "Coolant too hot", "Alarm on Inst. Cluster at or above this temperature", 1, 0, 200, NULL},
|
||||||
{F_GEARBOX_HOT, "Gearbox hot", "C", 1, 0, 200, NULL},
|
{F_GEARBOX_HOT, TAB_ALERTS, "Gearbox oil too hot", "Alarm on Inst. Cluster at or above this temperature", 1, 0, 200, NULL},
|
||||||
{F_BATT_LOW, "Battery low", "x0.01V", 10, 0, 3000, NULL},
|
{F_BATT_LOW, TAB_ALERTS, "Battery low", "Alarm on Inst. Cluster below this voltage", 10, 0, 3000, NULL},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const char *TAB_NAMES[TAB_COUNT] = {"Tachometer", "Coolant gauge", "Alerts", "Simulation"};
|
||||||
|
|
||||||
static int32_t getField(const link_config_t &c, field_t f)
|
static int32_t getField(const link_config_t &c, field_t f)
|
||||||
{
|
{
|
||||||
switch (f)
|
switch (f)
|
||||||
{
|
{
|
||||||
case F_TACH_PPR:
|
case F_TACH_PPR: return c.tach_ppr;
|
||||||
return c.tach_ppr;
|
case F_TACH_TRIM: return c.tach_trim_pct;
|
||||||
case F_TACH_TRIM:
|
case F_TACH_MAX_HZ: return c.tach_max_hz;
|
||||||
return c.tach_trim_pct;
|
case F_TEMP_HZ: return c.temp_pwm_hz;
|
||||||
case F_TACH_MAX_HZ:
|
case F_TEMP_SLOPE: return c.temp_slope_x100;
|
||||||
return c.tach_max_hz;
|
case F_TEMP_OFFSET: return c.temp_offset;
|
||||||
case F_TEMP_HZ:
|
case F_TEMP_MIN: return c.temp_min_c;
|
||||||
return c.temp_pwm_hz;
|
case F_TEMP_DUTY_MAX: return c.temp_duty_max;
|
||||||
case F_TEMP_SLOPE:
|
case F_COOLANT_HOT: return c.coolant_hot_c;
|
||||||
return c.temp_slope_x100;
|
case F_GEARBOX_HOT: return c.gearbox_hot_c;
|
||||||
case F_TEMP_OFFSET:
|
case F_BATT_LOW: return c.battery_low_x100;
|
||||||
return c.temp_offset;
|
default: return 0;
|
||||||
case F_TEMP_MIN:
|
|
||||||
return c.temp_min_c;
|
|
||||||
case F_TEMP_DUTY_MAX:
|
|
||||||
return c.temp_duty_max;
|
|
||||||
case F_COOLANT_HOT:
|
|
||||||
return c.coolant_hot_c;
|
|
||||||
case F_GEARBOX_HOT:
|
|
||||||
return c.gearbox_hot_c;
|
|
||||||
case F_BATT_LOW:
|
|
||||||
return c.battery_low_x100;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,41 +91,36 @@ namespace TuningScreen
|
|||||||
{
|
{
|
||||||
switch (f)
|
switch (f)
|
||||||
{
|
{
|
||||||
case F_TACH_PPR:
|
case F_TACH_PPR: c.tach_ppr = (uint8_t)v; break;
|
||||||
c.tach_ppr = (uint8_t)v;
|
case F_TACH_TRIM: c.tach_trim_pct = (int8_t)v; break;
|
||||||
break;
|
case F_TACH_MAX_HZ: c.tach_max_hz = (uint16_t)v; break;
|
||||||
case F_TACH_TRIM:
|
case F_TEMP_HZ: c.temp_pwm_hz = (uint16_t)v; break;
|
||||||
c.tach_trim_pct = (int8_t)v;
|
case F_TEMP_SLOPE: c.temp_slope_x100 = (uint16_t)v; break;
|
||||||
break;
|
case F_TEMP_OFFSET: c.temp_offset = (int16_t)v; break;
|
||||||
case F_TACH_MAX_HZ:
|
case F_TEMP_MIN: c.temp_min_c = (int16_t)v; break;
|
||||||
c.tach_max_hz = (uint16_t)v;
|
case F_TEMP_DUTY_MAX: c.temp_duty_max = (uint8_t)v; break;
|
||||||
break;
|
case F_COOLANT_HOT: c.coolant_hot_c = (int16_t)v; break;
|
||||||
case F_TEMP_HZ:
|
case F_GEARBOX_HOT: c.gearbox_hot_c = (int16_t)v; break;
|
||||||
c.temp_pwm_hz = (uint16_t)v;
|
case F_BATT_LOW: c.battery_low_x100 = (uint16_t)v; break;
|
||||||
break;
|
default: break;
|
||||||
case F_TEMP_SLOPE:
|
}
|
||||||
c.temp_slope_x100 = (uint16_t)v;
|
}
|
||||||
break;
|
|
||||||
case F_TEMP_OFFSET:
|
static void formatValue(field_t f, int32_t v, char *out, size_t n)
|
||||||
c.temp_offset = (int16_t)v;
|
{
|
||||||
break;
|
switch (f)
|
||||||
|
{
|
||||||
|
case F_TACH_TRIM: snprintf(out, n, "%+ld %%", (long)v); break;
|
||||||
|
case F_TACH_MAX_HZ: if (v == 0) snprintf(out, n, "no limit"); else snprintf(out, n, "%ld Hz", (long)v); break;
|
||||||
|
case F_TEMP_HZ: snprintf(out, n, "%ld Hz", (long)v); break;
|
||||||
|
case F_TEMP_SLOPE: snprintf(out, n, "%ld.%02ld", (long)(v / 100), (long)labs(v % 100)); break;
|
||||||
|
case F_TEMP_OFFSET: snprintf(out, n, "%+ld", (long)v); break;
|
||||||
case F_TEMP_MIN:
|
case F_TEMP_MIN:
|
||||||
c.temp_min_c = (int16_t)v;
|
|
||||||
break;
|
|
||||||
case F_TEMP_DUTY_MAX:
|
|
||||||
c.temp_duty_max = (uint8_t)v;
|
|
||||||
break;
|
|
||||||
case F_COOLANT_HOT:
|
case F_COOLANT_HOT:
|
||||||
c.coolant_hot_c = (int16_t)v;
|
case F_GEARBOX_HOT: snprintf(out, n, "%ld \xC2\xB0" "C", (long)v); break;
|
||||||
break;
|
case F_TEMP_DUTY_MAX: snprintf(out, n, "%ld / 255", (long)v); break;
|
||||||
case F_GEARBOX_HOT:
|
case F_BATT_LOW: snprintf(out, n, "%ld.%02ld V", (long)(v / 100), (long)(v % 100)); break;
|
||||||
c.gearbox_hot_c = (int16_t)v;
|
default: snprintf(out, n, "%ld", (long)v); break;
|
||||||
break;
|
|
||||||
case F_BATT_LOW:
|
|
||||||
c.battery_low_x100 = (uint16_t)v;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,6 +129,12 @@ namespace TuningScreen
|
|||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
static lv_obj_t *g_screen = NULL;
|
static lv_obj_t *g_screen = NULL;
|
||||||
|
static lv_obj_t *g_tab_btn[TAB_COUNT];
|
||||||
|
static lv_obj_t *g_tab_page[TAB_COUNT];
|
||||||
|
static tab_t g_tab = TAB_TACH;
|
||||||
|
static lv_obj_t *g_reset_btn = NULL;
|
||||||
|
static lv_obj_t *g_sim_chip = NULL;
|
||||||
|
static lv_obj_t *g_save_lbl = NULL;
|
||||||
static lv_obj_t *g_tach_en_sw = NULL;
|
static lv_obj_t *g_tach_en_sw = NULL;
|
||||||
static lv_obj_t *g_temp_en_sw = NULL;
|
static lv_obj_t *g_temp_en_sw = NULL;
|
||||||
static lv_obj_t *g_ovr_rpm_sw = NULL;
|
static lv_obj_t *g_ovr_rpm_sw = NULL;
|
||||||
@@ -159,32 +143,34 @@ namespace TuningScreen
|
|||||||
static lv_obj_t *g_ovr_duty_sl = NULL;
|
static lv_obj_t *g_ovr_duty_sl = NULL;
|
||||||
static lv_obj_t *g_ovr_rpm_lbl = NULL;
|
static lv_obj_t *g_ovr_rpm_lbl = NULL;
|
||||||
static lv_obj_t *g_ovr_duty_lbl = NULL;
|
static lv_obj_t *g_ovr_duty_lbl = NULL;
|
||||||
static lv_obj_t *g_status_lbl = NULL;
|
|
||||||
static uint8_t g_shown_version = 0;
|
static uint8_t g_shown_version = 0;
|
||||||
static bool g_refreshing = false; // suppress event handlers while we set widget values
|
static bool g_refreshing = false; // suppress event handlers while we set widget values
|
||||||
|
static uint16_t g_repeats = 0; // long-press repeat count of the button being held
|
||||||
|
|
||||||
|
static const int32_t RPM_MAX = 6000, RPM_STEP = 100;
|
||||||
|
static const int32_t DUTY_MAX = 255, DUTY_STEP = 5;
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// HELPERS
|
// REFRESH
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
static void formatValue(const row_t &r, int32_t v, char *out, size_t n)
|
static void refreshSaveState()
|
||||||
{
|
{
|
||||||
if (r.id == F_TEMP_SLOPE)
|
link_config_t c = Tunables::get();
|
||||||
{
|
const char *txt;
|
||||||
snprintf(out, n, "%ld.%02ld", (long)(v / 100), (long)labs(v % 100));
|
lv_color_t col = UI_COL_MUTED;
|
||||||
}
|
if (g_tab == TAB_SIM)
|
||||||
else if (r.id == F_BATT_LOW)
|
txt = "Simulation values are never saved - a restart returns to live data";
|
||||||
{
|
else if (Tunables::isDirty())
|
||||||
snprintf(out, n, "%ld.%02ld V", (long)(v / 100), (long)(v % 100));
|
txt = "Saving...";
|
||||||
}
|
|
||||||
else if (r.unit[0])
|
|
||||||
{
|
|
||||||
snprintf(out, n, "%ld %s", (long)v, r.unit);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
snprintf(out, n, "%ld", (long)v);
|
txt = LV_SYMBOL_OK " All changes saved";
|
||||||
|
col = UI_COL_OK;
|
||||||
}
|
}
|
||||||
|
setText(g_save_lbl, txt);
|
||||||
|
setTextColor(g_save_lbl, col);
|
||||||
|
setVisible(g_sim_chip, c.override_mode != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void refreshFromTunables()
|
static void refreshFromTunables()
|
||||||
@@ -192,58 +178,38 @@ namespace TuningScreen
|
|||||||
link_config_t c = Tunables::get();
|
link_config_t c = Tunables::get();
|
||||||
g_refreshing = true;
|
g_refreshing = true;
|
||||||
|
|
||||||
char buf[24];
|
char buf[32];
|
||||||
for (int i = 0; i < F_COUNT; i++)
|
for (int i = 0; i < F_COUNT; i++)
|
||||||
{
|
{
|
||||||
if (g_rows[i].value_lbl == NULL)
|
if (g_rows[i].value_lbl == NULL)
|
||||||
continue;
|
continue;
|
||||||
formatValue(g_rows[i], getField(c, g_rows[i].id), buf, sizeof(buf));
|
formatValue(g_rows[i].id, getField(c, g_rows[i].id), buf, sizeof(buf));
|
||||||
lv_label_set_text(g_rows[i].value_lbl, buf);
|
setText(g_rows[i].value_lbl, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto setSw = [](lv_obj_t *sw, bool on)
|
setChecked(g_tach_en_sw, c.out_enable & OUT_ENABLE_TACH);
|
||||||
{
|
setChecked(g_temp_en_sw, c.out_enable & OUT_ENABLE_TEMP);
|
||||||
if (sw == NULL)
|
setChecked(g_ovr_rpm_sw, c.override_mode & OVERRIDE_TACH);
|
||||||
return;
|
setChecked(g_ovr_duty_sw, c.override_mode & OVERRIDE_TEMP);
|
||||||
if (on)
|
|
||||||
lv_obj_add_state(sw, LV_STATE_CHECKED);
|
|
||||||
else
|
|
||||||
lv_obj_clear_state(sw, LV_STATE_CHECKED);
|
|
||||||
};
|
|
||||||
setSw(g_tach_en_sw, c.out_enable & OUT_ENABLE_TACH);
|
|
||||||
setSw(g_temp_en_sw, c.out_enable & OUT_ENABLE_TEMP);
|
|
||||||
setSw(g_ovr_rpm_sw, c.override_mode & OVERRIDE_TACH);
|
|
||||||
setSw(g_ovr_duty_sw, c.override_mode & OVERRIDE_TEMP);
|
|
||||||
|
|
||||||
if (g_ovr_rpm_sl)
|
if (g_ovr_rpm_sl && !lv_obj_has_state(g_ovr_rpm_sl, LV_STATE_PRESSED))
|
||||||
lv_slider_set_value(g_ovr_rpm_sl, c.override_rpm, LV_ANIM_OFF);
|
lv_slider_set_value(g_ovr_rpm_sl, c.override_rpm, LV_ANIM_OFF);
|
||||||
if (g_ovr_duty_sl)
|
if (g_ovr_duty_sl && !lv_obj_has_state(g_ovr_duty_sl, LV_STATE_PRESSED))
|
||||||
lv_slider_set_value(g_ovr_duty_sl, c.override_duty, LV_ANIM_OFF);
|
lv_slider_set_value(g_ovr_duty_sl, c.override_duty, LV_ANIM_OFF);
|
||||||
if (g_ovr_rpm_lbl)
|
snprintf(buf, sizeof(buf), "%u rpm", c.override_rpm);
|
||||||
{
|
setText(g_ovr_rpm_lbl, buf);
|
||||||
snprintf(buf, sizeof(buf), "%u rpm", c.override_rpm);
|
snprintf(buf, sizeof(buf), "%u / 255", c.override_duty);
|
||||||
lv_label_set_text(g_ovr_rpm_lbl, buf);
|
setText(g_ovr_duty_lbl, buf);
|
||||||
}
|
|
||||||
if (g_ovr_duty_lbl)
|
|
||||||
{
|
|
||||||
snprintf(buf, sizeof(buf), "%u / 255", c.override_duty);
|
|
||||||
lv_label_set_text(g_ovr_duty_lbl, buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_status_lbl)
|
|
||||||
{
|
|
||||||
snprintf(buf, sizeof(buf), "config v%u", c.cfg_version);
|
|
||||||
lv_label_set_text(g_status_lbl, buf);
|
|
||||||
lv_obj_set_style_text_color(g_status_lbl, c.override_mode ? COL_WARN : COL_MUTED, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
refreshSaveState();
|
||||||
g_shown_version = c.cfg_version;
|
g_shown_version = c.cfg_version;
|
||||||
g_refreshing = false;
|
g_refreshing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- event handlers --------------------------------------------------------
|
// ============================================================================
|
||||||
|
// EVENT HANDLERS
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
// user_data = row pointer; the button's own user data (+1/-1) is in lv_event_get_user_data
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
row_t *row;
|
row_t *row;
|
||||||
@@ -251,29 +217,44 @@ namespace TuningScreen
|
|||||||
} step_ctx_t;
|
} step_ctx_t;
|
||||||
static step_ctx_t g_step_ctx[F_COUNT][2];
|
static step_ctx_t g_step_ctx[F_COUNT][2];
|
||||||
|
|
||||||
|
/** 1x for taps and the first second of a hold, then 5x, then 10x. */
|
||||||
|
static int32_t holdMultiplier(lv_event_code_t code)
|
||||||
|
{
|
||||||
|
if (code == LV_EVENT_PRESSED)
|
||||||
|
{
|
||||||
|
g_repeats = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (code == LV_EVENT_LONG_PRESSED_REPEAT)
|
||||||
|
{
|
||||||
|
g_repeats++;
|
||||||
|
return g_repeats > 25 ? 10 : g_repeats > 10 ? 5 : 1;
|
||||||
|
}
|
||||||
|
return 1; // CLICKED
|
||||||
|
}
|
||||||
|
|
||||||
static void onStep(lv_event_t *e)
|
static void onStep(lv_event_t *e)
|
||||||
{
|
{
|
||||||
lv_event_code_t code = lv_event_get_code(e);
|
lv_event_code_t code = lv_event_get_code(e);
|
||||||
if (code != LV_EVENT_CLICKED && code != LV_EVENT_LONG_PRESSED_REPEAT)
|
int32_t mult = holdMultiplier(code);
|
||||||
|
if (mult == 0)
|
||||||
return;
|
return;
|
||||||
|
if (code == LV_EVENT_CLICKED && g_repeats > 0)
|
||||||
|
return; // end of a hold, already applied
|
||||||
step_ctx_t *ctx = (step_ctx_t *)lv_event_get_user_data(e);
|
step_ctx_t *ctx = (step_ctx_t *)lv_event_get_user_data(e);
|
||||||
link_config_t c = Tunables::get();
|
link_config_t c = Tunables::get();
|
||||||
int32_t v = getField(c, ctx->row->id) + ctx->dir * ctx->row->step;
|
int32_t v = getField(c, ctx->row->id) + ctx->dir * ctx->row->step * mult;
|
||||||
if (v < ctx->row->min)
|
v = constrain(v, ctx->row->min, ctx->row->max);
|
||||||
v = ctx->row->min;
|
|
||||||
if (v > ctx->row->max)
|
|
||||||
v = ctx->row->max;
|
|
||||||
setField(c, ctx->row->id, v);
|
setField(c, ctx->row->id, v);
|
||||||
Tunables::set(c); // saves + bumps version -> CONFIG frame goes out
|
Tunables::set(c); // bumps version -> CONFIG frame goes out; NVS write after 3 s idle
|
||||||
refreshFromTunables();
|
refreshFromTunables();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void onEnableSwitch(lv_event_t *e)
|
static void onEnableSwitch(lv_event_t *e)
|
||||||
{
|
{
|
||||||
if (g_refreshing || lv_event_get_code(e) != LV_EVENT_VALUE_CHANGED)
|
if (g_refreshing)
|
||||||
return;
|
return;
|
||||||
lv_obj_t *sw = lv_event_get_target(e);
|
bool on = lv_obj_has_state(lv_event_get_target(e), LV_STATE_CHECKED);
|
||||||
bool on = lv_obj_has_state(sw, LV_STATE_CHECKED);
|
|
||||||
uint8_t bit = (uint8_t)(uintptr_t)lv_event_get_user_data(e);
|
uint8_t bit = (uint8_t)(uintptr_t)lv_event_get_user_data(e);
|
||||||
link_config_t c = Tunables::get();
|
link_config_t c = Tunables::get();
|
||||||
c.out_enable = on ? (c.out_enable | bit) : (c.out_enable & ~bit);
|
c.out_enable = on ? (c.out_enable | bit) : (c.out_enable & ~bit);
|
||||||
@@ -283,23 +264,21 @@ namespace TuningScreen
|
|||||||
|
|
||||||
static void pushOverride()
|
static void pushOverride()
|
||||||
{
|
{
|
||||||
link_config_t c = Tunables::get();
|
|
||||||
uint8_t mode = 0;
|
uint8_t mode = 0;
|
||||||
if (g_ovr_rpm_sw && lv_obj_has_state(g_ovr_rpm_sw, LV_STATE_CHECKED))
|
if (lv_obj_has_state(g_ovr_rpm_sw, LV_STATE_CHECKED))
|
||||||
mode |= OVERRIDE_TACH;
|
mode |= OVERRIDE_TACH;
|
||||||
if (g_ovr_duty_sw && lv_obj_has_state(g_ovr_duty_sw, LV_STATE_CHECKED))
|
if (lv_obj_has_state(g_ovr_duty_sw, LV_STATE_CHECKED))
|
||||||
mode |= OVERRIDE_TEMP;
|
mode |= OVERRIDE_TEMP;
|
||||||
uint16_t rpm = g_ovr_rpm_sl ? (uint16_t)lv_slider_get_value(g_ovr_rpm_sl) : c.override_rpm;
|
Tunables::setOverride(mode, (uint16_t)lv_slider_get_value(g_ovr_rpm_sl),
|
||||||
uint8_t duty = g_ovr_duty_sl ? (uint8_t)lv_slider_get_value(g_ovr_duty_sl) : c.override_duty;
|
(uint8_t)lv_slider_get_value(g_ovr_duty_sl)); // pushed to B, never saved
|
||||||
Tunables::setOverride(mode, rpm, duty); // pushed to B, never saved
|
|
||||||
refreshFromTunables();
|
refreshFromTunables();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void onOverrideSwitch(lv_event_t *e)
|
static void onOverrideSwitch(lv_event_t *e)
|
||||||
{
|
{
|
||||||
if (g_refreshing || lv_event_get_code(e) != LV_EVENT_VALUE_CHANGED)
|
(void)e;
|
||||||
return;
|
if (!g_refreshing)
|
||||||
pushOverride();
|
pushOverride();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void onOverrideSlider(lv_event_t *e)
|
static void onOverrideSlider(lv_event_t *e)
|
||||||
@@ -307,21 +286,21 @@ namespace TuningScreen
|
|||||||
if (g_refreshing)
|
if (g_refreshing)
|
||||||
return;
|
return;
|
||||||
lv_event_code_t code = lv_event_get_code(e);
|
lv_event_code_t code = lv_event_get_code(e);
|
||||||
// Update the readout while dragging; push to B on release so we don't
|
lv_obj_t *sl = lv_event_get_target(e);
|
||||||
// flood the link with CONFIG frames at touch rate.
|
// Readout follows the finger; push to B on release so we don't flood
|
||||||
|
// the link with CONFIG frames at touch rate.
|
||||||
if (code == LV_EVENT_VALUE_CHANGED)
|
if (code == LV_EVENT_VALUE_CHANGED)
|
||||||
{
|
{
|
||||||
char buf[24];
|
char buf[24];
|
||||||
lv_obj_t *sl = lv_event_get_target(e);
|
if (sl == g_ovr_rpm_sl)
|
||||||
if (sl == g_ovr_rpm_sl && g_ovr_rpm_lbl)
|
|
||||||
{
|
{
|
||||||
snprintf(buf, sizeof(buf), "%d rpm", (int)lv_slider_get_value(sl));
|
snprintf(buf, sizeof(buf), "%d rpm", (int)lv_slider_get_value(sl));
|
||||||
lv_label_set_text(g_ovr_rpm_lbl, buf);
|
setText(g_ovr_rpm_lbl, buf);
|
||||||
}
|
}
|
||||||
else if (sl == g_ovr_duty_sl && g_ovr_duty_lbl)
|
else
|
||||||
{
|
{
|
||||||
snprintf(buf, sizeof(buf), "%d / 255", (int)lv_slider_get_value(sl));
|
snprintf(buf, sizeof(buf), "%d / 255", (int)lv_slider_get_value(sl));
|
||||||
lv_label_set_text(g_ovr_duty_lbl, buf);
|
setText(g_ovr_duty_lbl, buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (code == LV_EVENT_RELEASED)
|
else if (code == LV_EVENT_RELEASED)
|
||||||
@@ -330,250 +309,252 @@ namespace TuningScreen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Fine -/+ next to a slider; user data = +/-1, slider picked by the button's parent row. */
|
||||||
|
static void onSimStep(lv_event_t *e)
|
||||||
|
{
|
||||||
|
lv_event_code_t code = lv_event_get_code(e);
|
||||||
|
int32_t mult = holdMultiplier(code);
|
||||||
|
if (mult == 0 || (code == LV_EVENT_CLICKED && g_repeats > 0))
|
||||||
|
return;
|
||||||
|
int dir = (int)(intptr_t)lv_event_get_user_data(e);
|
||||||
|
lv_obj_t *btn = lv_event_get_target(e);
|
||||||
|
bool rpm = lv_obj_get_parent(btn) == lv_obj_get_parent(g_ovr_rpm_sl);
|
||||||
|
lv_obj_t *sl = rpm ? g_ovr_rpm_sl : g_ovr_duty_sl;
|
||||||
|
int32_t v = lv_slider_get_value(sl) + dir * (rpm ? RPM_STEP : DUTY_STEP) * mult;
|
||||||
|
lv_slider_set_value(sl, constrain(v, 0, rpm ? RPM_MAX : DUTY_MAX), LV_ANIM_OFF);
|
||||||
|
pushOverride();
|
||||||
|
}
|
||||||
|
|
||||||
static void onBack(lv_event_t *e)
|
static void onBack(lv_event_t *e)
|
||||||
{
|
{
|
||||||
if (lv_event_get_code(e) != LV_EVENT_CLICKED)
|
(void)e;
|
||||||
return;
|
Tunables::flush(); // write pending edits now rather than after the idle delay
|
||||||
Tunables::flush(); // write pending edits now rather than after the idle delay
|
|
||||||
DrivelineScreen::show();
|
DrivelineScreen::show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void onGesture(lv_event_t *e)
|
||||||
|
{
|
||||||
|
(void)e;
|
||||||
|
if (lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_LEFT)
|
||||||
|
{
|
||||||
|
lv_indev_wait_release(lv_indev_get_act());
|
||||||
|
Tunables::flush();
|
||||||
|
DrivelineScreen::show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void onResetConfirmed(bool ok, void *user)
|
||||||
|
{
|
||||||
|
if (!ok)
|
||||||
|
return;
|
||||||
|
tab_t tab = (tab_t)(uintptr_t)user;
|
||||||
|
link_config_t d, c = Tunables::get();
|
||||||
|
link_config_defaults(&d);
|
||||||
|
for (int i = 0; i < F_COUNT; i++)
|
||||||
|
if (g_rows[i].tab == tab)
|
||||||
|
setField(c, g_rows[i].id, getField(d, g_rows[i].id));
|
||||||
|
uint8_t bit = tab == TAB_TACH ? OUT_ENABLE_TACH : tab == TAB_COOLANT ? OUT_ENABLE_TEMP : 0;
|
||||||
|
c.out_enable = (c.out_enable & ~bit) | (d.out_enable & bit);
|
||||||
|
Tunables::set(c);
|
||||||
|
refreshFromTunables();
|
||||||
|
}
|
||||||
|
|
||||||
static void onReset(lv_event_t *e)
|
static void onReset(lv_event_t *e)
|
||||||
{
|
{
|
||||||
if (lv_event_get_code(e) != LV_EVENT_CLICKED)
|
(void)e;
|
||||||
return;
|
char title[64];
|
||||||
Tunables::resetDefaults();
|
snprintf(title, sizeof(title), "Reset %s?", TAB_NAMES[g_tab]);
|
||||||
refreshFromTunables();
|
confirm(title, "Every value on this tab goes back to its default. The other tabs are not touched.",
|
||||||
|
"Reset", onResetConfirmed, (void *)(uintptr_t)g_tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- builders --------------------------------------------------------------
|
static void selectTab(tab_t t)
|
||||||
|
|
||||||
static lv_obj_t *makePanel(lv_obj_t *parent, const char *title, lv_coord_t w)
|
|
||||||
{
|
{
|
||||||
lv_obj_t *p = lv_obj_create(parent);
|
g_tab = t;
|
||||||
lv_obj_set_size(p, w, LV_SIZE_CONTENT);
|
for (int i = 0; i < TAB_COUNT; i++)
|
||||||
lv_obj_set_style_bg_color(p, COL_PANEL, 0);
|
{
|
||||||
lv_obj_set_style_border_width(p, 0, 0);
|
bool on = (i == t);
|
||||||
lv_obj_set_style_radius(p, 12, 0);
|
setVisible(g_tab_page[i], on);
|
||||||
lv_obj_set_style_pad_all(p, 12, 0);
|
lv_obj_set_style_bg_color(g_tab_btn[i], on ? UI_COL_ACCENT : UI_COL_PANEL, 0);
|
||||||
lv_obj_set_style_pad_row(p, 6, 0);
|
lv_obj_set_style_text_color(g_tab_btn[i], on ? lv_color_hex(0x0B1620) : UI_COL_TEXT, 0);
|
||||||
lv_obj_set_flex_flow(p, LV_FLEX_FLOW_COLUMN);
|
}
|
||||||
lv_obj_clear_flag(p, LV_OBJ_FLAG_SCROLLABLE);
|
setVisible(g_reset_btn, t != TAB_SIM);
|
||||||
|
refreshSaveState();
|
||||||
lv_obj_t *t = lv_label_create(p);
|
|
||||||
lv_label_set_text(t, title);
|
|
||||||
lv_obj_set_style_text_font(t, &lv_font_montserrat_14, 0);
|
|
||||||
lv_obj_set_style_text_color(t, COL_ACCENT, 0);
|
|
||||||
lv_obj_set_style_pad_bottom(t, 4, 0);
|
|
||||||
return p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static lv_obj_t *makeStepBtn(lv_obj_t *parent, const char *txt, step_ctx_t *ctx)
|
static void onTab(lv_event_t *e)
|
||||||
{
|
{
|
||||||
lv_obj_t *b = lv_btn_create(parent);
|
selectTab((tab_t)(uintptr_t)lv_event_get_user_data(e));
|
||||||
lv_obj_set_size(b, 44, 36);
|
}
|
||||||
lv_obj_set_style_bg_color(b, COL_BG, 0);
|
|
||||||
lv_obj_set_style_radius(b, 8, 0);
|
// ============================================================================
|
||||||
lv_obj_add_event_cb(b, onStep, LV_EVENT_CLICKED, ctx);
|
// BUILDERS
|
||||||
lv_obj_add_event_cb(b, onStep, LV_EVENT_LONG_PRESSED_REPEAT, ctx);
|
// ============================================================================
|
||||||
lv_obj_t *l = lv_label_create(b);
|
|
||||||
lv_label_set_text(l, txt);
|
static lv_obj_t *makeStepBtn(lv_obj_t *parent, const char *txt, lv_event_cb_t cb, void *ctx)
|
||||||
lv_obj_set_style_text_font(l, &lv_font_montserrat_14, 0);
|
{
|
||||||
lv_obj_center(l);
|
lv_obj_t *b = button(parent, txt, 76, 56, BTN_SECONDARY, NULL, NULL);
|
||||||
|
lv_obj_set_style_text_font(lv_obj_get_child(b, 0), &lv_font_montserrat_24, 0);
|
||||||
|
lv_obj_add_event_cb(b, cb, LV_EVENT_PRESSED, ctx);
|
||||||
|
lv_obj_add_event_cb(b, cb, LV_EVENT_CLICKED, ctx);
|
||||||
|
lv_obj_add_event_cb(b, cb, LV_EVENT_LONG_PRESSED_REPEAT, ctx);
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void makeRow(lv_obj_t *panel, field_t f)
|
/** [name / hint] ... [-] value [+] */
|
||||||
|
static void makeRow(lv_obj_t *page, field_t f)
|
||||||
{
|
{
|
||||||
row_t *r = &g_rows[f];
|
row_t *r = &g_rows[f];
|
||||||
lv_obj_t *row = lv_obj_create(panel);
|
lv_obj_t *row = box(page, LV_FLEX_FLOW_ROW);
|
||||||
lv_obj_remove_style_all(row);
|
lv_obj_set_size(row, LV_PCT(100), 62);
|
||||||
lv_obj_set_size(row, LV_PCT(100), 36);
|
|
||||||
lv_obj_set_flex_flow(row, LV_FLEX_FLOW_ROW);
|
|
||||||
lv_obj_set_flex_align(row, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
|
lv_obj_set_flex_align(row, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
|
||||||
lv_obj_set_style_pad_column(row, 6, 0);
|
lv_obj_set_style_pad_column(row, 12, 0);
|
||||||
lv_obj_clear_flag(row, LV_OBJ_FLAG_SCROLLABLE);
|
|
||||||
|
|
||||||
lv_obj_t *name = lv_label_create(row);
|
lv_obj_t *txt = box(row, LV_FLEX_FLOW_COLUMN);
|
||||||
lv_label_set_text(name, r->name);
|
lv_obj_set_height(txt, LV_SIZE_CONTENT);
|
||||||
lv_obj_set_style_text_font(name, &lv_font_montserrat_14, 0);
|
lv_obj_set_flex_grow(txt, 1);
|
||||||
lv_obj_set_style_text_color(name, COL_MUTED, 0);
|
lv_obj_set_style_pad_row(txt, 2, 0);
|
||||||
lv_obj_set_width(name, 118);
|
label(txt, r->name, &lv_font_montserrat_24, UI_COL_TEXT);
|
||||||
|
label(txt, r->hint, &lv_font_montserrat_14, UI_COL_MUTED);
|
||||||
|
|
||||||
g_step_ctx[f][0] = {r, -1};
|
g_step_ctx[f][0] = {r, -1};
|
||||||
g_step_ctx[f][1] = {r, +1};
|
g_step_ctx[f][1] = {r, +1};
|
||||||
makeStepBtn(row, LV_SYMBOL_MINUS, &g_step_ctx[f][0]);
|
makeStepBtn(row, LV_SYMBOL_MINUS, onStep, &g_step_ctx[f][0]);
|
||||||
|
r->value_lbl = label(row, "--", &lv_font_montserrat_30, UI_COL_TEXT);
|
||||||
r->value_lbl = lv_label_create(row);
|
|
||||||
lv_label_set_text(r->value_lbl, "--");
|
|
||||||
lv_obj_set_style_text_font(r->value_lbl, &lv_font_montserrat_14, 0);
|
|
||||||
lv_obj_set_style_text_color(r->value_lbl, COL_TEXT, 0);
|
|
||||||
lv_obj_set_style_text_align(r->value_lbl, LV_TEXT_ALIGN_CENTER, 0);
|
lv_obj_set_style_text_align(r->value_lbl, LV_TEXT_ALIGN_CENTER, 0);
|
||||||
lv_obj_set_width(r->value_lbl, 82);
|
lv_obj_set_width(r->value_lbl, 190);
|
||||||
|
makeStepBtn(row, LV_SYMBOL_PLUS, onStep, &g_step_ctx[f][1]);
|
||||||
makeStepBtn(row, LV_SYMBOL_PLUS, &g_step_ctx[f][1]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static lv_obj_t *makeSwitchRow(lv_obj_t *panel, const char *text, lv_event_cb_t cb, void *user)
|
static lv_obj_t *makeSwitchRow(lv_obj_t *page, const char *name, const char *hint, lv_event_cb_t cb, void *user)
|
||||||
{
|
{
|
||||||
lv_obj_t *row = lv_obj_create(panel);
|
lv_obj_t *row = box(page, LV_FLEX_FLOW_ROW);
|
||||||
lv_obj_remove_style_all(row);
|
lv_obj_set_size(row, LV_PCT(100), 62);
|
||||||
lv_obj_set_size(row, LV_PCT(100), 36);
|
|
||||||
lv_obj_set_flex_flow(row, LV_FLEX_FLOW_ROW);
|
|
||||||
lv_obj_set_flex_align(row, LV_FLEX_ALIGN_SPACE_BETWEEN, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
|
lv_obj_set_flex_align(row, LV_FLEX_ALIGN_SPACE_BETWEEN, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
|
||||||
lv_obj_clear_flag(row, LV_OBJ_FLAG_SCROLLABLE);
|
lv_obj_t *txt = box(row, LV_FLEX_FLOW_COLUMN);
|
||||||
|
lv_obj_set_size(txt, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
|
||||||
lv_obj_t *l = lv_label_create(row);
|
lv_obj_set_style_pad_row(txt, 2, 0);
|
||||||
lv_label_set_text(l, text);
|
label(txt, name, &lv_font_montserrat_24, UI_COL_TEXT);
|
||||||
lv_obj_set_style_text_font(l, &lv_font_montserrat_14, 0);
|
label(txt, hint, &lv_font_montserrat_14, UI_COL_MUTED);
|
||||||
lv_obj_set_style_text_color(l, COL_MUTED, 0);
|
lv_obj_t *sw = toggle(row, cb, user);
|
||||||
|
lv_obj_set_style_pad_right(row, 70, 0); // line the switch up under the value column
|
||||||
lv_obj_t *sw = lv_switch_create(row);
|
|
||||||
lv_obj_set_style_bg_color(sw, COL_ACCENT, (lv_style_selector_t)LV_PART_INDICATOR | (lv_style_selector_t)LV_STATE_CHECKED);
|
|
||||||
lv_obj_add_event_cb(sw, cb, LV_EVENT_VALUE_CHANGED, user);
|
|
||||||
return sw;
|
return sw;
|
||||||
}
|
}
|
||||||
|
|
||||||
static lv_obj_t *makeSliderRow(lv_obj_t *panel, const char *text, int32_t max, lv_obj_t **readout)
|
/** Simulation card: title + readout + switch, then [-] slider [+]. */
|
||||||
|
static lv_obj_t *makeSimCard(lv_obj_t *page, const char *title, int32_t max, lv_obj_t **sw, lv_obj_t **readout)
|
||||||
{
|
{
|
||||||
lv_obj_t *head = lv_obj_create(panel);
|
lv_obj_t *c = card(page);
|
||||||
lv_obj_remove_style_all(head);
|
lv_obj_set_size(c, LV_PCT(100), LV_SIZE_CONTENT);
|
||||||
lv_obj_set_size(head, LV_PCT(100), 20);
|
lv_obj_set_flex_flow(c, LV_FLEX_FLOW_COLUMN);
|
||||||
lv_obj_set_flex_flow(head, LV_FLEX_FLOW_ROW);
|
lv_obj_set_style_pad_row(c, 14, 0);
|
||||||
lv_obj_set_flex_align(head, LV_FLEX_ALIGN_SPACE_BETWEEN, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
|
|
||||||
lv_obj_clear_flag(head, LV_OBJ_FLAG_SCROLLABLE);
|
|
||||||
|
|
||||||
lv_obj_t *l = lv_label_create(head);
|
lv_obj_t *top = box(c, LV_FLEX_FLOW_ROW);
|
||||||
lv_label_set_text(l, text);
|
lv_obj_set_size(top, LV_PCT(100), LV_SIZE_CONTENT);
|
||||||
lv_obj_set_style_text_font(l, &lv_font_montserrat_14, 0);
|
lv_obj_set_flex_align(top, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
|
||||||
lv_obj_set_style_text_color(l, COL_MUTED, 0);
|
lv_obj_t *t = label(top, title, &lv_font_montserrat_24, UI_COL_TEXT);
|
||||||
|
lv_obj_set_flex_grow(t, 1);
|
||||||
|
*readout = label(top, "--", &lv_font_montserrat_30, UI_COL_TEXT);
|
||||||
|
lv_obj_set_style_pad_right(*readout, 24, 0);
|
||||||
|
*sw = toggle(top, onOverrideSwitch, NULL);
|
||||||
|
|
||||||
*readout = lv_label_create(head);
|
lv_obj_t *bottom = box(c, LV_FLEX_FLOW_ROW);
|
||||||
lv_label_set_text(*readout, "--");
|
lv_obj_set_size(bottom, LV_PCT(100), LV_SIZE_CONTENT);
|
||||||
lv_obj_set_style_text_font(*readout, &lv_font_montserrat_14, 0);
|
lv_obj_set_flex_align(bottom, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
|
||||||
lv_obj_set_style_text_color(*readout, COL_TEXT, 0);
|
lv_obj_set_style_pad_column(bottom, 24, 0);
|
||||||
|
makeStepBtn(bottom, LV_SYMBOL_MINUS, onSimStep, (void *)(intptr_t)-1);
|
||||||
lv_obj_t *sl = lv_slider_create(panel);
|
lv_obj_t *sl = lv_slider_create(bottom);
|
||||||
lv_obj_set_width(sl, LV_PCT(96));
|
lv_obj_set_height(sl, 16);
|
||||||
|
lv_obj_set_flex_grow(sl, 1);
|
||||||
lv_slider_set_range(sl, 0, max);
|
lv_slider_set_range(sl, 0, max);
|
||||||
lv_obj_set_style_bg_color(sl, COL_BG, 0);
|
lv_obj_set_style_bg_color(sl, UI_COL_PANEL2, 0);
|
||||||
lv_obj_set_style_bg_color(sl, COL_ACCENT, LV_PART_INDICATOR);
|
lv_obj_set_style_bg_color(sl, UI_COL_ACCENT, LV_PART_INDICATOR);
|
||||||
lv_obj_set_style_bg_color(sl, COL_TEXT, LV_PART_KNOB);
|
lv_obj_set_style_bg_color(sl, UI_COL_TEXT, LV_PART_KNOB);
|
||||||
|
lv_obj_set_style_pad_all(sl, 12, LV_PART_KNOB); // big knob
|
||||||
|
lv_obj_set_style_anim_time(sl, 0, 0);
|
||||||
|
lv_obj_clear_flag(sl, LV_OBJ_FLAG_GESTURE_BUBBLE); // dragging must not change screens
|
||||||
lv_obj_add_event_cb(sl, onOverrideSlider, LV_EVENT_VALUE_CHANGED, NULL);
|
lv_obj_add_event_cb(sl, onOverrideSlider, LV_EVENT_VALUE_CHANGED, NULL);
|
||||||
lv_obj_add_event_cb(sl, onOverrideSlider, LV_EVENT_RELEASED, NULL);
|
lv_obj_add_event_cb(sl, onOverrideSlider, LV_EVENT_RELEASED, NULL);
|
||||||
|
lv_obj_set_style_pad_ver(bottom, 12, 0); // room for the knob
|
||||||
|
makeStepBtn(bottom, LV_SYMBOL_PLUS, onSimStep, (void *)(intptr_t)1);
|
||||||
return sl;
|
return sl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static lv_obj_t *makeTabPage()
|
||||||
|
{
|
||||||
|
lv_obj_t *p = box(g_screen, LV_FLEX_FLOW_COLUMN);
|
||||||
|
lv_obj_set_size(p, 1024 - 48, 600 - 150 - 36);
|
||||||
|
lv_obj_set_pos(p, 24, 150);
|
||||||
|
lv_obj_set_style_pad_row(p, 6, 0);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
static void build()
|
static void build()
|
||||||
{
|
{
|
||||||
if (g_screen != NULL)
|
if (g_screen != NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
g_screen = lv_obj_create(NULL);
|
g_screen = screen();
|
||||||
lv_obj_set_style_bg_color(g_screen, COL_BG, 0);
|
lv_obj_add_event_cb(g_screen, onGesture, LV_EVENT_GESTURE, NULL);
|
||||||
lv_obj_clear_flag(g_screen, LV_OBJ_FLAG_SCROLLABLE);
|
header(g_screen, "GAUGE TUNING", onBack);
|
||||||
// No swipe gesture on this screen: dragging the override sliders would
|
|
||||||
// otherwise change screens. Leave via the Driveline button (top right).
|
|
||||||
|
|
||||||
lv_obj_t *title = lv_label_create(g_screen);
|
g_sim_chip = label(g_screen, "SIMULATION ON", &lv_font_montserrat_20, UI_COL_TEXT);
|
||||||
lv_label_set_text(title, "GAUGE TUNING");
|
lv_obj_set_style_bg_color(g_sim_chip, UI_COL_WARN, 0);
|
||||||
lv_obj_set_style_text_font(title, &lv_font_montserrat_30, 0);
|
lv_obj_set_style_bg_opa(g_sim_chip, LV_OPA_COVER, 0);
|
||||||
lv_obj_set_style_text_color(title, COL_TEXT, 0);
|
lv_obj_set_style_radius(g_sim_chip, 8, 0);
|
||||||
lv_obj_align(title, LV_ALIGN_TOP_LEFT, 24, 16);
|
lv_obj_set_style_pad_hor(g_sim_chip, 12, 0);
|
||||||
|
lv_obj_set_style_pad_ver(g_sim_chip, 6, 0);
|
||||||
|
lv_obj_align(g_sim_chip, LV_ALIGN_TOP_LEFT, 290, 22);
|
||||||
|
lv_obj_add_flag(g_sim_chip, LV_OBJ_FLAG_HIDDEN);
|
||||||
|
|
||||||
lv_obj_t *back = lv_btn_create(g_screen);
|
g_reset_btn = button(g_screen, LV_SYMBOL_REFRESH " Reset tab", 190, 56, BTN_SECONDARY, onReset, NULL);
|
||||||
lv_obj_set_size(back, 150, 36);
|
lv_obj_align(g_reset_btn, LV_ALIGN_TOP_RIGHT, -16 - 200 - 12, 10);
|
||||||
lv_obj_align(back, LV_ALIGN_TOP_RIGHT, -24, 18);
|
|
||||||
lv_obj_set_style_bg_color(back, COL_ACCENT, 0);
|
|
||||||
lv_obj_add_event_cb(back, onBack, LV_EVENT_CLICKED, NULL);
|
|
||||||
lv_obj_t *bl = lv_label_create(back);
|
|
||||||
lv_label_set_text(bl, LV_SYMBOL_HOME " Driveline");
|
|
||||||
lv_obj_set_style_text_font(bl, &lv_font_montserrat_14, 0);
|
|
||||||
lv_obj_center(bl);
|
|
||||||
|
|
||||||
lv_obj_t *reset = lv_btn_create(g_screen);
|
// tab bar
|
||||||
lv_obj_set_size(reset, 150, 36);
|
for (int i = 0; i < TAB_COUNT; i++)
|
||||||
lv_obj_align(reset, LV_ALIGN_TOP_RIGHT, -24 - 150 - 12, 18);
|
{
|
||||||
lv_obj_set_style_bg_color(reset, COL_PANEL, 0);
|
g_tab_btn[i] = button(g_screen, TAB_NAMES[i], 232, 58, BTN_SECONDARY, onTab, (void *)(uintptr_t)i);
|
||||||
lv_obj_add_event_cb(reset, onReset, LV_EVENT_CLICKED, NULL);
|
lv_obj_set_pos(g_tab_btn[i], 24 + i * (232 + 12), 80);
|
||||||
lv_obj_t *rl = lv_label_create(reset);
|
g_tab_page[i] = makeTabPage();
|
||||||
lv_label_set_text(rl, LV_SYMBOL_REFRESH " Defaults");
|
}
|
||||||
lv_obj_set_style_text_font(rl, &lv_font_montserrat_14, 0);
|
|
||||||
lv_obj_center(rl);
|
|
||||||
|
|
||||||
// Three columns of panels
|
// ---- Tachometer ----
|
||||||
lv_obj_t *cols = lv_obj_create(g_screen);
|
makeRow(g_tab_page[TAB_TACH], F_TACH_PPR);
|
||||||
lv_obj_remove_style_all(cols);
|
makeRow(g_tab_page[TAB_TACH], F_TACH_TRIM);
|
||||||
lv_obj_set_size(cols, 1024 - 48, 600 - 70 - 30);
|
makeRow(g_tab_page[TAB_TACH], F_TACH_MAX_HZ);
|
||||||
lv_obj_align(cols, LV_ALIGN_TOP_LEFT, 24, 66);
|
g_tach_en_sw = makeSwitchRow(g_tab_page[TAB_TACH], "Tachometer output", "IO7 on Inst. Cluster. Off = no signal",
|
||||||
lv_obj_set_flex_flow(cols, LV_FLEX_FLOW_ROW);
|
onEnableSwitch, (void *)(uintptr_t)OUT_ENABLE_TACH);
|
||||||
lv_obj_set_flex_align(cols, LV_FLEX_ALIGN_SPACE_BETWEEN, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START);
|
|
||||||
lv_obj_clear_flag(cols, LV_OBJ_FLAG_SCROLLABLE);
|
|
||||||
|
|
||||||
const lv_coord_t W = 320;
|
// ---- Coolant gauge ----
|
||||||
|
makeRow(g_tab_page[TAB_COOLANT], F_TEMP_HZ);
|
||||||
|
makeRow(g_tab_page[TAB_COOLANT], F_TEMP_SLOPE);
|
||||||
|
makeRow(g_tab_page[TAB_COOLANT], F_TEMP_OFFSET);
|
||||||
|
makeRow(g_tab_page[TAB_COOLANT], F_TEMP_MIN);
|
||||||
|
makeRow(g_tab_page[TAB_COOLANT], F_TEMP_DUTY_MAX);
|
||||||
|
g_temp_en_sw = makeSwitchRow(g_tab_page[TAB_COOLANT], "Coolant gauge output", "IO8 on Inst. Cluster. Off = no signal",
|
||||||
|
onEnableSwitch, (void *)(uintptr_t)OUT_ENABLE_TEMP);
|
||||||
|
|
||||||
// ---- column 1: tach + alerts ----
|
// ---- Alerts ----
|
||||||
lv_obj_t *c1 = lv_obj_create(cols);
|
makeRow(g_tab_page[TAB_ALERTS], F_COOLANT_HOT);
|
||||||
lv_obj_remove_style_all(c1);
|
makeRow(g_tab_page[TAB_ALERTS], F_GEARBOX_HOT);
|
||||||
lv_obj_set_size(c1, W, LV_SIZE_CONTENT);
|
makeRow(g_tab_page[TAB_ALERTS], F_BATT_LOW);
|
||||||
lv_obj_set_flex_flow(c1, LV_FLEX_FLOW_COLUMN);
|
|
||||||
lv_obj_set_style_pad_row(c1, 12, 0);
|
|
||||||
lv_obj_clear_flag(c1, LV_OBJ_FLAG_SCROLLABLE);
|
|
||||||
|
|
||||||
lv_obj_t *tach = makePanel(c1, "TACHOMETER(IO7)", W);
|
// ---- Simulation ----
|
||||||
makeRow(tach, F_TACH_PPR);
|
lv_obj_t *sim = g_tab_page[TAB_SIM];
|
||||||
makeRow(tach, F_TACH_TRIM);
|
lv_obj_set_style_pad_row(sim, 14, 0);
|
||||||
makeRow(tach, F_TACH_MAX_HZ);
|
lv_obj_t *intro = label(sim,
|
||||||
g_tach_en_sw = makeSwitchRow(tach, "Output enabled", onEnableSwitch, (void *)(uintptr_t)OUT_ENABLE_TACH);
|
"Forces fixed values on the gauge outputs so the needles can be calibrated "
|
||||||
|
"against the cluster. Switch off when done.",
|
||||||
|
&lv_font_montserrat_20, UI_COL_MUTED);
|
||||||
|
lv_label_set_long_mode(intro, LV_LABEL_LONG_WRAP);
|
||||||
|
lv_obj_set_width(intro, LV_PCT(100));
|
||||||
|
g_ovr_rpm_sl = makeSimCard(sim, "Force tachometer", RPM_MAX, &g_ovr_rpm_sw, &g_ovr_rpm_lbl);
|
||||||
|
g_ovr_duty_sl = makeSimCard(sim, "Force coolant gauge", DUTY_MAX, &g_ovr_duty_sw, &g_ovr_duty_lbl);
|
||||||
|
|
||||||
lv_obj_t *alerts = makePanel(c1, "ALERT THRESHOLDS", W);
|
g_save_lbl = label(g_screen, "", &lv_font_montserrat_20, UI_COL_MUTED);
|
||||||
makeRow(alerts, F_COOLANT_HOT);
|
lv_obj_align(g_save_lbl, LV_ALIGN_BOTTOM_LEFT, 24, -8);
|
||||||
makeRow(alerts, F_GEARBOX_HOT);
|
|
||||||
makeRow(alerts, F_BATT_LOW);
|
|
||||||
|
|
||||||
// ---- column 2: coolant gauge ----
|
|
||||||
lv_obj_t *temp = makePanel(cols, "COOLANT GAUGE(IO8)", W);
|
|
||||||
makeRow(temp, F_TEMP_HZ);
|
|
||||||
makeRow(temp, F_TEMP_SLOPE);
|
|
||||||
makeRow(temp, F_TEMP_OFFSET);
|
|
||||||
makeRow(temp, F_TEMP_MIN);
|
|
||||||
makeRow(temp, F_TEMP_DUTY_MAX);
|
|
||||||
g_temp_en_sw = makeSwitchRow(temp, "Output enabled", onEnableSwitch, (void *)(uintptr_t)OUT_ENABLE_TEMP);
|
|
||||||
|
|
||||||
// lv_obj_t* note = lv_label_create(temp);
|
|
||||||
// lv_label_set_text(note, "duty = slope x T + offset\n(defaults: 1.5 x T + 50, from the\nCANNY program)");
|
|
||||||
// lv_obj_set_style_text_font(note, &lv_font_montserrat_14, 0);
|
|
||||||
// lv_obj_set_style_text_color(note, COL_MUTED, 0);
|
|
||||||
|
|
||||||
// ---- column 3: calibration override ----
|
|
||||||
lv_obj_t *ovr = makePanel(cols, "SIMULATION", 300);
|
|
||||||
g_ovr_rpm_sw = makeSwitchRow(ovr, "Force tach rpm", onOverrideSwitch, NULL);
|
|
||||||
g_ovr_rpm_sl = makeSliderRow(ovr, "RPM", 6000, &g_ovr_rpm_lbl);
|
|
||||||
g_ovr_duty_sw = makeSwitchRow(ovr, "Force coolant duty", onOverrideSwitch, NULL);
|
|
||||||
g_ovr_duty_sl = makeSliderRow(ovr, "Duty", 255, &g_ovr_duty_lbl);
|
|
||||||
|
|
||||||
// lv_obj_t* howto = lv_label_create(ovr);
|
|
||||||
// lv_label_set_text(howto,
|
|
||||||
// "Tach: force 1000 rpm, fix Pulses/rev until\n"
|
|
||||||
// "the needle reads 1000; force 3000, fix Trim.\n"
|
|
||||||
// "Temp: force a duty, note the needle, repeat;\n"
|
|
||||||
// "derive Slope/Offset from two marks.\n"
|
|
||||||
// "Switch overrides OFF when done.");
|
|
||||||
// lv_obj_set_style_text_font(howto, &lv_font_montserrat_14, 0);
|
|
||||||
// lv_obj_set_style_text_color(howto, COL_MUTED, 0);
|
|
||||||
|
|
||||||
// lv_obj_t *hint = lv_label_create(g_screen);
|
|
||||||
// lv_label_set_text(hint, LV_SYMBOL_LEFT " swipe left: back to Driveline");
|
|
||||||
// lv_obj_set_style_text_font(hint, &lv_font_montserrat_14, 0);
|
|
||||||
// lv_obj_set_style_text_color(hint, COL_MUTED, 0);
|
|
||||||
// lv_obj_align(hint, LV_ALIGN_BOTTOM_RIGHT, -24, -10);
|
|
||||||
|
|
||||||
g_status_lbl = lv_label_create(g_screen);
|
|
||||||
lv_label_set_text(g_status_lbl, "config v-");
|
|
||||||
lv_obj_set_style_text_font(g_status_lbl, &lv_font_montserrat_14, 0);
|
|
||||||
lv_obj_set_style_text_color(g_status_lbl, COL_MUTED, 0);
|
|
||||||
lv_obj_align(g_status_lbl, LV_ALIGN_BOTTOM_RIGHT, -24, -10);
|
|
||||||
|
|
||||||
|
selectTab(TAB_TACH);
|
||||||
ESP_LOGI("Tuning", "Gauge tuning screen built");
|
ESP_LOGI("Tuning", "Gauge tuning screen built");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -585,7 +566,7 @@ namespace TuningScreen
|
|||||||
{
|
{
|
||||||
build();
|
build();
|
||||||
refreshFromTunables();
|
refreshFromTunables();
|
||||||
lv_scr_load_anim(g_screen, LV_SCR_LOAD_ANIM_NONE, 0, 0, false); // instant: fades stutter at 1024x600
|
lv_scr_load_anim(g_screen, LV_SCR_LOAD_ANIM_NONE, 0, 0, false); // instant: fades stutter at 1024x600
|
||||||
}
|
}
|
||||||
|
|
||||||
void tick()
|
void tick()
|
||||||
@@ -596,10 +577,11 @@ namespace TuningScreen
|
|||||||
if (millis() - last < 500)
|
if (millis() - last < 500)
|
||||||
return;
|
return;
|
||||||
last = millis();
|
last = millis();
|
||||||
if (Tunables::version() == g_shown_version)
|
|
||||||
return; // nothing changed elsewhere
|
|
||||||
lvgl_port_lock(-1);
|
lvgl_port_lock(-1);
|
||||||
refreshFromTunables();
|
if (Tunables::version() != g_shown_version)
|
||||||
|
refreshFromTunables(); // changed from the console
|
||||||
|
else
|
||||||
|
refreshSaveState(); // "Saving..." -> "saved" after the deferred write
|
||||||
lvgl_port_unlock();
|
lvgl_port_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,11 +6,12 @@
|
|||||||
* bench override (force an rpm / a duty) so the needles can be calibrated
|
* bench override (force an rpm / a duty) so the needles can be calibrated
|
||||||
* from the touchscreen while watching the cluster.
|
* from the touchscreen while watching the cluster.
|
||||||
*
|
*
|
||||||
* Lives in src/ (never touched by SquareLine exports), like DrivelineScreen.
|
* Four tabs: Tachometer / Coolant gauge / Alerts / Simulation.
|
||||||
* Reached by swiping RIGHT on the Driveline screen; the Driveline button (top
|
* Reached by swiping RIGHT on the Driveline screen; swipe left or the Driveline
|
||||||
* right) goes back. No swipe gesture on this screen (it would fight the sliders).
|
* button (top right) goes back. The Simulation sliders don't bubble gestures,
|
||||||
|
* so dragging them never changes screens.
|
||||||
* Every change goes through Tunables, so it is saved to NVS (overrides
|
* Every change goes through Tunables, so it is saved to NVS (overrides
|
||||||
* excepted) and pushed to Controller B in the next CONFIG frame.
|
* excepted) and pushed to Inst. Cluster in the next CONFIG frame.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Builds the v2 frames (DATA at 5 Hz, CONFIG on change + every CONFIG_RESEND_MS)
|
* Builds the v2 frames (DATA at 5 Hz, CONFIG on change + every CONFIG_RESEND_MS)
|
||||||
* and sends each one on BOTH transports: UART1 (GPIO 44 -> SP3485 -> 485_A/B)
|
* and sends each one on BOTH transports: UART1 (GPIO 44 -> SP3485 -> 485_A/B)
|
||||||
* and ESP-NOW broadcast. Controller B dedupes on packet_id.
|
* and ESP-NOW broadcast. Inst. Cluster dedupes on packet_id.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "uart_manager.h"
|
#include "uart_manager.h"
|
||||||
@@ -43,36 +43,24 @@ static uart_stats_t g_uart_stats = {0};
|
|||||||
// CONFIG frame scheduling
|
// CONFIG frame scheduling
|
||||||
static uint8_t g_last_cfg_version_sent = 0;
|
static uint8_t g_last_cfg_version_sent = 0;
|
||||||
static uint32_t g_last_cfg_send_time = 0;
|
static uint32_t g_last_cfg_send_time = 0;
|
||||||
|
static volatile bool g_port_ready = false; // Serial1.begin() done (in the task)
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// PRIVATE HELPER FUNCTIONS
|
// PRIVATE HELPER FUNCTIONS
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Seed the shared structure until CAN data arrives.
|
* @brief Start from NOTHING valid. Until a CAN frame fills a field, its valid
|
||||||
* @note The temperatures/voltage are marked valid so a bench without CAN still
|
* flag stays clear and B shows no value for it (user decision
|
||||||
* exercises B's display. RPM and gear nibbles are NOT marked valid: the
|
* 2026-09-28: no invented numbers, ever - the old bench defaults of
|
||||||
* tach output must never run on invented data.
|
* 89 / 85 degC and 12.45 V looked like real readings).
|
||||||
*/
|
*/
|
||||||
static void initializeDefaultData() {
|
static void initializeDefaultData() {
|
||||||
if (xSemaphoreTake(g_data_mutex, pdMS_TO_TICKS(100)) == pdTRUE) {
|
if (xSemaphoreTake(g_data_mutex, pdMS_TO_TICKS(100)) == pdTRUE) {
|
||||||
g_automotive_data.gear_lever = DEFAULT_GEAR_LEVER;
|
uint8_t dbg = g_automotive_data.debug_enabled;
|
||||||
g_automotive_data.gear_nibbles = 0;
|
memset(&g_automotive_data, 0, sizeof(g_automotive_data));
|
||||||
g_automotive_data.engine_rpm = 0;
|
g_automotive_data.gear_lever = LEVER_UNKNOWN;
|
||||||
g_automotive_data.gearbox_oil_temp = DEFAULT_GEARBOX_TEMP;
|
g_automotive_data.debug_enabled = dbg;
|
||||||
g_automotive_data.engine_oil_temp = DEFAULT_ENGINE_OIL_TEMP;
|
|
||||||
g_automotive_data.coolant_temp = DEFAULT_COOLANT_TEMP;
|
|
||||||
g_automotive_data.battery_voltage = DEFAULT_BATTERY_VOLTAGE;
|
|
||||||
g_automotive_data.alerts = DEFAULT_ALERTS;
|
|
||||||
|
|
||||||
g_automotive_data.valid_flags = VALID_FLAG_GEAR_POS |
|
|
||||||
VALID_FLAG_GEARBOX_TEMP |
|
|
||||||
VALID_FLAG_ENGINE_TEMP |
|
|
||||||
VALID_FLAG_COOLANT_TEMP |
|
|
||||||
VALID_FLAG_BATTERY_VOLT |
|
|
||||||
VALID_FLAG_ALERTS;
|
|
||||||
|
|
||||||
g_automotive_data.debug_enabled = 0;
|
|
||||||
xSemaphoreGive(g_data_mutex);
|
xSemaphoreGive(g_data_mutex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -173,6 +161,7 @@ static void uartTask(void* parameter) {
|
|||||||
|
|
||||||
Serial1.setRxBufferSize(256);
|
Serial1.setRxBufferSize(256);
|
||||||
Serial1.begin(UART_BAUD_RATE, SERIAL_8N1, UART_RX_PIN, UART_TX_PIN);
|
Serial1.begin(UART_BAUD_RATE, SERIAL_8N1, UART_RX_PIN, UART_TX_PIN);
|
||||||
|
g_port_ready = true;
|
||||||
ESP_LOGI("UARTTask", "UART1 initialized: %d baud, TX=GPIO%d (RS485 A/B), protocol v%u",
|
ESP_LOGI("UARTTask", "UART1 initialized: %d baud, TX=GPIO%d (RS485 A/B), protocol v%u",
|
||||||
UART_BAUD_RATE, UART_TX_PIN, PACKET_VERSION);
|
UART_BAUD_RATE, UART_TX_PIN, PACKET_VERSION);
|
||||||
|
|
||||||
@@ -302,7 +291,7 @@ void setDebugEnabled(bool enabled) {
|
|||||||
if (xSemaphoreTake(g_data_mutex, pdMS_TO_TICKS(100)) == pdTRUE) {
|
if (xSemaphoreTake(g_data_mutex, pdMS_TO_TICKS(100)) == pdTRUE) {
|
||||||
g_automotive_data.debug_enabled = enabled ? 1 : 0;
|
g_automotive_data.debug_enabled = enabled ? 1 : 0;
|
||||||
xSemaphoreGive(g_data_mutex);
|
xSemaphoreGive(g_data_mutex);
|
||||||
ESP_LOGI("UARTMgr", "Debug flag set to %s (will be transmitted to Controller B)",
|
ESP_LOGI("UARTMgr", "Debug flag set to %s (will be transmitted to Inst. Cluster)",
|
||||||
enabled ? "ENABLED" : "DISABLED");
|
enabled ? "ENABLED" : "DISABLED");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -323,15 +312,8 @@ void linkToCANState(bool can_active) {
|
|||||||
// EVENT HANDLERS
|
// EVENT HANDLERS
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
void onUARTToggle(lv_event_t *e)
|
void setEnabled(bool state)
|
||||||
{
|
{
|
||||||
lv_obj_t *target = lv_event_get_target(e);
|
|
||||||
if (target == NULL) {
|
|
||||||
ESP_LOGE("UARTMgr", "ERROR: UART toggle target is NULL!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool state = lv_obj_has_state(target, LV_STATE_CHECKED);
|
|
||||||
|
|
||||||
ESP_LOGI("UARTMgr", "===== UART Toggle Event =====");
|
ESP_LOGI("UARTMgr", "===== UART Toggle Event =====");
|
||||||
ESP_LOGI("UARTMgr", "UART Toggle State: %s", state ? "ON" : "OFF");
|
ESP_LOGI("UARTMgr", "UART Toggle State: %s", state ? "ON" : "OFF");
|
||||||
@@ -362,4 +344,10 @@ void onUARTToggle(lv_event_t *e)
|
|||||||
ESP_LOGI("UARTMgr", "=============================");
|
ESP_LOGI("UARTMgr", "=============================");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool sendWire(const uint8_t* frame, size_t len) {
|
||||||
|
if (!g_port_ready || len == 0) return false;
|
||||||
|
return Serial1.write(frame, len) == len;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace UARTManager
|
} // namespace UARTManager
|
||||||
|
|
||||||
|
|||||||
@@ -116,15 +116,18 @@ void setDebugEnabled(bool enabled);
|
|||||||
*/
|
*/
|
||||||
void linkToCANState(bool can_active);
|
void linkToCANState(bool can_active);
|
||||||
|
|
||||||
// ============================================================================
|
/**
|
||||||
// EVENT HANDLERS (Called from SquareLine Studio UI)
|
* @brief Settings-screen switch: start/stop sending to Inst. Cluster (UART1 +
|
||||||
// ============================================================================
|
* ESP-NOW) and remember the choice in NVS.
|
||||||
|
*/
|
||||||
|
void setEnabled(bool enabled);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief UART toggle event handler
|
* @brief Send one complete frame on the UART wire ONLY (never ESP-NOW).
|
||||||
* @param e LVGL event object
|
* Used for the PAIR frame, which must not go over the air. One write
|
||||||
* @note This function is registered in SquareLine Studio UI
|
* call, so it cannot interleave with the task's own frames.
|
||||||
|
* @return true if the port is up and every byte was written
|
||||||
*/
|
*/
|
||||||
void onUARTToggle(lv_event_t *e);
|
bool sendWire(const uint8_t* frame, size_t len);
|
||||||
|
|
||||||
} // namespace UARTManager
|
} // namespace UARTManager
|
||||||
|
|||||||
@@ -0,0 +1,178 @@
|
|||||||
|
/*
|
||||||
|
* UI kit implementation - see ui_kit.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ui_kit.h"
|
||||||
|
|
||||||
|
namespace UiKit {
|
||||||
|
|
||||||
|
lv_obj_t* screen() {
|
||||||
|
lv_obj_t* s = lv_obj_create(NULL);
|
||||||
|
lv_obj_set_style_bg_color(s, UI_COL_BG, 0);
|
||||||
|
lv_obj_set_style_bg_opa(s, LV_OPA_COVER, 0);
|
||||||
|
lv_obj_clear_flag(s, LV_OBJ_FLAG_SCROLLABLE);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
void header(lv_obj_t* scr, const char* title, lv_event_cb_t back_cb) {
|
||||||
|
lv_obj_t* t = label(scr, title, &lv_font_montserrat_30, UI_COL_TEXT);
|
||||||
|
lv_obj_align(t, LV_ALIGN_TOP_LEFT, 24, 18);
|
||||||
|
|
||||||
|
// -176: the StatusOverlay Wi-Fi chip owns the last 150 px of the top-right corner
|
||||||
|
lv_obj_t* back = button(scr, LV_SYMBOL_LEFT " Driveline", 200, 56, BTN_SECONDARY, back_cb, NULL);
|
||||||
|
lv_obj_align(back, LV_ALIGN_TOP_RIGHT, -176, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
lv_obj_t* label(lv_obj_t* parent, const char* text, const lv_font_t* font, lv_color_t color) {
|
||||||
|
lv_obj_t* l = lv_label_create(parent);
|
||||||
|
lv_label_set_text(l, text);
|
||||||
|
lv_obj_set_style_text_font(l, font, 0);
|
||||||
|
lv_obj_set_style_text_color(l, color, 0);
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void styleButton(lv_obj_t* b, btn_style_t style) {
|
||||||
|
lv_color_t bg = UI_COL_PANEL2, fg = UI_COL_TEXT;
|
||||||
|
switch (style) {
|
||||||
|
case BTN_PRIMARY: bg = UI_COL_ACCENT; fg = lv_color_hex(0x0B1620); break;
|
||||||
|
case BTN_SECONDARY: bg = UI_COL_PANEL2; fg = UI_COL_TEXT; break;
|
||||||
|
case BTN_DANGER: bg = UI_COL_WARN; fg = UI_COL_TEXT; break;
|
||||||
|
case BTN_SUCCESS: bg = UI_COL_OK; fg = lv_color_hex(0x0B1620); break;
|
||||||
|
}
|
||||||
|
lv_obj_set_style_bg_color(b, bg, 0);
|
||||||
|
lv_obj_set_style_bg_opa(b, LV_OPA_COVER, 0);
|
||||||
|
lv_obj_set_style_text_color(b, fg, 0);
|
||||||
|
lv_obj_set_style_radius(b, 10, 0);
|
||||||
|
lv_obj_set_style_shadow_width(b, 0, 0);
|
||||||
|
lv_obj_set_style_bg_color(b, lv_color_hex(0x3A4450), LV_STATE_DISABLED);
|
||||||
|
lv_obj_set_style_text_color(b, UI_COL_MUTED, LV_STATE_DISABLED);
|
||||||
|
}
|
||||||
|
|
||||||
|
lv_obj_t* button(lv_obj_t* parent, const char* text, lv_coord_t w, lv_coord_t h,
|
||||||
|
btn_style_t style, lv_event_cb_t cb, void* user) {
|
||||||
|
lv_obj_t* b = lv_btn_create(parent);
|
||||||
|
lv_obj_set_size(b, w, h);
|
||||||
|
styleButton(b, style);
|
||||||
|
if (cb) lv_obj_add_event_cb(b, cb, LV_EVENT_CLICKED, user);
|
||||||
|
lv_obj_t* l = lv_label_create(b);
|
||||||
|
lv_label_set_text(l, text);
|
||||||
|
lv_obj_set_style_text_font(l, &lv_font_montserrat_20, 0);
|
||||||
|
lv_obj_center(l);
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setButtonText(lv_obj_t* btn, const char* text) {
|
||||||
|
setText(lv_obj_get_child(btn, 0), text);
|
||||||
|
}
|
||||||
|
|
||||||
|
lv_obj_t* toggle(lv_obj_t* parent, lv_event_cb_t cb, void* user) {
|
||||||
|
lv_obj_t* sw = lv_switch_create(parent);
|
||||||
|
lv_obj_set_size(sw, 92, 48);
|
||||||
|
lv_obj_set_style_bg_color(sw, UI_COL_PANEL2, 0);
|
||||||
|
lv_obj_set_style_bg_color(sw, UI_COL_ACCENT, (lv_style_selector_t)LV_PART_INDICATOR | (lv_style_selector_t)LV_STATE_CHECKED);
|
||||||
|
lv_obj_set_style_anim_time(sw, 0, 0); // no knob slide animation: one redraw per flip
|
||||||
|
if (cb) lv_obj_add_event_cb(sw, cb, LV_EVENT_VALUE_CHANGED, user);
|
||||||
|
return sw;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setChecked(lv_obj_t* obj, bool on) {
|
||||||
|
if (obj == NULL || lv_obj_has_state(obj, LV_STATE_CHECKED) == on) return;
|
||||||
|
if (on) lv_obj_add_state(obj, LV_STATE_CHECKED);
|
||||||
|
else lv_obj_clear_state(obj, LV_STATE_CHECKED);
|
||||||
|
}
|
||||||
|
|
||||||
|
lv_obj_t* box(lv_obj_t* parent, lv_flex_flow_t flow) {
|
||||||
|
lv_obj_t* b = lv_obj_create(parent);
|
||||||
|
lv_obj_remove_style_all(b);
|
||||||
|
lv_obj_set_flex_flow(b, flow);
|
||||||
|
lv_obj_clear_flag(b, LV_OBJ_FLAG_SCROLLABLE);
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
lv_obj_t* card(lv_obj_t* parent) {
|
||||||
|
lv_obj_t* c = lv_obj_create(parent);
|
||||||
|
lv_obj_set_style_bg_color(c, UI_COL_PANEL, 0);
|
||||||
|
lv_obj_set_style_border_width(c, 0, 0);
|
||||||
|
lv_obj_set_style_radius(c, 12, 0);
|
||||||
|
lv_obj_set_style_pad_all(c, 16, 0);
|
||||||
|
lv_obj_set_style_shadow_width(c, 0, 0);
|
||||||
|
lv_obj_clear_flag(c, LV_OBJ_FLAG_SCROLLABLE);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setText(lv_obj_t* lbl, const char* text) {
|
||||||
|
if (lbl == NULL) return;
|
||||||
|
const char* cur = lv_label_get_text(lbl);
|
||||||
|
if (cur && strcmp(cur, text) == 0) return;
|
||||||
|
lv_label_set_text(lbl, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setTextColor(lv_obj_t* lbl, lv_color_t c) {
|
||||||
|
if (lbl == NULL) return;
|
||||||
|
if (lv_obj_get_style_text_color(lbl, LV_PART_MAIN).full == c.full) return;
|
||||||
|
lv_obj_set_style_text_color(lbl, c, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setVisible(lv_obj_t* obj, bool visible) {
|
||||||
|
if (obj == NULL || lv_obj_has_flag(obj, LV_OBJ_FLAG_HIDDEN) == !visible) return;
|
||||||
|
if (visible) lv_obj_clear_flag(obj, LV_OBJ_FLAG_HIDDEN);
|
||||||
|
else lv_obj_add_flag(obj, LV_OBJ_FLAG_HIDDEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- confirm dialog --------------------------------------------------------
|
||||||
|
|
||||||
|
static const char* g_btn_map[3] = {"Cancel", "OK", ""};
|
||||||
|
static char g_ok_text[32];
|
||||||
|
static void (*g_confirm_cb)(bool, void*) = NULL;
|
||||||
|
static void* g_confirm_user = NULL;
|
||||||
|
|
||||||
|
static void onConfirm(lv_event_t* e) {
|
||||||
|
lv_obj_t* mb = lv_event_get_current_target(e);
|
||||||
|
uint16_t id = lv_msgbox_get_active_btn(mb);
|
||||||
|
if (id == LV_BTNMATRIX_BTN_NONE) return;
|
||||||
|
lv_msgbox_close_async(mb);
|
||||||
|
void (*cb)(bool, void*) = g_confirm_cb;
|
||||||
|
g_confirm_cb = NULL;
|
||||||
|
if (cb) cb(id == 1, g_confirm_user);
|
||||||
|
}
|
||||||
|
|
||||||
|
void confirm(const char* title, const char* text, const char* ok_text,
|
||||||
|
void (*cb)(bool ok, void* user), void* user) {
|
||||||
|
snprintf(g_ok_text, sizeof(g_ok_text), "%s", ok_text);
|
||||||
|
g_btn_map[1] = g_ok_text;
|
||||||
|
g_confirm_cb = cb;
|
||||||
|
g_confirm_user = user;
|
||||||
|
|
||||||
|
lv_obj_t* mb = lv_msgbox_create(NULL, title, text, g_btn_map, false);
|
||||||
|
lv_obj_set_width(mb, 640);
|
||||||
|
lv_obj_set_style_bg_color(mb, UI_COL_PANEL, 0);
|
||||||
|
lv_obj_set_style_border_width(mb, 0, 0);
|
||||||
|
lv_obj_set_style_shadow_width(mb, 0, 0);
|
||||||
|
lv_obj_set_style_radius(mb, 14, 0);
|
||||||
|
lv_obj_set_style_pad_all(mb, 24, 0);
|
||||||
|
lv_obj_set_style_pad_row(mb, 16, 0);
|
||||||
|
lv_obj_set_style_text_color(mb, UI_COL_TEXT, 0);
|
||||||
|
lv_obj_set_style_text_font(lv_msgbox_get_title(mb), &lv_font_montserrat_24, 0);
|
||||||
|
lv_obj_set_style_text_font(lv_msgbox_get_text(mb), &lv_font_montserrat_20, 0);
|
||||||
|
|
||||||
|
lv_obj_t* btns = lv_msgbox_get_btns(mb);
|
||||||
|
lv_obj_set_size(btns, LV_PCT(100), 64);
|
||||||
|
lv_obj_set_style_text_font(btns, &lv_font_montserrat_20, 0);
|
||||||
|
lv_obj_set_style_pad_column(btns, 16, 0);
|
||||||
|
lv_obj_set_style_bg_color(btns, UI_COL_PANEL2, LV_PART_ITEMS);
|
||||||
|
lv_obj_set_style_text_color(btns, UI_COL_TEXT, LV_PART_ITEMS);
|
||||||
|
lv_obj_set_style_radius(btns, 10, LV_PART_ITEMS);
|
||||||
|
lv_obj_set_style_shadow_width(btns, 0, LV_PART_ITEMS);
|
||||||
|
lv_btnmatrix_set_btn_ctrl(btns, 1, LV_BTNMATRIX_CTRL_CHECKED); // highlight the action
|
||||||
|
lv_obj_set_style_bg_color(btns, UI_COL_ACCENT, (lv_style_selector_t)LV_PART_ITEMS | (lv_style_selector_t)LV_STATE_CHECKED);
|
||||||
|
lv_obj_set_style_text_color(btns, lv_color_hex(0x0B1620), (lv_style_selector_t)LV_PART_ITEMS | (lv_style_selector_t)LV_STATE_CHECKED);
|
||||||
|
|
||||||
|
lv_obj_t* backdrop = lv_obj_get_parent(mb);
|
||||||
|
lv_obj_set_style_bg_color(backdrop, lv_color_black(), 0);
|
||||||
|
lv_obj_set_style_bg_opa(backdrop, LV_OPA_70, 0);
|
||||||
|
|
||||||
|
lv_obj_center(mb);
|
||||||
|
lv_obj_add_event_cb(mb, onConfirm, LV_EVENT_VALUE_CHANGED, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace UiKit
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* UI kit - shared look for the hand-coded screens (Settings, Gauge Tuning).
|
||||||
|
*
|
||||||
|
* Car-sized touch targets (>= 56 px), 20/24 px body text, no shadows or
|
||||||
|
* animated transitions (every extra redraw of this 1024x600 PSRAM framebuffer
|
||||||
|
* costs frame time). All functions need the LVGL lock, like any LVGL call.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <lvgl.h>
|
||||||
|
|
||||||
|
#define UI_COL_BG lv_color_hex(0x101418)
|
||||||
|
#define UI_COL_PANEL lv_color_hex(0x1B2128)
|
||||||
|
#define UI_COL_PANEL2 lv_color_hex(0x252D36) // pressed / selected rows
|
||||||
|
#define UI_COL_TEXT lv_color_hex(0xE8EDF2)
|
||||||
|
#define UI_COL_MUTED lv_color_hex(0x8894A0)
|
||||||
|
#define UI_COL_ACCENT lv_color_hex(0x3DA9FC)
|
||||||
|
#define UI_COL_OK lv_color_hex(0x3DD68C)
|
||||||
|
#define UI_COL_WARN lv_color_hex(0xE5484D)
|
||||||
|
#define UI_COL_AMBER lv_color_hex(0xF5A524)
|
||||||
|
|
||||||
|
namespace UiKit {
|
||||||
|
|
||||||
|
typedef enum { BTN_PRIMARY, BTN_SECONDARY, BTN_DANGER, BTN_SUCCESS } btn_style_t;
|
||||||
|
|
||||||
|
/** Plain full-screen background object. */
|
||||||
|
lv_obj_t* screen();
|
||||||
|
|
||||||
|
/** Title top-left and a "< Driveline" button top-right that calls back_cb. */
|
||||||
|
void header(lv_obj_t* scr, const char* title, lv_event_cb_t back_cb);
|
||||||
|
|
||||||
|
lv_obj_t* label(lv_obj_t* parent, const char* text, const lv_font_t* font, lv_color_t color);
|
||||||
|
|
||||||
|
/** Button with a centred label; the label is the button's first child. */
|
||||||
|
lv_obj_t* button(lv_obj_t* parent, const char* text, lv_coord_t w, lv_coord_t h,
|
||||||
|
btn_style_t style, lv_event_cb_t cb, void* user);
|
||||||
|
void setButtonText(lv_obj_t* btn, const char* text);
|
||||||
|
|
||||||
|
lv_obj_t* toggle(lv_obj_t* parent, lv_event_cb_t cb, void* user);
|
||||||
|
void setChecked(lv_obj_t* obj, bool on);
|
||||||
|
|
||||||
|
/** Transparent flex row/column container without padding or scrolling. */
|
||||||
|
lv_obj_t* box(lv_obj_t* parent, lv_flex_flow_t flow);
|
||||||
|
|
||||||
|
/** Rounded panel (card). */
|
||||||
|
lv_obj_t* card(lv_obj_t* parent);
|
||||||
|
|
||||||
|
/** lv_label_set_text only when the text changed - avoids needless redraws. */
|
||||||
|
void setText(lv_obj_t* lbl, const char* text);
|
||||||
|
void setTextColor(lv_obj_t* lbl, lv_color_t c);
|
||||||
|
void setVisible(lv_obj_t* obj, bool visible);
|
||||||
|
|
||||||
|
/** Modal Cancel / OK dialog; cb(true, user) on OK, cb(false, user) on Cancel. */
|
||||||
|
void confirm(const char* title, const char* text, const char* ok_text,
|
||||||
|
void (*cb)(bool ok, void* user), void* user);
|
||||||
|
|
||||||
|
} // namespace UiKit
|
||||||
@@ -4,19 +4,7 @@
|
|||||||
|
|
||||||
#include "ui_state_manager.h"
|
#include "ui_state_manager.h"
|
||||||
#include "display/lvgl_v8_port.h"
|
#include "display/lvgl_v8_port.h"
|
||||||
#include "settings_manager.h"
|
|
||||||
#include "wifi_manager.h"
|
|
||||||
#include "uart_manager.h"
|
#include "uart_manager.h"
|
||||||
#include "drivers/can_driver.h"
|
|
||||||
|
|
||||||
// External UI element references (from ui_Settings_Screen.c)
|
|
||||||
extern "C" {
|
|
||||||
extern lv_obj_t *uic_Main_Container;
|
|
||||||
extern lv_obj_t *uic_Toggle_Wifi_Switch;
|
|
||||||
extern lv_obj_t *uic_Toggle_UART_Switch;
|
|
||||||
extern lv_obj_t *uic_Toggle_CAN_Bus_Switch;
|
|
||||||
extern lv_obj_t *uic_Toggle_Debug_Switch;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace UIStateManager {
|
namespace UIStateManager {
|
||||||
|
|
||||||
@@ -24,9 +12,6 @@ namespace UIStateManager {
|
|||||||
// PRIVATE MODULE STATE
|
// PRIVATE MODULE STATE
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
// Track which screen instance we synced (to prevent redundant syncing)
|
|
||||||
static lv_obj_t* g_last_synced_screen = NULL;
|
|
||||||
|
|
||||||
// Debug mode state
|
// Debug mode state
|
||||||
static bool g_debug_enabled = false;
|
static bool g_debug_enabled = false;
|
||||||
|
|
||||||
@@ -36,90 +21,9 @@ static bool g_debug_enabled = false;
|
|||||||
|
|
||||||
void init() {
|
void init() {
|
||||||
Serial.println("[UIStateManager] Initialized");
|
Serial.println("[UIStateManager] Initialized");
|
||||||
g_last_synced_screen = NULL;
|
|
||||||
g_debug_enabled = false;
|
g_debug_enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void applySavedStatesToUI() {
|
|
||||||
// Wait for UI widgets to be created
|
|
||||||
if (uic_Toggle_Wifi_Switch == NULL || uic_Toggle_UART_Switch == NULL || uic_Toggle_CAN_Bus_Switch == NULL) {
|
|
||||||
// Reset last synced screen when widgets are NULL (screen unloaded)
|
|
||||||
g_last_synced_screen = NULL;
|
|
||||||
return; // Settings screen not loaded yet
|
|
||||||
}
|
|
||||||
|
|
||||||
if (uic_Main_Container == NULL) {
|
|
||||||
return; // UI not ready
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the Settings screen pointer (parent of Main Container)
|
|
||||||
lv_obj_t* settings_screen = lv_obj_get_parent(uic_Main_Container);
|
|
||||||
if (settings_screen == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if we've already synced this screen instance
|
|
||||||
if (g_last_synced_screen == settings_screen) {
|
|
||||||
return; // Already synced this instance
|
|
||||||
}
|
|
||||||
|
|
||||||
Serial.println("Settings screen detected - syncing toggle states with services...");
|
|
||||||
|
|
||||||
// Sync UI with the actual running state of services
|
|
||||||
bool current_wifi_state = WiFiManager::getState() != WiFiManager::WIFI_STATE_OFF;
|
|
||||||
bool current_uart_state = UARTManager::getState() != UARTManager::UART_STATE_OFF;
|
|
||||||
bool current_can_state = CANDriver::isActive();
|
|
||||||
bool current_debug_state = g_debug_enabled;
|
|
||||||
|
|
||||||
lvgl_port_lock(-1);
|
|
||||||
|
|
||||||
// The SquareLine project ships the WiFi switch with LV_STATE_DISABLED (since
|
|
||||||
// the first export), which swallows every touch. Wi-Fi is needed to join a
|
|
||||||
// network for OTA updates, so re-enable it here - survives re-exports.
|
|
||||||
lv_obj_clear_state(uic_Toggle_Wifi_Switch, LV_STATE_DISABLED);
|
|
||||||
|
|
||||||
// Apply WiFi state
|
|
||||||
if (current_wifi_state) {
|
|
||||||
lv_obj_add_state(uic_Toggle_Wifi_Switch, LV_STATE_CHECKED);
|
|
||||||
} else {
|
|
||||||
lv_obj_clear_state(uic_Toggle_Wifi_Switch, LV_STATE_CHECKED);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply UART state
|
|
||||||
if (current_uart_state) {
|
|
||||||
lv_obj_add_state(uic_Toggle_UART_Switch, LV_STATE_CHECKED);
|
|
||||||
} else {
|
|
||||||
lv_obj_clear_state(uic_Toggle_UART_Switch, LV_STATE_CHECKED);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply CAN Bus state
|
|
||||||
if (current_can_state) {
|
|
||||||
lv_obj_add_state(uic_Toggle_CAN_Bus_Switch, LV_STATE_CHECKED);
|
|
||||||
} else {
|
|
||||||
lv_obj_clear_state(uic_Toggle_CAN_Bus_Switch, LV_STATE_CHECKED);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply Debug state
|
|
||||||
if (uic_Toggle_Debug_Switch != NULL) {
|
|
||||||
if (current_debug_state) {
|
|
||||||
lv_obj_add_state(uic_Toggle_Debug_Switch, LV_STATE_CHECKED);
|
|
||||||
} else {
|
|
||||||
lv_obj_clear_state(uic_Toggle_Debug_Switch, LV_STATE_CHECKED);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lvgl_port_unlock();
|
|
||||||
|
|
||||||
// Mark this screen instance as synced
|
|
||||||
g_last_synced_screen = settings_screen;
|
|
||||||
|
|
||||||
Serial.printf("Toggle states synced: WiFi=%s, UART=%s, CAN=%s, Debug=%s\n",
|
|
||||||
current_wifi_state ? "ON" : "OFF",
|
|
||||||
current_uart_state ? "ON" : "OFF",
|
|
||||||
current_can_state ? "ON" : "OFF",
|
|
||||||
current_debug_state ? "ON" : "OFF");
|
|
||||||
}
|
|
||||||
|
|
||||||
void setDebugEnabled(bool enabled) {
|
void setDebugEnabled(bool enabled) {
|
||||||
g_debug_enabled = enabled;
|
g_debug_enabled = enabled;
|
||||||
|
|
||||||
@@ -154,31 +58,4 @@ bool isDebugEnabled() {
|
|||||||
return g_debug_enabled;
|
return g_debug_enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// EVENT HANDLERS
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
void onDebugToggle(lv_event_t *e)
|
|
||||||
{
|
|
||||||
lv_obj_t *target = lv_event_get_target(e);
|
|
||||||
|
|
||||||
if (target == NULL) {
|
|
||||||
Serial.println("ERROR: Debug toggle target is NULL!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool state = lv_obj_has_state(target, LV_STATE_CHECKED);
|
|
||||||
|
|
||||||
Serial.printf("===== Debug Toggle Event =====\n");
|
|
||||||
Serial.printf("Debug Mode: %s\n", state ? "ON" : "OFF");
|
|
||||||
|
|
||||||
// Save state to NVS
|
|
||||||
SettingsManager::saveDebugState(state);
|
|
||||||
|
|
||||||
// Update global state and enable/disable monitors
|
|
||||||
setDebugEnabled(state);
|
|
||||||
|
|
||||||
Serial.printf("==============================\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace UIStateManager
|
} // namespace UIStateManager
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* UI State Manager Module
|
* UI State Manager Module
|
||||||
*
|
*
|
||||||
* Handles UI state synchronization:
|
* Holds the debug flag (sent to Inst. Cluster, shows LVGL's performance overlay).
|
||||||
* - Syncs toggle switches with actual service states when screens change
|
|
||||||
* - Handles SquareLine Studio screen lifecycle (destroy/recreate)
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@@ -25,18 +23,6 @@ namespace UIStateManager {
|
|||||||
*/
|
*/
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Apply saved states to UI switches
|
|
||||||
*
|
|
||||||
* This function is called continuously in loop() to sync UI toggle switches
|
|
||||||
* with the actual running state of services when the Settings screen loads.
|
|
||||||
* It handles the SquareLine Studio screen lifecycle where screens get
|
|
||||||
* destroyed/recreated when swiping between screens.
|
|
||||||
*
|
|
||||||
* @note This function is thread-safe and uses LVGL locks internally
|
|
||||||
*/
|
|
||||||
void applySavedStatesToUI();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Enable or disable debug mode (LVGL performance and memory monitors)
|
* @brief Enable or disable debug mode (LVGL performance and memory monitors)
|
||||||
* @param enabled True to enable debug monitors, false to disable
|
* @param enabled True to enable debug monitors, false to disable
|
||||||
@@ -49,15 +35,4 @@ void setDebugEnabled(bool enabled);
|
|||||||
*/
|
*/
|
||||||
bool isDebugEnabled();
|
bool isDebugEnabled();
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// EVENT HANDLERS (Called from SquareLine Studio UI)
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Debug toggle event handler
|
|
||||||
* @param e LVGL event object
|
|
||||||
* @note This function is registered in SquareLine Studio UI
|
|
||||||
*/
|
|
||||||
void onDebugToggle(lv_event_t *e);
|
|
||||||
|
|
||||||
} // namespace UIStateManager
|
} // namespace UIStateManager
|
||||||
|
|||||||
+457
-714
File diff suppressed because it is too large
Load Diff
+58
-126
@@ -1,160 +1,92 @@
|
|||||||
/*
|
/*
|
||||||
* WiFi Manager Module
|
* WiFi Manager Module
|
||||||
*
|
*
|
||||||
* Handles WiFi functionality for the Waveshare ESP32-S3-Touch-LCD-5B:
|
* Joins one remembered network (for OTA updates) and scans on request. Owns no
|
||||||
* - WiFi scanning and network discovery
|
* LVGL objects: the Settings screen polls getStatus()/getNetworks() and calls
|
||||||
* - Connection management with password entry
|
* the request functions, so screen lifetimes can never leave dangling pointers
|
||||||
* - Dynamic SSID button generation
|
* here.
|
||||||
* - FreeRTOS task on Core 0 for async WiFi operations
|
*
|
||||||
* - Thread-safe UI updates via LVGL lock
|
* Radio rules (the ESP-NOW link to Inst. Cluster shares the radio):
|
||||||
* - Auto-restore WiFi state from NVS
|
* - the radio stays in STA mode forever; "off" only stops association/scans.
|
||||||
|
* Never WiFi.disconnect(true) / WiFi.mode(WIFI_OFF) - that kills ESP-NOW.
|
||||||
|
* - scans only when asked (each one hops every channel);
|
||||||
|
* - no endless auto-reconnect: one attempt at boot, one after a drop, then
|
||||||
|
* idle on ESPNOW_CHANNEL until the user asks again.
|
||||||
|
*
|
||||||
|
* The network is remembered in NVS (namespace "wifi") after a successful join.
|
||||||
|
* The password is never printed.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include <lvgl.h>
|
|
||||||
#include <freertos/FreeRTOS.h>
|
|
||||||
#include <freertos/task.h>
|
|
||||||
#include <freertos/queue.h>
|
|
||||||
|
|
||||||
namespace WiFiManager {
|
namespace WiFiManager {
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// CONFIGURATION
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
#define WIFI_SCAN_MAX_NETWORKS 20
|
#define WIFI_SCAN_MAX_NETWORKS 20
|
||||||
#define WIFI_SCAN_INTERVAL_MS 10000 // Rescan every 10 seconds when WiFi is ON
|
#define WIFI_CONNECT_TIMEOUT_MS 15000
|
||||||
#define WIFI_TASK_STACK_SIZE 4096
|
#define WIFI_TASK_STACK_SIZE 4096
|
||||||
#define WIFI_TASK_PRIORITY 1
|
#define WIFI_TASK_PRIORITY 1
|
||||||
#define WIFI_TASK_CORE 0 // Run WiFi task on Core 0 (LVGL runs on Core 1)
|
#define WIFI_TASK_CORE 0
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// PUBLIC TYPES
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief WiFi state machine states
|
|
||||||
*/
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
WIFI_STATE_OFF = 0,
|
LINK_OFF = 0, // Wi-Fi switched off
|
||||||
WIFI_STATE_SCANNING,
|
LINK_IDLE, // on, not connected, not trying
|
||||||
WIFI_STATE_SCAN_COMPLETE,
|
LINK_CONNECTING,
|
||||||
WIFI_STATE_CONNECTED,
|
LINK_CONNECTED,
|
||||||
WIFI_STATE_CONNECTING,
|
LINK_FAILED // last attempt failed; see status_t::error
|
||||||
WIFI_STATE_ERROR
|
} link_t;
|
||||||
} wifi_state_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief WiFi scan result structure
|
|
||||||
*/
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
String ssid;
|
link_t link;
|
||||||
int32_t rssi;
|
char ssid[33]; // network being joined / joined / that failed
|
||||||
wifi_auth_mode_t auth;
|
char ip[16];
|
||||||
} wifi_network_t;
|
int rssi; // dBm, when connected
|
||||||
|
char error[48]; // human-readable reason when LINK_FAILED
|
||||||
|
char saved_ssid[33]; // remembered network ("" = none)
|
||||||
|
bool scanning;
|
||||||
|
uint32_t scan_gen; // bumps each time a scan completes
|
||||||
|
} status_t;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief WiFi connection credentials
|
|
||||||
*/
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char ssid[32];
|
char ssid[33];
|
||||||
char password[64];
|
int8_t rssi;
|
||||||
} wifi_credentials_t;
|
bool secured;
|
||||||
|
} network_t;
|
||||||
|
|
||||||
/**
|
/** Start the Wi-Fi task. If enabled and a network is saved, joins it. */
|
||||||
* @brief WiFi event types for FreeRTOS queue
|
void init(bool enabled);
|
||||||
*/
|
|
||||||
typedef enum {
|
|
||||||
WIFI_UI_EVENT_TOGGLE_ON,
|
|
||||||
WIFI_UI_EVENT_TOGGLE_OFF,
|
|
||||||
WIFI_UI_EVENT_SCAN_START,
|
|
||||||
WIFI_UI_EVENT_SCAN_DONE,
|
|
||||||
WIFI_UI_EVENT_UPDATE_UI,
|
|
||||||
WIFI_UI_EVENT_CONNECT,
|
|
||||||
WIFI_UI_EVENT_DISCONNECT
|
|
||||||
} wifi_ui_event_type_t;
|
|
||||||
|
|
||||||
/**
|
/** Wi-Fi switch: persisted. On joins the saved network; off disconnects. */
|
||||||
* @brief WiFi queue event structure
|
void setEnabled(bool on);
|
||||||
*/
|
bool isEnabled();
|
||||||
typedef struct {
|
|
||||||
wifi_ui_event_type_t type;
|
|
||||||
void* data;
|
|
||||||
} wifi_queue_event_t;
|
|
||||||
|
|
||||||
// ============================================================================
|
/** Scan once (ignored while off or already scanning). */
|
||||||
// PUBLIC API
|
void requestScan();
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
/**
|
/** Join a network; remembered if it works. pass may be NULL/"" for open networks. */
|
||||||
* @brief Initialize the WiFi manager subsystem
|
void connect(const char* ssid, const char* pass);
|
||||||
*
|
|
||||||
* This function:
|
|
||||||
* - Creates FreeRTOS mutex and queue
|
|
||||||
* - Spawns WiFi task on Core 0
|
|
||||||
* - Optionally auto-starts WiFi based on saved state
|
|
||||||
*
|
|
||||||
* @param auto_start If true, automatically start WiFi based on NVS saved state
|
|
||||||
*/
|
|
||||||
void init(bool auto_start);
|
|
||||||
|
|
||||||
/**
|
/** Join the remembered network again. */
|
||||||
* @brief Get current WiFi state
|
void connectSaved();
|
||||||
* @return Current wifi_state_t value
|
|
||||||
*/
|
|
||||||
wifi_state_t getState();
|
|
||||||
|
|
||||||
/**
|
/** Drop the remembered network and disconnect. */
|
||||||
* @brief Get WiFi network count from last scan
|
void forget();
|
||||||
* @return Number of networks found
|
|
||||||
*/
|
|
||||||
uint8_t getNetworkCount();
|
|
||||||
|
|
||||||
/**
|
status_t getStatus();
|
||||||
* @brief Console handler for `wifi status | join <ssid> [pass] | off`.
|
|
||||||
* @return false if the line isn't a wifi command
|
/** Copy of the last scan (strongest first, one row per SSID). Returns the count. */
|
||||||
*/
|
uint8_t getNetworks(network_t* out, uint8_t max);
|
||||||
|
|
||||||
|
/** Console: `wifi status | join <ssid> [pass] | forget | on | off`. */
|
||||||
bool handleCommand(const char* line);
|
bool handleCommand(const char* line);
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// EVENT HANDLERS (Called from SquareLine Studio UI)
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief WiFi toggle event handler
|
* The remembered network, password included - for LinkPeer, which hands it to
|
||||||
* @param e LVGL event object
|
* Inst. Cluster inside an encrypted frame. Never print the password.
|
||||||
* @note This function is registered in SquareLine Studio UI
|
* @return false if no network is saved
|
||||||
*/
|
*/
|
||||||
void onWifiToggle(lv_event_t *e);
|
bool getSavedCredentials(char* ssid, size_t ssid_n, char* pass, size_t pass_n);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief SSID button click handler
|
|
||||||
* @param e LVGL event object
|
|
||||||
* @note Shows password entry for secured networks
|
|
||||||
*/
|
|
||||||
void onSSIDButtonClick(lv_event_t *e);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Keyboard event handler for password entry
|
|
||||||
* @param e LVGL event object
|
|
||||||
* @note Handles READY (connect) and CANCEL events
|
|
||||||
*/
|
|
||||||
void onKeyboardEvent(lv_event_t *e);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Manual rescan request handler
|
|
||||||
* @param e LVGL event object
|
|
||||||
*/
|
|
||||||
void onRescanRequest(lv_event_t *e);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Legacy SquareLine Studio compatibility function
|
|
||||||
* @param e LVGL event object
|
|
||||||
* @note Kept for compatibility, but dynamic buttons handle clicks now
|
|
||||||
*/
|
|
||||||
void onSelectSSID(lv_event_t *e);
|
|
||||||
|
|
||||||
} // namespace WiFiManager
|
} // namespace WiFiManager
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
"""Run the Route A OBD-II diag probe sequence on Controller A and log everything.
|
"""Run the Route A OBD-II diag probe sequence on Main CTRL and log everything.
|
||||||
|
|
||||||
Opens the port once (one reboot), waits for boot, then sends each diag command
|
Opens the port once (one reboot), waits for boot, then sends each diag command
|
||||||
with a generous wait, echoing replies and saving the full console stream
|
with a generous wait, echoing replies and saving the full console stream
|
||||||
|
|||||||
@@ -0,0 +1,103 @@
|
|||||||
|
"""Display-performance session: stream PERF lines from Main CTRL to a log
|
||||||
|
while you provoke symptoms on the touchscreen (wiki open question #13).
|
||||||
|
|
||||||
|
Opens the port WITHOUT resetting the board (DTR/RTS low), turns on `perf on 1`,
|
||||||
|
then logs everything to wiki/raw/perf-<timestamp>.log until Ctrl+C. PERF lines
|
||||||
|
are echoed to the terminal. Anything you type is sent to the console, except
|
||||||
|
lines starting with '#', which are written into the log as markers - use them
|
||||||
|
to timestamp what you did on the screen:
|
||||||
|
|
||||||
|
# opened wifi page, scan running - dots visible
|
||||||
|
# tuning save
|
||||||
|
# ota install started
|
||||||
|
|
||||||
|
Usage: python tools/perf_session.py COM14 [period_seconds]
|
||||||
|
"""
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import threading
|
||||||
|
import time
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
import serial
|
||||||
|
|
||||||
|
port = sys.argv[1] if len(sys.argv) > 1 else "COM14"
|
||||||
|
period = sys.argv[2] if len(sys.argv) > 2 else "1"
|
||||||
|
|
||||||
|
out_dir = os.path.join("wiki", "raw")
|
||||||
|
os.makedirs(out_dir, exist_ok=True)
|
||||||
|
path = os.path.join(out_dir, f"perf-{datetime.now():%Y%m%d-%H%M%S}.log")
|
||||||
|
|
||||||
|
s = serial.Serial()
|
||||||
|
s.port = port
|
||||||
|
s.baudrate = 115200
|
||||||
|
s.timeout = 0.2
|
||||||
|
s.dtr = False
|
||||||
|
s.rts = False
|
||||||
|
s.open()
|
||||||
|
|
||||||
|
stop = threading.Event()
|
||||||
|
lock = threading.Lock()
|
||||||
|
log = open(path, "w", encoding="utf-8", newline="\n")
|
||||||
|
|
||||||
|
|
||||||
|
def stamp():
|
||||||
|
return datetime.now().strftime("%H:%M:%S.%f")[:-3]
|
||||||
|
|
||||||
|
|
||||||
|
def write_log(line):
|
||||||
|
with lock:
|
||||||
|
log.write(f"{stamp()} {line}\n")
|
||||||
|
log.flush()
|
||||||
|
|
||||||
|
|
||||||
|
def reader():
|
||||||
|
while not stop.is_set():
|
||||||
|
raw = s.readline()
|
||||||
|
if not raw:
|
||||||
|
continue
|
||||||
|
line = raw.decode("utf-8", "replace").rstrip("\r\n")
|
||||||
|
write_log(line)
|
||||||
|
if line.startswith("PERF,") or "[perf]" in line or "[ota]" in line or "[wifi]" in line:
|
||||||
|
print(line)
|
||||||
|
|
||||||
|
|
||||||
|
def send(cmd):
|
||||||
|
write_log(f">>> {cmd}")
|
||||||
|
s.write((cmd + "\n").encode())
|
||||||
|
s.flush()
|
||||||
|
|
||||||
|
|
||||||
|
t = threading.Thread(target=reader, daemon=True)
|
||||||
|
t.start()
|
||||||
|
time.sleep(0.5)
|
||||||
|
send(f"perf on {period}")
|
||||||
|
print(f"logging to {path} (type console commands, '# note' for a marker, Ctrl+C to stop)")
|
||||||
|
print("columns: ts,fps,avg_ms,max_ms,kpx/frame,flush_ms/s,lvgl_idle%,idle0%,idle1%,int_free,int_largest,psram_free")
|
||||||
|
|
||||||
|
try:
|
||||||
|
while True:
|
||||||
|
line = sys.stdin.readline()
|
||||||
|
if not line:
|
||||||
|
time.sleep(0.2)
|
||||||
|
continue
|
||||||
|
line = line.rstrip("\r\n")
|
||||||
|
if not line:
|
||||||
|
continue
|
||||||
|
if line.startswith("#"):
|
||||||
|
write_log(f"### {line[1:].strip()}")
|
||||||
|
print(f"marker: {line[1:].strip()}")
|
||||||
|
else:
|
||||||
|
send(line)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
pass
|
||||||
|
finally:
|
||||||
|
try:
|
||||||
|
send("perf off")
|
||||||
|
time.sleep(0.3)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
stop.set()
|
||||||
|
s.close()
|
||||||
|
log.close()
|
||||||
|
print(f"\nsaved {path}")
|
||||||
@@ -83,7 +83,7 @@ On BMW PT-CAN (Powertrain CAN) networks, data is divided into two categories: **
|
|||||||
|
|
||||||
1\. Broadcasted Data (Why you see RPM & Temp)
|
1\. Broadcasted Data (Why you see RPM & Temp)
|
||||||
|
|
||||||
The DDE (Engine ECU) continuously loops and broadcasts specific telemetry frames that other modules (like the Instrument Cluster, Transmission Control, and Stability Control) *absolutely need* to function.
|
The DDE (Engine ECU) continuously loops and broadcasts specific telemetry frames that other modules (like the Inst. Cluster, Transmission Control, and Stability Control) *absolutely need* to function.
|
||||||
|
|
||||||
Bimmerforums.com +1
|
Bimmerforums.com +1
|
||||||
|
|
||||||
|
|||||||
+10
-5
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
type: index
|
type: index
|
||||||
updated: 2026-09-26
|
updated: 2026-09-27
|
||||||
---
|
---
|
||||||
|
|
||||||
# Index
|
# Index
|
||||||
@@ -12,21 +12,22 @@ Catalog of every page in the wiki. Read this first when answering questions. Kee
|
|||||||
- [[patrol-instrument-cluster]] — **what the Patrol cluster expects on its inputs**: tach = 2 pulses/rev (verified by calibration), temp = NTC sender 2.1–2.9 kΩ cold → ~250 Ω at 90 °C; the 1 kHz PWM needle-flutter problem and the mitigation ladder (fixed-duty test → 20 kHz → hardware damping)
|
- [[patrol-instrument-cluster]] — **what the Patrol cluster expects on its inputs**: tach = 2 pulses/rev (verified by calibration), temp = NTC sender 2.1–2.9 kΩ cold → ~250 Ω at 90 °C; the 1 kHz PWM needle-flutter problem and the mitigation ladder (fixed-duty test → 20 kHz → hardware damping)
|
||||||
- [[bmw-m57n-engine]] — the 3.0L BMW diesel whose CAN bus we read; E60/E65 donor (confirmed), DDE ECU, auto box with EGS on bus
|
- [[bmw-m57n-engine]] — the 3.0L BMW diesel whose CAN bus we read; E60/E65 donor (confirmed), DDE ECU, auto box with EGS on bus
|
||||||
- [[nissan-patrol-swap]] — the target vehicle: Patrol receiving the M57N + BMW auto; the tapped bus is a BMW island in a Nissan
|
- [[nissan-patrol-swap]] — the target vehicle: Patrol receiving the M57N + BMW auto; the tapped bus is a BMW island in a Nissan
|
||||||
- [[esp32-s3-touch-lcd-5b]] — Waveshare 5" display board (Controller A); onboard TJA1051 CAN transceiver, 7–36 V input, pinout, PSRAM/LCD gotchas
|
- [[esp32-s3-touch-lcd-5b]] — Waveshare 5" display board (Main CTRL); onboard TJA1051 CAN transceiver, 7–36 V input, pinout, PSRAM/LCD gotchas — **flash writes flicker the RGB panel, full-screen fades stutter, internal RAM nearly full, opening the serial port resets the board unless DTR/RTS are low; Wi-Fi scans caused the flickering dots; all screens hand-coded since 2026-09-27**
|
||||||
|
- [[diff-lock-inputs]] — **2026-09-29**: Patrol diff locks (+12 V = locked) on DI0 rear / DI1 front, `DI_COM` to ground; PC814 → CH422G EXIO0/EXIO5 (active low); the bank flip per read is unverified for panel flicker, so it is behind a Settings switch, default OFF
|
||||||
|
|
||||||
## Concepts
|
## Concepts
|
||||||
|
|
||||||
- [[can-bus-integration]] — the core challenge; current firmware ID map flagged as placeholder, verification plan
|
- [[can-bus-integration]] — the core challenge; current firmware ID map flagged as placeholder, verification plan
|
||||||
- [[driveline-speed-signals]] — **engine / turbine / output-shaft speeds**: turbine speed as physical proof of gear engagement, and the output-shaft field that is our **only road-speed source** (no DSC on this bus) — the feedback variable for a future cruise-control PoC, with the safety envelope that would require
|
- [[driveline-speed-signals]] — **engine / turbine / output-shaft speeds**: turbine speed as physical proof of gear engagement, and the output-shaft field that is our **only road-speed source** (no DSC on this bus) — the feedback variable for a future cruise-control PoC, with the safety envelope that would require
|
||||||
- [[dual-controller-architecture]] — Controller A → UART1 + ESP-NOW, protocol v2 → Controller B (1.3" display + Patrol gauge outputs); A owns alerts and the gauge tunables (`cfg` console)
|
- [[dual-controller-architecture]] — Main CTRL → UART1 + ESP-NOW, protocol v2 → Inst. Cluster (1.3" display + Patrol gauge outputs); A owns alerts and the gauge tunables (`cfg` console)
|
||||||
- [[obd-diagnostic-polling]] — **why boost / MAF / rail / injection / DTCs never appear on the sniffer** and how a tester gets them: Route A generic OBD-II mode 01 on `0x7DF` and Route B BMW KWP on `0x6F1` → `0x612` — **BOTH VERIFIED WORKING 2026-09-23** (minimal PID set, no boost PID, mode 09 silent; `1A 86` ident identifies the donor; DTCs read via mode 03), the capture-with-Launch procedure (still wanted for the `22 D1xx` live-data identifiers), and why polling is a transmit-on-the-bus design decision
|
- [[obd-diagnostic-polling]] — **why boost / MAF / rail / injection / DTCs never appear on the sniffer** and how a tester gets them: Route A generic OBD-II mode 01 on `0x7DF` and Route B BMW KWP on `0x6F1` → `0x612` — **BOTH VERIFIED WORKING 2026-09-23** (minimal PID set, no boost PID, mode 09 silent; `1A 86` ident identifies the donor; DTCs read via mode 03), the capture-with-Launch procedure (still wanted for the `22 D1xx` live-data identifiers), and why polling is a transmit-on-the-bus design decision
|
||||||
- [[ota-updates]] — **Controller A updates itself from Gitea releases**: tag `v*` → CI builds + signs (ECDSA P-256) → `ota install` (manual, parked, Wi-Fi) pulls over HTTPS from the public repo, verifies, flashes the idle slot, 30 s confirm-or-rollback; **verified end-to-end 2026-09-26 (dev → v0.1.1)**; dual-slot partition table; plan for updating Controller B through A over ESP-NOW
|
- [[ota-updates]] — **Main CTRL updates itself from Gitea releases**: tag `v*` → CI builds + signs (ECDSA P-256) → Settings → Updates (confirm dialog) or `ota install` (manual, parked, Wi-Fi) pulls over HTTPS from the public repo, verifies, flashes the idle slot, 30 s confirm-or-rollback; **verified end-to-end, from the screen since 2026-09-27 (now v0.1.5)**, release with `git push --follow-tags origin main`; dual-slot partition table; **Inst. Cluster card on the Updates page (2026-09-27)**: B pulls its own release, A pairs over the wire (`link pair`), hands over credentials in encrypted frames and triggers - details in B's wiki `controller-b-ota`
|
||||||
|
|
||||||
## Synthesis
|
## Synthesis
|
||||||
|
|
||||||
- [[canny-5-3-pico-gauge-drive]] — **why the CANNY-based setup moves the Patrol needles and our ESP32 doesn't**: CANNY "negative output" = 12 V-domain low-side switch, ESP32 IO7/IO8 = 3.3 V push-pull; the low-side transistor fix, and why it's not firmware PWM polarity
|
- [[canny-5-3-pico-gauge-drive]] — **why the CANNY-based setup moves the Patrol needles and our ESP32 doesn't**: CANNY "negative output" = 12 V-domain low-side switch, ESP32 IO7/IO8 = 3.3 V push-pull; the low-side transistor fix, and why it's not firmware PWM polarity
|
||||||
- [[can-id-candidates]] — **the E60/E65 CAN ID map — now decoded end-to-end**: gear (lever + engaged + mode), coolant, gearbox temp (raw−40), battery (12-bit ×0.015), RPM, turbine speed, engine state all verified; placeholder IDs verified absent; fault codes and boost not passively broadcast
|
- [[can-id-candidates]] — **the E60/E65 CAN ID map — now decoded end-to-end**: gear (lever + engaged + mode), coolant, gearbox temp (raw−40), battery (12-bit ×0.015), RPM, turbine speed, engine state all verified; placeholder IDs verified absent; fault codes and boost not passively broadcast
|
||||||
- [[open-questions]] — the research frontier: bench-verify the candidate IDs, operating temp, transient protection, fault-code design decision
|
- [[open-questions]] — the research frontier (#14 Wi-Fi UX resolved 2026-09-27): bench-verify the candidate IDs, operating temp, transient protection, fault-code design decision
|
||||||
|
|
||||||
## Sources
|
## Sources
|
||||||
|
|
||||||
@@ -37,6 +38,10 @@ Catalog of every page in the wiki. Read this first when answering questions. Kee
|
|||||||
- [[gear-box-can-revealings]] — **gear fully decoded & VERIFIED** (2026-07-16/17): `0x1D2` byte0 = lever, **byte1 = engaged gear 1–6**, byte4 = Drive/Sport/Manual mode; `0x0BA` = the box's own target gear incl. **reverse**; raw at `raw/gear_box_can_revealings.csv` + `raw/gearbox_engaged_gear.csv`
|
- [[gear-box-can-revealings]] — **gear fully decoded & VERIFIED** (2026-07-16/17): `0x1D2` byte0 = lever, **byte1 = engaged gear 1–6**, byte4 = Drive/Sport/Manual mode; `0x0BA` = the box's own target gear incl. **reverse**; raw at `raw/gear_box_can_revealings.csv` + `raw/gearbox_engaged_gear.csv`
|
||||||
- [[can-capture-2026-07-17-drive]] — **first capture with the vehicle moving** (2026-07-17): verifies `0x0BA` gears 2nd–6th directly (making it a complete gear source), catches the lockup clutch live, and produces the ×0.125 output-shaft scaling evidence; raw at `raw/log_20260717_145930.txt`
|
- [[can-capture-2026-07-17-drive]] — **first capture with the vehicle moving** (2026-07-17): verifies `0x0BA` gears 2nd–6th directly (making it a complete gear source), catches the lockup clutch live, and produces the ×0.125 output-shaft scaling evidence; raw at `raw/log_20260717_145930.txt`
|
||||||
- [[e65-reverse-engineering-repo]] — **E65 per-ID DBC-style docs (ingested 2026-07-17)** — the highest-value source yet: settled the gearbox-temp offset (raw−40) and battery layout (12-bit ×0.015), proved the engine was running in our capture, and revealed turbine speed, output shaft, pedal position and cruise state
|
- [[e65-reverse-engineering-repo]] — **E65 per-ID DBC-style docs (ingested 2026-07-17)** — the highest-value source yet: settled the gearbox-temp offset (raw−40) and battery layout (12-bit ×0.015), proved the engine was running in our capture, and revealed turbine speed, output shaft, pedal position and cruise state
|
||||||
|
- [[perf-xip-ota-2026-09-27]] — **step 3 result**: core rebuilt with XIP-from-PSRAM + IRAM-safe RGB ISR; a full OTA download no longer drops a single panel frame (24/s, 41.5 ms vs 4–8/s, 0.75 s gaps); PSRAM −1.7 MB; dots still to be judged by eye
|
||||||
|
- [[perf-dots-and-ota-2026-09-27]] — **dots are not dropped frames** (panel 24/s, 41.5 ms gap while dots visible → sub-frame DMA glitches, bounce buffers are the fix) and **OTA drops the panel to 4–8 frames/s** (flash writes blank it ~75 % of the download → XIP step needed before any progress bar)
|
||||||
|
- [[perf-baseline-2026-09-27]] — **first display-performance baseline** (`perf` monitor, 2026-09-27): per-screen fps / ms per frame / PSRAM copy load / idle; Driveline's needless 10 Hz redraw, 140–330 ms screen-change frames, Simulation tab as the heaviest load, flash writes invisible to LVGL counters (vsync counter needed), monitor blind during OTA
|
||||||
|
- [[esp32-s3-touch-lcd-5-schematic]] — **the board schematic** (re-downloaded 2026-09-26): VOUT = `I2C_VCC` chosen by solder jumper `H8` (3V3 default / 5V), level-shifted I2C, SY8293 2 A 5 V rail, SD pins, CAN/RS485 GPIOs confirmed
|
||||||
- [[esp32-s3-touch-lcd-5-intro-photo]] — Waveshare annotated board photo (moved into `raw/` 2026-09-21): terminal-block signal order (VIN/GND/VOUT · SDA/SCL · CAN · RS485 A/B · DO0/DO1 · DI), shared CAN/RS485 120 Ω switch, IO0/IO3/IO4/IO46 strapping pads
|
- [[esp32-s3-touch-lcd-5-intro-photo]] — Waveshare annotated board photo (moved into `raw/` 2026-09-21): terminal-block signal order (VIN/GND/VOUT · SDA/SCL · CAN · RS485 A/B · DO0/DO1 · DI), shared CAN/RS485 120 Ω switch, IO0/IO3/IO4/IO46 strapping pads
|
||||||
- [[google-ai-dde7m57-pids]] — Google AI Mode clipping on "dde7m57 pids" (ingested 2026-09-21, raw in `Clippings/`): uncited; its `0x612`-as-request claim is **contradicted**, its D1xx identifiers are `(unverified)`; kept for the Ediabas value names and the user's own observation that `0x612` appears with the Launch connected
|
- [[google-ai-dde7m57-pids]] — Google AI Mode clipping on "dde7m57 pids" (ingested 2026-09-21, raw in `Clippings/`): uncited; its `0x612`-as-request claim is **contradicted**, its D1xx identifiers are `(unverified)`; kept for the Ediabas value names and the user's own observation that `0x612` appears with the Launch connected
|
||||||
- [[diag-route-a-2026-09-23]] — **first live Route A probe run (2026-09-23)**: DDE serves generic OBD mode 01 on `0x7E8` (verified: rpm + coolant cross-checked against the broadcast IDs); supported-PID list; MAF/IAT values implausible (explained by Route B session: sensor faults); mode 09 silent (no VIN); **5 stored DTCs, MIL off**; raw at `raw/diag-20260923-1117*.log`
|
- [[diag-route-a-2026-09-23]] — **first live Route A probe run (2026-09-23)**: DDE serves generic OBD mode 01 on `0x7E8` (verified: rpm + coolant cross-checked against the broadcast IDs); supported-PID list; MAF/IAT values implausible (explained by Route B session: sensor faults); mode 09 silent (no VIN); **5 stored DTCs, MIL off**; raw at `raw/diag-20260923-1117*.log`
|
||||||
|
|||||||
+108
-7
@@ -44,15 +44,15 @@ First real dump off the swap's bus, taken with the board's **own new raw-frame l
|
|||||||
|
|
||||||
## [2026-09-21] update | .docs folder retired; UART spec moved to docs/; board photo ingested
|
## [2026-09-21] update | .docs folder retired; UART spec moved to docs/; board photo ingested
|
||||||
|
|
||||||
The repo's `.docs/` folder was deleted (user decision). `CAN_BUS_INTEGRATION.md` documented the dead placeholder IDs and an external transceiver the board does not need — superseded by [[can-id-candidates]] and [[can-bus-integration]]. `UART_PROTOCOL.md` (the packet spec, shared with Controller B) moved to `docs/UART_PROTOCOL.md` as the single copy; Controller B's duplicate was removed. The annotated board photo moved to `raw/` → [[esp32-s3-touch-lcd-5-intro-photo]]: confirms the terminal-block order, that GPIO 44 exits only as the RS485 A/B pair, and that one 120 Ω switch serves both CAN and RS485. Root `CLAUDE.md` corrected: verified CAN ID list replaces the placeholders, `TWAI_MODE_NORMAL` replaces "LISTEN_ONLY", UART TX is GPIO 44 (was written as 43), dummy-data references removed.
|
The repo's `.docs/` folder was deleted (user decision). `CAN_BUS_INTEGRATION.md` documented the dead placeholder IDs and an external transceiver the board does not need — superseded by [[can-id-candidates]] and [[can-bus-integration]]. `UART_PROTOCOL.md` (the packet spec, shared with Inst. Cluster) moved to `docs/UART_PROTOCOL.md` as the single copy; Inst. Cluster's duplicate was removed. The annotated board photo moved to `raw/` → [[esp32-s3-touch-lcd-5-intro-photo]]: confirms the terminal-block order, that GPIO 44 exits only as the RS485 A/B pair, and that one 120 Ω switch serves both CAN and RS485. Root `CLAUDE.md` corrected: verified CAN ID list replaces the placeholders, `TWAI_MODE_NORMAL` replaces "LISTEN_ONLY", UART TX is GPIO 44 (was written as 43), dummy-data references removed.
|
||||||
|
|
||||||
**Missing source**: the schematic PDF (`ESP32-S3-Touch-LCD-5-Sch.pdf`) was in `.docs/` at the start of the 2026-09-21 session and was not on disk by the time of this cleanup (never git-tracked). Its net list was read earlier that session and is reflected in [[esp32-s3-touch-lcd-5b]]; re-download it into `raw/` — still on the sourcing wishlist in [[open-questions]].
|
**Missing source**: the schematic PDF (`ESP32-S3-Touch-LCD-5-Sch.pdf`) was in `.docs/` at the start of the 2026-09-21 session and was not on disk by the time of this cleanup (never git-tracked). Its net list was read earlier that session and is reflected in [[esp32-s3-touch-lcd-5b]]; re-download it into `raw/` — still on the sourcing wishlist in [[open-questions]].
|
||||||
|
|
||||||
Sibling wiki instantiated today at `../../ESP32-S3-LCD-1.3/wiki/` for Controller B (link, redundancy, gauge outputs). Cross-references from there use the text form `(sibling: 5B wiki → page)`.
|
Sibling wiki instantiated today at `../../ESP32-S3-LCD-1.3/wiki/` for Inst. Cluster (link, redundancy, gauge outputs). Cross-references from there use the text form `(sibling: 5B wiki → page)`.
|
||||||
|
|
||||||
## [2026-09-21] update | Link protocol v2: ESP-NOW second transport, gear/rpm/alerts on the wire, tunables console
|
## [2026-09-21] update | Link protocol v2: ESP-NOW second transport, gear/rpm/alerts on the wire, tunables console
|
||||||
|
|
||||||
Firmware (not yet committed): shared header v2 with typed DATA/CONFIG frames; `Tunables` module (gauge calibration + alert thresholds in NVS, `cfg show|set|override|reset` on the USB console); `EspNowLink` broadcasts every frame alongside UART1 (radio now stays in STA mode — WiFiManager's off no longer calls `WIFI_OFF`); CAN driver publishes lever + target/engaged gear nibbles and rpm, and evaluates coolant/gearbox/battery/cooling-demand alerts against the tunables. Bench-verified with Controller B: both transports alive, every frame deduplicated, `cfg override rpm 2000` drove B's tach output at 133.3 Hz. `docs/UART_PROTOCOL.md` rewritten for v2. [[dual-controller-architecture]] and index updated. Build note: IDF 5.5's ESP-NOW send callback takes `wifi_tx_info_t*`; and the two repos must not be built concurrently (shared penv).
|
Firmware (not yet committed): shared header v2 with typed DATA/CONFIG frames; `Tunables` module (gauge calibration + alert thresholds in NVS, `cfg show|set|override|reset` on the USB console); `EspNowLink` broadcasts every frame alongside UART1 (radio now stays in STA mode — WiFiManager's off no longer calls `WIFI_OFF`); CAN driver publishes lever + target/engaged gear nibbles and rpm, and evaluates coolant/gearbox/battery/cooling-demand alerts against the tunables. Bench-verified with Inst. Cluster: both transports alive, every frame deduplicated, `cfg override rpm 2000` drove B's tach output at 133.3 Hz. `docs/UART_PROTOCOL.md` rewritten for v2. [[dual-controller-architecture]] and index updated. Build note: IDF 5.5's ESP-NOW send callback takes `wifi_tx_info_t*`; and the two repos must not be built concurrently (shared penv).
|
||||||
|
|
||||||
## [2026-09-21] update | Gauge Tuning screen
|
## [2026-09-21] update | Gauge Tuning screen
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ User clipped a Google AI Mode conversation into `Clippings/` (Obsidian Web Clipp
|
|||||||
|
|
||||||
User dropped `raw/BMW 335d.csv` and clipped page 1 of the e90post/6post thread "Extended BMW 335d PIDs for Torque" (DWR, 2009 335d = M57N2 on DDE7.3/EDC17CP09) → [[dwr-335d-torque-pids]]. **Every entry is a generic SAE J1979 mode-01 PID** (DWR says so in post 21; header `Auto` = `0x7DF`); nothing BMW-proprietary, nothing broadcast. Two revisions compared: the CSV in `raw/` is the corrected 2017 one (boost ×0.3125 = the J1979 0.03125 kPa/bit; fuel rate ×0.0938 lb/hr; post-#2's ×0.296 and ×5.64 were wrong); residual typos noted (`000031` for 0.0000305, one `+33`). Decoded his table back to SI with the J1979 byte positions. Consequence for us: the generic route is the **cheapest polling experiment** — one `01 00` supported-PID query on `0x7DF` tells whether our DDE answers EOBD on the PT-CAN and which PIDs it has — but the diesel-specific PIDs he relies on for boost (`70`), exhaust pressure (`73`), EGT (`78`), DPF (`7A`), NOx (`83`) are 2007+ J1979 additions an EDC16 almost certainly lacks `(unverified)`, and PID `0B` clips at 255 kPa. [[obd-diagnostic-polling]] restructured into Route A (generic, PID table, first test) and Route B (BMW `0x6F1`/`0x612`). Wishlist: DWR's Testo parameter list (post 175 of the Testo thread). Updated [[open-questions]] #7 + wishlist, index.
|
User dropped `raw/BMW 335d.csv` and clipped page 1 of the e90post/6post thread "Extended BMW 335d PIDs for Torque" (DWR, 2009 335d = M57N2 on DDE7.3/EDC17CP09) → [[dwr-335d-torque-pids]]. **Every entry is a generic SAE J1979 mode-01 PID** (DWR says so in post 21; header `Auto` = `0x7DF`); nothing BMW-proprietary, nothing broadcast. Two revisions compared: the CSV in `raw/` is the corrected 2017 one (boost ×0.3125 = the J1979 0.03125 kPa/bit; fuel rate ×0.0938 lb/hr; post-#2's ×0.296 and ×5.64 were wrong); residual typos noted (`000031` for 0.0000305, one `+33`). Decoded his table back to SI with the J1979 byte positions. Consequence for us: the generic route is the **cheapest polling experiment** — one `01 00` supported-PID query on `0x7DF` tells whether our DDE answers EOBD on the PT-CAN and which PIDs it has — but the diesel-specific PIDs he relies on for boost (`70`), exhaust pressure (`73`), EGT (`78`), DPF (`7A`), NOx (`83`) are 2007+ J1979 additions an EDC16 almost certainly lacks `(unverified)`, and PID `0B` clips at 255 kPa. [[obd-diagnostic-polling]] restructured into Route A (generic, PID table, first test) and Route B (BMW `0x6F1`/`0x612`). Wishlist: DWR's Testo parameter list (post 175 of the Testo thread). Updated [[open-questions]] #7 + wishlist, index.
|
||||||
|
|
||||||
## [2026-09-21] update | `diag` console probe: Controller A can now send OBD-II requests
|
## [2026-09-21] update | `diag` console probe: Main CTRL can now send OBD-II requests
|
||||||
|
|
||||||
User decision: build the Route A probe. New module `src/modules/diag_probe.cpp` and a single sanctioned transmit function `CANDriver::transmit()` (single-shot frames, `CANTX,` console echo mirroring `CANRAW,`). Console: `diag pids` (mode-01 supported-PID bitmap scan, blocks 00/20/40…, per-responder summary with PID names), `diag pid <hex>` (one request, decoded for the Route A table incl. PID 70 boost and 78 EGT), `diag vin`, `diag ecu` (mode 09), `diag status`. ISO-TP single/first/consecutive frames reassembled with a `30 00 00` flow control to the responder's physical ID. Guards: one request in flight, refused for 3 s after any foreign tester frame (`0x7DF`/`0x7E0–7`/`0x6F1`), services 01 and 09 only. Console dispatch chained through `Tunables::setExtraCommandHandler()`. Built (1.49 MB) and flashed to COM11; bench check with no bus attached: `diag pids` sent `02 01 00` on `0x7DF`, the TWAI controller reported the single-shot frame un-ACKed, and the probe reported "not ACKed - no other node saw it" rather than blaming the ECU (the summary distinguishes un-ACKed from ACKed-but-silent). CAN-task warnings now take the serial lock so they no longer splice into `CANTX` lines. The wiki's "firmware never transmits" statements are now qualified on [[can-bus-integration]] and [[obd-diagnostic-polling]] (test-day procedure and the three possible outcomes written there). Root `CLAUDE.md` and `docs/UART_PROTOCOL.md` console section updated. Procedure rewritten as numbered steps with all four outcomes (un-ACKed / ACKed-silent / one responder / two responders) and the log-capture command.
|
User decision: build the Route A probe. New module `src/modules/diag_probe.cpp` and a single sanctioned transmit function `CANDriver::transmit()` (single-shot frames, `CANTX,` console echo mirroring `CANRAW,`). Console: `diag pids` (mode-01 supported-PID bitmap scan, blocks 00/20/40…, per-responder summary with PID names), `diag pid <hex>` (one request, decoded for the Route A table incl. PID 70 boost and 78 EGT), `diag vin`, `diag ecu` (mode 09), `diag status`. ISO-TP single/first/consecutive frames reassembled with a `30 00 00` flow control to the responder's physical ID. Guards: one request in flight, refused for 3 s after any foreign tester frame (`0x7DF`/`0x7E0–7`/`0x6F1`), services 01 and 09 only. Console dispatch chained through `Tunables::setExtraCommandHandler()`. Built (1.49 MB) and flashed to COM11; bench check with no bus attached: `diag pids` sent `02 01 00` on `0x7DF`, the TWAI controller reported the single-shot frame un-ACKed, and the probe reported "not ACKed - no other node saw it" rather than blaming the ECU (the summary distinguishes un-ACKed from ACKed-but-silent). CAN-task warnings now take the serial lock so they no longer splice into `CANTX` lines. The wiki's "firmware never transmits" statements are now qualified on [[can-bus-integration]] and [[obd-diagnostic-polling]] (test-day procedure and the three possible outcomes written there). Root `CLAUDE.md` and `docs/UART_PROTOCOL.md` console section updated. Procedure rewritten as numbered steps with all four outcomes (un-ACKed / ACKed-silent / one responder / two responders) and the log-capture command.
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ First in-car test of the dual-controller rig: A reads the bus fine, B receives f
|
|||||||
|
|
||||||
## [2026-09-22] query | Patrol cluster signal research - tach 2 ppr verified, temp sender curve, flutter plan
|
## [2026-09-22] query | Patrol cluster signal research - tach 2 ppr verified, temp sender curve, flutter plan
|
||||||
|
|
||||||
First day driving the real cluster from Controller B through the 2SK3069 low-side stage. Tach: needle tracked at double with ppr=4; user set ppr=2 -> tracks correctly (verified). 2 ppr matches an ECU-driven 4-cyl-style tach input (ZD30-era Y61 hint, unverified) rather than the TD42 alternator-W-terminal scheme. Temp gauge on IO8: needle flutters at temp_pwm_hz=1 kHz. Researched: stock Patrol sender is an NTC (2.1-2.9k @ 20C, 0.68-1k @ 50C, 236-260R @ 90C; patrol4x4/sensorgal), gauge is current-measuring; community PWM-gauge experience says flutter dies at ~40-50 kHz. Mitigation ladder filed: fixed-duty override test (data vs electrical), cfg set temp_hz 20000 (firmware clamp), then raise clamp / series drain resistor (~100-240R, also bounds full-on beyond-hot short) / gauge-side cap. Temp law must be re-derived after (FET inverts duty sense). Filed [[patrol-instrument-cluster]]; index updated. Earlier same day: [[canny-5-3-pico-gauge-drive]] hypothesis effectively confirmed by the needles moving through the FET; gauge-output disable bits found off during bench test (B console "disabled") - re-enabled via tuning screen.
|
First day driving the real cluster from Inst. Cluster through the 2SK3069 low-side stage. Tach: needle tracked at double with ppr=4; user set ppr=2 -> tracks correctly (verified). 2 ppr matches an ECU-driven 4-cyl-style tach input (ZD30-era Y61 hint, unverified) rather than the TD42 alternator-W-terminal scheme. Temp gauge on IO8: needle flutters at temp_pwm_hz=1 kHz. Researched: stock Patrol sender is an NTC (2.1-2.9k @ 20C, 0.68-1k @ 50C, 236-260R @ 90C; patrol4x4/sensorgal), gauge is current-measuring; community PWM-gauge experience says flutter dies at ~40-50 kHz. Mitigation ladder filed: fixed-duty override test (data vs electrical), cfg set temp_hz 20000 (firmware clamp), then raise clamp / series drain resistor (~100-240R, also bounds full-on beyond-hot short) / gauge-side cap. Temp law must be re-derived after (FET inverts duty sense). Filed [[patrol-instrument-cluster]]; index updated. Earlier same day: [[canny-5-3-pico-gauge-drive]] hypothesis effectively confirmed by the needles moving through the FET; gauge-output disable bits found off during bench test (B console "disabled") - re-enabled via tuning screen.
|
||||||
|
|
||||||
## [2026-09-22] update | Temp gauge flutter resolved: temp_hz 1 kHz -> 20 kHz
|
## [2026-09-22] update | Temp gauge flutter resolved: temp_hz 1 kHz -> 20 kHz
|
||||||
|
|
||||||
@@ -110,9 +110,9 @@ The capture-with-Launch session, finally run (engine idling, our read-only seria
|
|||||||
|
|
||||||
Tightened the live-data findings after checking the full capture: the Launch used only 1A/2C/22/23 - NO 10 (session), 27 (security), or 3E (tester-present). So self-polling a 2C value (e.g. rail pressure) needs only the 2C 10 15E0 define + 2C 10 00DF poll, no secret; the earlier 21-block NRCs (0x22/0x33) are a different mechanism and do not gate 2C. Corrected the "needs session/define handshake" wording in launch-capture-2026-09-23.md and obd-diagnostic-polling. Recorded the design decision (user, 2026-09-23): active polling, if built, lives behind a password-protected Diagnostics screen (authorized-tech gate, manual, refuses while scan tool connected, read-oriented services) - open-questions #12, and a project memory so the capability is not re-researched later.
|
Tightened the live-data findings after checking the full capture: the Launch used only 1A/2C/22/23 - NO 10 (session), 27 (security), or 3E (tester-present). So self-polling a 2C value (e.g. rail pressure) needs only the 2C 10 15E0 define + 2C 10 00DF poll, no secret; the earlier 21-block NRCs (0x22/0x33) are a different mechanism and do not gate 2C. Corrected the "needs session/define handshake" wording in launch-capture-2026-09-23.md and obd-diagnostic-polling. Recorded the design decision (user, 2026-09-23): active polling, if built, lives behind a password-protected Diagnostics screen (authorized-tech gate, manual, refuses while scan tool connected, read-oriented services) - open-questions #12, and a project memory so the capability is not re-researched later.
|
||||||
|
|
||||||
## [2026-09-26] build | OTA updates for Controller A
|
## [2026-09-26] build | OTA updates for Main CTRL
|
||||||
|
|
||||||
Repartitioned A to dual OTA slots (2 x 7.9 MB, SPIFFS dropped, nvs/otadata offsets kept - tunables v150 survived the one-time USB flash on COM10, verified). New src/modules/ota_update.cpp + include/config/ota_config.h: manual `ota status|check|install|rollback` console; HTTPS pull from the (now public) Gitea repo's latest release, ECDSA P-256 signature over "patrol-a|version|sha256" checked before download, image hashed while streaming, parked gate before download and before slot switch, rollback via verifyRollbackLater() override + 30 s confirm. TLS trusts ISRG Root X1 + Root YR (both verified against the server chain). CI: .gitea/workflows/firmware.yml (main -> rolling unsigned pre-release main-latest; v* tag -> signed release with manifest.txt). Decisions: manual trigger (future Diagnostics screen), public repos instead of a device token, Controller B to be updated by A over ESP-NOW (wire is one-way). Wrote pages/ota-updates.md. Pending: BMW_NISSAN_FIRMWARE_SIGNING_KEY repo secret, enable repo Actions, first v* tag to test end-to-end.
|
Repartitioned A to dual OTA slots (2 x 7.9 MB, SPIFFS dropped, nvs/otadata offsets kept - tunables v150 survived the one-time USB flash on COM10, verified). New src/modules/ota_update.cpp + include/config/ota_config.h: manual `ota status|check|install|rollback` console; HTTPS pull from the (now public) Gitea repo's latest release, ECDSA P-256 signature over "patrol-a|version|sha256" checked before download, image hashed while streaming, parked gate before download and before slot switch, rollback via verifyRollbackLater() override + 30 s confirm. TLS trusts ISRG Root X1 + Root YR (both verified against the server chain). CI: .gitea/workflows/firmware.yml (main -> rolling unsigned pre-release main-latest; v* tag -> signed release with manifest.txt). Decisions: manual trigger (future Diagnostics screen), public repos instead of a device token, Inst. Cluster to be updated by A over ESP-NOW (wire is one-way). Wrote pages/ota-updates.md. Pending: BMW_NISSAN_FIRMWARE_SIGNING_KEY repo secret, enable repo Actions, first v* tag to test end-to-end.
|
||||||
|
|
||||||
## [2026-09-26] build | OTA bring-up: Wi-Fi switch, ESP-NOW, memory
|
## [2026-09-26] build | OTA bring-up: Wi-Fi switch, ESP-NOW, memory
|
||||||
|
|
||||||
@@ -125,3 +125,104 @@ Bench (home, both controllers on laptop USB, no car): A running USB-flashed `dev
|
|||||||
## [2026-09-26] build | Display quick fixes (v0.1.2)
|
## [2026-09-26] build | Display quick fixes (v0.1.2)
|
||||||
|
|
||||||
User reported heavy flicker during OTA and on Gauge Tuning taps, and laggy swipes. Diagnosis: flash and PSRAM share the MSPI cache; every flash write (OTA, or the NVS save on each Tuning tap) stalls the PSRAM framebuffer the RGB panel streams from, with no bounce buffer (ESP_PANEL_LCD_RGB_BOUNCE_BUF_SIZE=0) - a known ESP32-S3 RGB issue. Swipes: every transition was LV_SCR_LOAD_ANIM_FADE_ON 100 ms - a full 1024x600 software re-render + alpha blend per frame. Also: the Debug "FPS" counts loop() passes (loop sleeps 100 ms), not rendering - real render FPS has never been measured. Quick fixes: instant screen switches; Tunables NVS writes deferred to 3 s idle / leaving Tuning; backlight off during OTA writes with before/after notices; firmware version label bottom-right on every screen. Real cure (bounce buffers + SPIRAM_XIP_FROM_PSRAM via custom_sdkconfig, needs internal RAM freed first) is planned as one measured bench session with open-questions #13.
|
User reported heavy flicker during OTA and on Gauge Tuning taps, and laggy swipes. Diagnosis: flash and PSRAM share the MSPI cache; every flash write (OTA, or the NVS save on each Tuning tap) stalls the PSRAM framebuffer the RGB panel streams from, with no bounce buffer (ESP_PANEL_LCD_RGB_BOUNCE_BUF_SIZE=0) - a known ESP32-S3 RGB issue. Swipes: every transition was LV_SCR_LOAD_ANIM_FADE_ON 100 ms - a full 1024x600 software re-render + alpha blend per frame. Also: the Debug "FPS" counts loop() passes (loop sleeps 100 ms), not rendering - real render FPS has never been measured. Quick fixes: instant screen switches; Tunables NVS writes deferred to 3 s idle / leaving Tuning; backlight off during OTA writes with before/after notices; firmware version label bottom-right on every screen. Real cure (bounce buffers + SPIRAM_XIP_FROM_PSRAM via custom_sdkconfig, needs internal RAM freed first) is planned as one measured bench session with open-questions #13.
|
||||||
|
|
||||||
|
## [2026-09-26] build | CI: no duplicate / docs-only builds; v0.1.3
|
||||||
|
|
||||||
|
v0.1.3 released (OTA download loop no longer aborts on a momentary TLS connected()==false; a forced reinstall had stalled at 570 B once, retry succeeded). Pushing main then the tag ran two identical builds, and every wiki commit rebuilt firmware: the workflow's new "Skip?" step makes a main push skip itself when its commit carries a v* tag or only touches wiki/** / *.md (in-job, so tag builds are never path-filtered). Release with `git push --follow-tags origin main`. Logic dry-run locally against the real remote (tagged/untagged/docs/mixed cases).
|
||||||
|
|
||||||
|
## [2026-09-27] lint | Session sweep: OTA status, board gotchas, Wi-Fi follow-ups
|
||||||
|
|
||||||
|
Brought the wiki in line with the whole 2026-09-26 session. ota-updates: status table of every cycle (dev->v0.1.1->v0.1.2, forced reinstall with the 570 B abort + clean failure path, v0.1.3 published but not installed), "installs are done by the running firmware" rule, flicker cause marked verified, Wi-Fi lost on reboot, console-without-reset recipe, B repo now public. esp32-s3-touch-lcd-5b: removed the unmeasured "~50 FPS" claim, USB serial is native CDC (not UART0) with the DTR/RTS reset gotcha, new lessons (flash-write flicker, fade stutter, internal RAM, never power the radio off, dual-slot partitions). dual-controller-architecture: ESP-NOW/Wi-Fi radio sharing + the disconnect(true) bug, B updates via A over ESP-NOW. open-questions #14: Wi-Fi UX redesign, remember network, delete v0.1.0 release. Pending user confirmations: dark-screen OTA shows no flicker; version label placement; instant swipes; Tuning taps.
|
||||||
|
|
||||||
|
## [2026-09-27] build | UI freeze + reboots fixed: LVGL pool to PSRAM, dangling SSID buttons, scans (v0.1.4)
|
||||||
|
|
||||||
|
User: swiping main<->Settings 3x froze the UI; random flickering dots on all screens. Board state while frozen: link task alive (UART+ESP-NOW), loop()/console dead -> LVGL lock held forever. Causes found: (1) LV_ASSERT_HANDLER `while(1);` spins inside the task holding the LVGL lock; (2) g_ssid_buttons[] dangled after SquareLine deleted the Settings screen -> lv_obj_del() on freed objects; (3) with (1) replaced by abort(), the next run rebooted after ~5 round trips and the decoded backtrace showed the real limit: lv_mem_buf_get() failing in a label draw - the 48 KB LVGL pool at 87% / 31% frag / 4.5 KB biggest block; (4) Wi-Fi scanned every 10 s on every screen, connected or not. Fixes: abort() handler, LV_EVENT_DELETE clears button slots, scanning only with the list on screen and not connected, LVGL pool 512 KB in PSRAM (frees 48 KB internal: internal free 16 -> 69 KB), `mem` console command. Verified: 10 Settings visits + 9 list rebuilds, pool peak 4%, 0 crashes; user: swipes better, no dots, no freeze, no reboot. Updated esp32-s3-touch-lcd-5b, open-questions #13/#14, ota-updates, CLAUDE.md.
|
||||||
|
|
||||||
|
## [2026-09-27] build | Hand-coded Settings + tabbed Gauge Tuning, remembered Wi-Fi, on-screen updates (v0.1.5)
|
||||||
|
|
||||||
|
User asked to refactor the Settings and Gauge Tuning UX, save the Wi-Fi connection, and add a check for updates. Decisions (user): sidebar Settings (Wi-Fi / Updates / System), install behind a confirm dialog (not a PIN), one remembered network, Tuning as tabs with big controls. SquareLine Settings screen deleted; WiFiManager rewritten without UI code (remembered network in NVS, auto-join at boot, scans only on request, one retry then back to the ESP-NOW channel, failure reasons on screen, password never logged - the old code printed it). Verified: auto-join after USB flash; user installed v0.1.4 then v0.1.5 from the screen ("All good"); v0.1.4 showed the dots again because it forgot the network after the restart and rescanned. Lessons: a plain `git push` doesn't send tags (v0.1.5 needed `git push origin v0.1.5`); esptool crashes mid-write when its progress bar goes to a cp1252 pipe. Updated ota-updates (status table, decision: Updates on Settings), open-questions #12/#14, esp32-s3-touch-lcd-5b, dual-controller-architecture, index.
|
||||||
|
|
||||||
|
## [2026-09-27] build | SquareLine decommissioned (v0.1.6); display plan recorded
|
||||||
|
|
||||||
|
`include/ui/` deleted (the SquareLine export: ui_init, placeholder screen, helpers, theme manager); its one live line, the dark LVGL theme, moved to `display_init.cpp`. User verified on `dev` (Wi-Fi forget/scan/rejoin, dialogs, keyboard) and installed v0.1.6 from the screen: "all good". SquareLine references left in `.pio/libdeps` are library examples, never compiled. Recorded the agreed display plan in open-questions #13 (baseline -> bounce buffers -> XIP_FROM_PSRAM on a branch), including why bounce buffers alone won't fix flash-write flicker, and why CAN / wire / ESP-NOW need no buffering (dropped-frame counter deferred by the user).
|
||||||
|
|
||||||
|
## [2026-09-26] ingest | Schematic re-downloaded; VOUT = H8 solder jumper (3V3 default / 5V)
|
||||||
|
|
||||||
|
User asked whether VOUT becomes 5 V by "unsoldering the resistor". Re-fetched `ESP32-S3-Touch-LCD-5-Sch.pdf` into `raw/` (closes the wishlist item) → [[esp32-s3-touch-lcd-5-schematic]]. Answer: VOUT is net `I2C_VCC`, picked by **`H8`, a 3-pad solder jumper** (1 = 3V3, 2 = VOUT, 3 = 5V; "the default paste is 3V3"): open the 1–2 bridge, bridge 2–3, never all three. The terminal-block I2C lines are level-shifted (NDC7002N, 4.7 k pull-ups to `I2C_VCC`) so they follow the choice. 5 V rail is a SY8293 buck rated 2 A ("run the line at 2A"), screen ≈550 mA, so ≈1 A spare for a load such as Inst. Cluster `(unverified estimate)`; not on USB power. Also indexed: SD SPI pins (IO11/12/13, CS EXIO4), CAN IO15/16 and RS485 IO43/44 confirmed. Updated [[esp32-s3-touch-lcd-5b]], [[open-questions]] wishlist, index.
|
||||||
|
|
||||||
|
## [2026-09-27] query | Open question 13 reviewed with the user: full fix committed, dots not gone
|
||||||
|
|
||||||
|
I argued for the cheap half only (baseline, 40-line draw buffer, time-boxed bounce buffers) and deferring XIP-from-PSRAM as cosmetic. User corrected two premises: the dots still appear occasionally on v0.1.6 (the "gone" claim on [[esp32-s3-touch-lcd-5b]] was too strong — now qualified), and a dark screen during OTA is a safety/UX defect (no feedback → driver may turn the ignition off mid-update). Decision (user): fix everything, all steps through XIP, bench time is no constraint; add an on-screen progress bar + "do not switch off" during updates. Recorded on [[open-questions]] #13. Also explained in plain terms why the coolant duty law still needs re-deriving through the FET stage ([[patrol-instrument-cluster]]); that remains the higher-priority car-facing item.
|
||||||
|
|
||||||
|
## [2026-09-27] build | `perf` console: the measuring stick for open question 13
|
||||||
|
|
||||||
|
Step 1 of the display plan. New `src/modules/perf_monitor.cpp`: LVGL `monitor_cb` (frames, ms/frame, px), a timer around `drawBitmap()` in the port's flush callback (ms per second spent writing the PSRAM framebuffer), `lv_timer_get_idle()`, FreeRTOS run-time stats for per-core idle (enabled in the Arduino core's sdkconfig), heap figures. `perf` / `perf on [sec]` / `perf off`; `PERF,` CSV lines sit next to `CANRAW` in a session log. Built and flashed COM14 (the 5B enumerates as COM14 today; the 1.3 as COM13). Idle baseline recorded on [[open-questions]] #13. Next: the provoke session (Wi-Fi scan, tuning save, OTA) with `perf on 1` logging, then bounce buffers.
|
||||||
|
|
||||||
|
## [2026-09-27] ingest | Display baseline session (perf log) — Driveline redraws for nothing, flash writes invisible to LVGL counters
|
||||||
|
|
||||||
|
`raw/perf-20260927-164620.log` (2.5 min, `perf on 1`, screens exercised: Settings, Wi-Fi scan + join, ota check, Gauge Tuning incl. hold-repeat and Simulation, ota install v0.1.6) → [[perf-baseline-2026-09-27]]. No markers were typed, timeline rebuilt from the board's log lines. Findings: (1) Driveline renders ~10 fps × 39 kpx × 30 ms with constant data — `tick()` calls `lv_label_set_text` unconditionally for rpm/torque/pedal/shaft every 100 ms `(repo)` → a third of core 1 and 51 ms/s of PSRAM writes for nothing; (2) screen switches are single 140–330 ms frames (the swipe lag) — a drawing cost, not a DMA one; (3) Simulation tab = 2 Mpx/s, 26 % of time copying to PSRAM, LVGL idle 9 %, core 1 idle 25 % — the load bounce-buffer refill must coexist with; (4) the 16:47:10 NVS save left no trace in the counters: flicker lives on the panel DMA side, so a vsync/refresh counter is needed to measure steps 2–3; (5) PERF stops during the 41 s OTA download (loop blocked). Heap flat. Plan on [[open-questions]] #13 amended (step 1b). User's visual observations for this run not recorded — asked.
|
||||||
|
|
||||||
|
## [2026-09-27] build | Step 1b: Driveline redraw stopped, panel vsync counter, timer-driven PERF
|
||||||
|
|
||||||
|
From the baseline findings. (1) `driveline_screen.cpp`: `setText()` / `setChip()` write a label or colour only when it differs — idle Driveline went from 9.7 fps, 30 ms/frame, 52 ms/s PSRAM copies, LVGL idle 68 %, core 1 idle 66 % to **0 fps, 0 ms/s, 96 %, 96 %** `(verified bench)`. (2) `perf` now counts the RGB panel's refresh-finished interrupt (attached in the port when tearing-avoidance is off): **≈24 vsync/s, longest gap 41.5 ms** = one frame at the 16 MHz pixel clock; a DMA restart will read as ≥ 83 ms — the first direct instrument for flicker and dots. (3) Periodic PERF moved from `loop()` to an esp_timer so it keeps reporting through the OTA download. Recorded on [[open-questions]] #13 and [[esp32-s3-touch-lcd-5b]]; root CLAUDE.md gained the "write only on change" rule for screen ticks. Next: provoke session with markers, then bounce buffers.
|
||||||
|
|
||||||
|
## [2026-09-27] ingest | Perf session with dots on screen + OTA: dots are sub-frame glitches, OTA kills 75 % of frames
|
||||||
|
|
||||||
|
`raw/perf-20260927-165903.log` → [[perf-dots-and-ota-2026-09-27]]. User started logging while dots/dashes were visible on the idle Driveline: LVGL 0 fps, cores 95 % idle, **panel 24–25 vsync/s with a 41.5 ms gap** — the frames were all on time, so the dots are FIFO underruns of a few pixels that the driver's restart-in-vsync never sees; only eyes can judge them, and bounce buffers (DMA from internal SRAM) are the designed cure. During `ota install` the panel fell to **4–8 vsync/s, gaps 290–747 ms** (332 ms = 8 frames recurring): each sector write disables the cache and starves the DMA — quantifies why the screen is unusable during updates and sets the step-3 target (24/s, 41.5 ms during install). Trim edits + deferred NVS save and `ota check` lost no frames. Still no markers typed — asked the user what was seen. Updated [[open-questions]] #13, [[esp32-s3-touch-lcd-5b]], index.
|
||||||
|
|
||||||
|
## [2026-09-27] lint | Correction: bounce buffers were on all along (10 lines, 21 MHz); the dots are late refills
|
||||||
|
|
||||||
|
While preparing step 2 I found the panel library reads `ESP_PANEL_BOARD_LCD_RGB_*` from its own `BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_5_B.h` — bounce buffer = width × 10, pixel clock 21 MHz (→ 24.1 Hz, matching the vsync counter exactly). The three `-DESP_PANEL_LCD_RGB_*` flags in `platformio.ini` were dead names; removed and replaced by a comment. Corrected [[esp32-s3-touch-lcd-5b]] (no more "no bounce buffer" / "16 MHz"), [[perf-dots-and-ota-2026-09-27]] (warning callout with the refined mechanism: a late 20 KB refill makes the DMA re-send the previous 10-line chunk → text-coloured dashes below each line, as in the user's photo `raw/dots-20260927_170136.jpg`), [[open-questions]] #13 (step A void; step 3 now covers dots and OTA). Contributing PSRAM traffic noted from the qio_opi sdkconfig: `CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y` (Wi-Fi buffers in PSRAM), 32 KB data cache / 32 B lines, `LCD_RGB_ISR_IRAM_SAFE` off, XIP off. pioarduino 55.03.33 supports `custom_sdkconfig` (rebuilds the core) — branch `display-xip` next.
|
||||||
|
|
||||||
|
## [2026-09-27] verify | Step 3 (XIP from PSRAM + IRAM-safe RGB ISR): OTA no longer blanks the panel
|
||||||
|
|
||||||
|
Branch `display-xip`: pioarduino `custom_sdkconfig` with `CONFIG_SPIRAM_XIP_FROM_PSRAM`/`FETCH_INSTRUCTIONS`/`RODATA` and `CONFIG_LCD_RGB_ISR_IRAM_SAFE`. First core rebuild (20 min) failed at the end on RainMaker/Insights embedding `https_server.crt`; dropping the unused components with `custom_component_remove` fixed it (rebuild ~3 min after). Flashed COM14, then a scripted `ota install force` with `perf on 1` → [[perf-xip-ota-2026-09-27]]: **24–25 vsync/s, 41.5 ms gap for the entire 33 s download** (stock core an hour earlier: 4–8/s, 290–747 ms). Flash-write blanking is fixed `(verified)`; step 4 (progress bar with the screen on) is unblocked. PSRAM free 6.6 → 4.9 MB, internal 66 → 63 KB, first full redraw 142 ms (no slow-down seen). Generated IDF files git-ignored. Open: dots by eye on the XIP build, swipe-lag comparison, CI must rebuild the core. Updated [[open-questions]] #13, [[esp32-s3-touch-lcd-5b]], index.
|
||||||
|
|
||||||
|
## [2026-09-27] build | Step 4: OTA keeps the screen on with a progress bar (branch display-xip)
|
||||||
|
|
||||||
|
`ota_update.cpp`: the full-screen notice gained an LVGL bar + percent label + amber "Do not switch off the ignition"; the download loop updates it per percent under a 50 ms LVGL try-lock; the backlight off/on around `writeImage()` is gone. Settings texts updated (confirm dialog, Updates note). Second forced install under `perf` → [[perf-xip-ota-2026-09-27]]: 24–25 panel frames/s and a 41.5 ms gap for the whole download, bar redrawing 2–3×/s. User confirmed on the screen: progress bar visible, no flicker. [[ota-updates]] rewritten for the lit screen; [[open-questions]] #13 step 4 done. Left: dots verdict by eye on the XIP build, CI core rebuild, merge + v0.1.7.
|
||||||
|
|
||||||
|
## [2026-09-27] release | v0.1.7: XIP from PSRAM, IRAM-safe panel refill, OTA progress bar, perf monitor, Driveline idle fix
|
||||||
|
|
||||||
|
User exercised the `display-xip` build (Wi-Fi scan, update check, install) and reported no flicker or other issues; decision: merge to main and tag **v0.1.7**. Contents since v0.1.6: core rebuilt with `CONFIG_SPIRAM_XIP_FROM_PSRAM` + `CONFIG_LCD_RGB_ISR_IRAM_SAFE` (pioarduino `custom_sdkconfig`, unused IDF components removed); OTA screen stays lit with a progress bar and "Do not switch off the ignition"; `perf` console + `tools/perf_session.py` (fps, PSRAM copy load, idle, panel vsync/gap); Driveline tick writes labels only on change; dead `ESP_PANEL_LCD_RGB_*` flags removed. Verified on the bench: 24–25 panel frames/s and a 41.5 ms gap throughout an OTA download (was 4–8/s). Open: dots in longer use (eyes only), CI core rebuild on the tag build. Pages: [[perf-baseline-2026-09-27]], [[perf-dots-and-ota-2026-09-27]], [[perf-xip-ota-2026-09-27]], [[ota-updates]], [[open-questions]] #13.
|
||||||
|
|
||||||
|
## [2026-09-27] build | v0.1.7 CI failure fixed: pioarduino core fork in the workflow, tag moved
|
||||||
|
|
||||||
|
Tag build died at the link step: `ModuleNotFoundError: No module named 'SCons.Tool.FortranCommon'`. Cause: CI installed upstream `platformio` via uv while the pioarduino platform pins its own SCons 4.8.1 (no Fortran tools) and, since `custom_sdkconfig`, the build runs through pioarduino's ESP-IDF path where the upstream core imports FortranCommon; locally the penv runs pioarduino's core fork (platform `penv_setup.py` pin v6.1.18), which never hit it — and v0.1.1–v0.1.6 never used that path. Workflow now installs the fork zip; documented in root CLAUDE.md and [[ota-updates]]. No release object existed for v0.1.7, so the tag was deleted on the remote and re-created on the fix commit, pushed with `--follow-tags`.
|
||||||
|
|
||||||
|
## [2026-09-27] verify | v0.1.7 published by CI after the core-fork fix
|
||||||
|
|
||||||
|
Second tag build (pioarduino core fork in the workflow) succeeded: release `v0.1.7` on Gitea at 18:28 with `firmware.bin` (1,722,464 B), `firmware.elf`, `manifest.txt` (target patrol-a, sha256 `a2949644…4c09`, ECDSA sig), built from `8e739fa`. Off-device check: downloaded binary's SHA-256 and size match the manifest. The bench board (dev build on COM14) could not `ota check` — Wi-Fi off and no saved network at that moment — so the first on-device install of v0.1.7 is the user's, from Settings → Updates. Expected on the board: "Version v0.1.7 is available", install with the screen lit and the progress bar, restart, `A v0.1.7` bottom-right; the Updates page then says up to date.
|
||||||
|
|
||||||
|
|
||||||
|
## [2026-09-27] update | Inst. Cluster updates from A's screen: link_peer, two-way maintenance frames, Updates page with two cards
|
||||||
|
|
||||||
|
Implemented A's half of B's OTA (design in B's wiki `controller-b-ota`). Shared `automotive_data.h` (+ new `link_secure.h`, both byte-identical in the two repos): `STATUS` 0x03 B → A, `PAIR` 0x04 A → B wire-only, `SECURE` 0x05 A → B (AES-256-GCM under the pairing key; inner `OTA_CMD` / `WIFI_CREDS`), `PACKET_MAX_PAYLOAD` 64 → 160, `PACKET_VERSION` unchanged (DATA/CONFIG bytes identical). New `src/modules/link_peer.cpp`: pairing key in NVS `linkpeer`, `link pair` sends the key ×3 over UART1 only (`UARTManager::sendWire()`), B's STATUS kept + logged, automatic push of the remembered Wi-Fi network to B (hash-compared, ≥ 15 s apart, FORGET when A forgets), `requestCheck/requestInstall` for the screen behind `Ota::isParked()` + A on Wi-Fi. `EspNowLink` gained a receive callback (IDF 5.5 `esp_now_recv_info_t`) and `sendTo()`; `WiFiManager::getSavedCredentials()` (for LinkPeer only, never printed). Settings → Updates rebuilt as two cards (Main CTRL / Inst. Cluster) that fit the 484 px page without scrolling. Bench: B heard within seconds (`link status`: MAC, `dev`, heap 234 KB), refusals correct; `link pair` cannot be confirmed because **no wire is connected on the bench** (B reports `uart silent`). Build notes: `pio` from PowerShell only (idf_tools refuses MSYS); first build after the B project reinstalls Arduino 3.3.3 and may fail once with a `TypeError` - rerun.
|
||||||
|
|
||||||
|
## [2026-09-27] verify | Inst. Cluster updated from A's console, end to end (details in B's wiki log)
|
||||||
|
|
||||||
|
With the wire connected: pairing, credential push, check and install of B's first signed release `v0.1.0` all worked from A's `link` console; B rebooted and confirmed. A's side needed one cosmetic fix (missing separator in the "Inst. Cluster update: failed - <reason>" log line), rebuilt and flashed COM14. Left for the user: tap Check / Install on the Inst. Cluster card of Settings → Updates on the next B release and watch B's progress line.
|
||||||
|
|
||||||
|
## [2026-09-27] update | Wi-Fi chip and blinking alert banner on every screen; Driveline reds
|
||||||
|
|
||||||
|
User: show Wi-Fi on every screen (top-right) and give a sense of urgency when a threshold is crossed. New `status_overlay.cpp` on `lv_layer_top()`: Wi-Fi chip (fixed 150 px, LONG_DOT) top-right on all three screens - the shared header's back button moved 160 px left to make room; alert banner top-centre, red blinking at 2 Hz (colour toggle from tick, no lv_anim) naming the value (`COOLANT 104 °C HOT`, `GEARBOX OIL ...`, `GEAR MISMATCH`, `BATTERY 11.20 V LOW`), steady amber for `GEARBOX COOLING`; hidden with CAN off / ignition off. Driveline: chips row moved to y 60, crossed values and their titles go red (amber for cooling), gear mismatch turns the hero ring and gear letter red and the separate mismatch label is gone. Built and flashed COM14. Untested visually and untestable on the bench (alerts need CAN frames) - user to look at the car.
|
||||||
|
|
||||||
|
## [2026-09-28] update | No invented data: A starts with nothing valid and forgets everything when the bus stops
|
||||||
|
|
||||||
|
User: "if there is no info from CAN bus, no values should be shown". Until now `UARTManager::initializeDefaultData()` seeded 89.0 / 85.0 degC and 12.45 V with their valid flags SET, so a bench B (and a car with CAN off) showed plausible fake readings. Now the shared structure starts zeroed with `valid_flags = 0` and lever UNKNOWN; every field is valid only after a CAN frame filled it. `can_driver.cpp` gained `clearSharedData()`, called on CAN stop and on the bus-silence timeout (which already stopped the link) so stale values never come back marked valid. The `DEFAULT_*` block left the shared header (copied to B, `cmp`-identical). Driveline and B already key everything off the valid flags, so they show `--` / hidden needles. Flashed COM14; B's RX log now shows `Valid:0x00`. Released as v0.1.9 (v0.1.8, tagged minutes earlier, still carries the defaults - do not install it).
|
||||||
|
|
||||||
|
## [2026-09-28] update | Boards renamed Main CTRL / Inst. Cluster; "Sleep when the car is off" switch
|
||||||
|
|
||||||
|
User renamed Controller A → **Main CTRL** and Controller B → **Inst. Cluster** across both repos (comments, UI text, workflow names, wiki) and reworded the Updates page; committed here together with the sleep feature. New `power_manager.cpp` + Settings → System switch (NVS `sleep_en`, default OFF), see [[sleep-when-parked]]: deep sleep after 60 s of quiet CAN bus + idle touch + no update job, wake on CAN RX GPIO 16 (ext0, pull-up, TWAI stopped first). The switch travels to the Inst. Cluster as bit 7 of `out_enable` in CONFIG (no version bump). Console `sleep status | on | off | now`. Bench lesson the same evening: the switch was turned on with CAN on and no bus, so the Main CTRL slept a minute later and its USB-CDC port vanished (a deep-sleeping S3 has no USB) - only the reset button or a power cycle brings it back; touching the screen within the minute keeps it awake. Inst. Cluster side verified (see its log): sleep at 60 s of link silence, timer wake after exactly 60 s, 4 s probe with the panel dark, sleep again.
|
||||||
|
|
||||||
|
## [2026-09-28] update | Deep-sleep feature REMOVED (user decision) - and the lesson it left
|
||||||
|
|
||||||
|
The "Sleep when the car is off" switch and both power managers are gone: code, Settings row, NVS key, the `CFG_SLEEP_WHEN_SILENT` bit in the shared header, the wiki page and the cheat-sheet entries. Reason: on the bench the Main CTRL's panel showed flickering white edges after a sleep, and it stayed that way through resets and even a USB flash of release v0.1.8. Cause, understood too late: `gpio_hold_en()` on the 20 RGB panel lines (added to blank the panel in sleep) lives in the RTC domain and **survives every reset except a power cycle** - no firmware without a matching `gpio_hold_dis()` at boot can drive the panel again. Only pulling the power clears it. **Rule for the future: never use GPIO hold / deep-sleep hold on this board's panel lines, and never send a board to deep sleep from the console without the user's go-ahead** (the USB port vanishes and only reset or power brings it back). The boards stay awake whenever powered; if power saving is ever wanted again, do it in hardware (ignition-switched supply).
|
||||||
|
|
||||||
|
## [2026-09-29] update | Diff-lock inputs on DI0 / DI1
|
||||||
|
|
||||||
|
The user wants the two Patrol diff locks (+12 V while locked; the front only locks after the rear) shown on the Main CTRL. From the schematic: DI0 = CH422G EXIO0, DI1 = EXIO5, active low behind PC814. The CH422G's IO0-7 are one all-in/all-out bank shared with touch reset, backlight and LCD reset, so the firmware flips the bank to input for about 0.1 ms per read, 4 Hz. It is behind a Settings switch, default OFF, until tried on the bench for flicker. New page [[diff-lock-inputs]]; the schematic source page now carries the input circuit and the EXIO net table.
|
||||||
|
|
||||||
|
## [2026-09-29] update | Diff-lock polarity is inverted in the car
|
||||||
|
|
||||||
|
In the car the Driveline showed locked while unlocked and open while locked; the bench (12 V = locked) had been right. The likely cause is the ground-switched dash lamps (unverified). Added a per-board polarity setting: the "Inverted" switch in the Settings diff-lock row and `difflock invert on|off`, NVS `difflock_inv`. [[diff-lock-inputs]] is corrected.
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ updated: 2026-09-22
|
|||||||
|
|
||||||
# CANNY 5.3 pico vs ESP32-S3: driving the Patrol cluster
|
# CANNY 5.3 pico vs ESP32-S3: driving the Patrol cluster
|
||||||
|
|
||||||
Why the user's old CANNY-based setup moves the Patrol tach and our ESP32 (Controller B, IO7) does not. Researched 2026-09-22 after the first in-car test of the dual-controller rig: temp needle parked mid-scale, tach dead ([[dual-controller-architecture]]).
|
Why the user's old CANNY-based setup moves the Patrol tach and our ESP32 (Inst. Cluster, IO7) does not. Researched 2026-09-22 after the first in-car test of the dual-controller rig: temp needle parked mid-scale, tach dead ([[dual-controller-architecture]]).
|
||||||
|
|
||||||
## The working reference setup `(verified)`
|
## The working reference setup `(verified)`
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ ESP32 IOx ──[R ~1k]── G/B N-MOSFET (logic-level, e.g. 2N7002/AO3400) o
|
|||||||
- If the cluster input turns out to have no internal pull-up, add an external ~4.7–10 kΩ to +12 V.
|
- If the cluster input turns out to have no internal pull-up, add an external ~4.7–10 kΩ to +12 V.
|
||||||
- On hand (2026-09-22): a **2SK3069** (N-ch, 60 V / 75 A, 4 V-drive class) — hugely oversized but suitable; planned for the tach channel with 220 Ω gate series + 10 kΩ gate pulldown `(source: alltransistors.com 2SK3069)`.
|
- On hand (2026-09-22): a **2SK3069** (N-ch, 60 V / 75 A, 4 V-drive class) — hugely oversized but suitable; planned for the tach channel with 220 Ω gate series + 10 kΩ gate pulldown `(source: alltransistors.com 2SK3069)`.
|
||||||
- **Never** connect the 12 V-pulled gauge line directly to an ESP32 pin, including in open-drain mode — the pin is not 12 V tolerant.
|
- **Never** connect the 12 V-pulled gauge line directly to an ESP32 pin, including in open-drain mode — the pin is not 12 V tolerant.
|
||||||
- Grounds must be common: cluster GND ↔ Controller B GND.
|
- Grounds must be common: cluster GND ↔ Inst. Cluster GND.
|
||||||
|
|
||||||
## Open items
|
## Open items
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
---
|
||||||
|
type: concept
|
||||||
|
tags: [hardware, patrol, inputs, ch422g, wiring]
|
||||||
|
updated: 2026-09-29
|
||||||
|
---
|
||||||
|
|
||||||
|
# Diff-lock inputs (DI0 rear, DI1 front)
|
||||||
|
|
||||||
|
The Patrol has two differential locks. The user first described the wires as carrying **+12 V while a diff is locked**. In the car, the screen then showed the opposite (verified by the user, 2026-09-29): the wires carry current while unlocked and none once locked.
|
||||||
|
|
||||||
|
> [!warning] Polarity in the car is inverted
|
||||||
|
> On the bench, 12 V on DI0 showed locked (verified). In the car, the same firmware showed locked while unlocked and open while locked (verified, 2026-09-29). The likely cause is the usual lamp wiring: the dash lamp is fed +12 V and the diff's position switch grounds it on lock. A wire tapped between the lamp and the switch then sits at about 12 V through the lamp filament while unlocked, and at 0 V once the switch closes `(unverified: wiring not traced)`. Fix: the per-board **Inverted** switch (Settings → System, diff-lock row) or `difflock invert on` `(repo)`. With it on, a broken wire reads as *locked*, which shows up as amber, not as a silent "open".
|
||||||
|
|
||||||
|
The front can only be locked after the rear, so the valid states are: none, rear only, rear + front (source: user). The Main CTRL shows them on the Driveline screen from its two isolated inputs.
|
||||||
|
|
||||||
|
## Wiring
|
||||||
|
|
||||||
|
| Terminal (16-way block) | Connect to |
|
||||||
|
|---|---|
|
||||||
|
| `DI0` | rear diff-lock wire (in the car: 12 V = UNlocked, so turn Inverted on) |
|
||||||
|
| `DI1` | front diff-lock wire (same) |
|
||||||
|
| `DI_COM` | vehicle ground (chassis, same ground as the board's `GND`) |
|
||||||
|
|
||||||
|
This is Waveshare's "PNP wet input / high-level trigger" wiring: `DI_COM` to the negative pole, 5–36 V DC on the input (source: [[esp32-s3-touch-lcd-5b-waveshare-wiki]]). Tap the wires in parallel with whatever the Patrol already drives with them (dash lamp); each input draws only ~3 mA.
|
||||||
|
|
||||||
|
## Circuit (source: [[esp32-s3-touch-lcd-5-schematic]], sheet 1, "DI/DO")
|
||||||
|
|
||||||
|
- `DINx` → PC814 LED (bidirectional, so polarity does not matter) → 3.6 kΩ (R78 / R73, 1206) → `DI_COM`. At 12 V: (12 − 1.2) / 3.6 k ≈ **3.0 mA**; at 14.4 V charging ≈ 3.7 mA.
|
||||||
|
- 100 nF across each input (C100 / C101) filters spikes.
|
||||||
|
- `DI_COM` is also fed from 5 V through D4 (1N5822) + R79 220 Ω. That is what makes the "dry contact" mode work (`DI_COM` left open, the input switched to ground). With `DI_COM` on ground, as here, that path draws ~20 mA from the board's 5 V rail `(unverified: read from the schematic, not measured)`.
|
||||||
|
- Output side: the phototransistor pulls `DI0` / `DI1` (4.7 kΩ to 3V3) **low** while current flows. `DI0` = CH422G **EXIO0**, `DI1` = **EXIO5** (net table on the same sheet). So **locked = bit reads 0**.
|
||||||
|
|
||||||
|
## How the firmware reads them `(repo)`
|
||||||
|
|
||||||
|
The CH422G's IO0–7 are **one bank, all inputs or all outputs**, and the same bank drives touch reset (EXIO1), backlight (EXIO2) and LCD reset (EXIO3). The firmware switches the bank to input for about 0.1 ms per read (three I2C transactions: WR_SET 0x00, read, WR_SET 0x01), 4 times a second, under the LVGL lock. The chip keeps its output latch, so the outputs return to their previous levels. Another project does the same on a running display (source: github.com/VaAndCob/waveshare-esp32-s3-5inch-ch422g-driver, `EX_Read()`).
|
||||||
|
|
||||||
|
> [!warning] Not yet verified on this board
|
||||||
|
> Whether the 0.1 ms float disturbs the panel (flicker) or touch is **unknown** until tried. That is why the feature sits behind **Settings → System → Diff lock inputs**, default OFF. A board without the wiring never flips the bank. If the panel flickers with the switch on, turn it off. The fallback is to move the inputs to spare GPIOs on the Inst. Cluster.
|
||||||
|
|
||||||
|
A state counts after two equal reads, so it can lag the real switch by up to 0.5 s. The Driveline draws a top view of the chassis, after the user's sketch. A locked axle turns amber: axle, tyres filled, and an X on the diff. There is no text; the drawing alone carries the state (user, 2026-09-29). Front locked without rear turns the front axle red, as a wiring or switch fault (verified on the bench by the user, 2026-09-29, with the earlier pill display: DI1 alone showed red, both inputs showed amber).
|
||||||
|
|
||||||
|
## Test on the bench
|
||||||
|
|
||||||
|
1. Settings → System → Diff lock inputs ON. The row's sub-line shows "Now: both open".
|
||||||
|
2. Put 12 V (the board's own VIN supply) on `DI0`, with `DI_COM` on `GND`. It should show "rear LOCKED", and the rear axle in the Driveline chassis drawing turns amber with an X on the diff. Then do the same on `DI1`.
|
||||||
|
3. Console: `difflock status` prints the raw IO byte: bit 0x01 (rear) and bit 0x20 (front) are SET while open, clear while locked.
|
||||||
|
4. Watch the panel for flicker while the switch is on (see the warning above).
|
||||||
|
|
||||||
|
## Related
|
||||||
|
|
||||||
|
[[esp32-s3-touch-lcd-5b]] · [[esp32-s3-touch-lcd-5-schematic]] · [[patrol-instrument-cluster]]
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
type: concept
|
type: concept
|
||||||
tags: [architecture, uart]
|
tags: [architecture, uart]
|
||||||
updated: 2026-09-21
|
updated: 2026-09-27
|
||||||
---
|
---
|
||||||
|
|
||||||
# Dual-Controller Architecture
|
# Dual-Controller Architecture
|
||||||
@@ -9,23 +9,27 @@ updated: 2026-09-21
|
|||||||
The system is two ESP32-S3 boards linked by UART **and ESP-NOW** (repo, protocol v2 since 2026-09-21):
|
The system is two ESP32-S3 boards linked by UART **and ESP-NOW** (repo, protocol v2 since 2026-09-21):
|
||||||
|
|
||||||
```
|
```
|
||||||
BMW M57N CAN bus ──▶ Controller A ──UART1 + ESP-NOW, 5 Hz──▶ Controller B ──▶ Patrol tach + temp gauge
|
BMW M57N CAN bus ──▶ Main CTRL ──UART1 + ESP-NOW, 5 Hz──▶ Inst. Cluster ──▶ Patrol tach + temp gauge
|
||||||
(this repo: (ESP32-S3-LCD-1.3,
|
(this repo: (ESP32-S3-LCD-1.3,
|
||||||
5" 1024×600 display) 1.3" round display, gauge outputs)
|
5" 1024×600 display) 1.3" round display, gauge outputs)
|
||||||
```
|
```
|
||||||
|
|
||||||
- **Controller A** — [[esp32-s3-touch-lcd-5b]]: listens to the CAN bus, renders the main UI, and re-broadcasts a compact sensor packet over UART1 (GPIO 43/44, 115200 baud) at 5 Hz.
|
- **Main CTRL** — [[esp32-s3-touch-lcd-5b]]: listens to the CAN bus, renders the main UI, and re-broadcasts a compact sensor packet over UART1 (GPIO 43/44, 115200 baud) at 5 Hz.
|
||||||
- **Controller B** — ESP32-S3-Touch-LCD-1.3: a secondary display fed purely by that UART stream. Lives in a sibling repo (`bmw-patrol/` parent directory).
|
- **Inst. Cluster** — ESP32-S3-Touch-LCD-1.3: a secondary display fed purely by that UART stream. Lives in a sibling repo (`bmw-patrol/` parent directory).
|
||||||
|
|
||||||
## Link protocol v2 (repo, 2026-09-21)
|
## Link protocol v2 (repo, 2026-09-21)
|
||||||
|
|
||||||
`0xAA | 0x02 | type | length | payload | XOR | 0x55`, identical on UART1 (GPIO 44 → SP3485 → `485_A`/`485_B`) and ESP-NOW broadcast (channel 1). DATA frames (lever, target/engaged gear nibbles, rpm, temps, battery, alert bitmap, valid flags) every 200 ms; CONFIG frames (`link_config_t`: Patrol gauge calibration + alert thresholds, edited on A via the `cfg` serial console and stored in NVS) on change and every 5 s. Alerts are decided here; B only renders them. Spec: `docs/UART_PROTOCOL.md`. Bench-verified with both transports live and B deduplicating every frame `(verified 2026-09-21)`.
|
`0xAA | 0x02 | type | length | payload | XOR | 0x55`, identical on UART1 (GPIO 44 → SP3485 → `485_A`/`485_B`) and ESP-NOW broadcast (channel 1). DATA frames (lever, target/engaged gear nibbles, rpm, temps, battery, alert bitmap, valid flags) every 200 ms; CONFIG frames (`link_config_t`: Patrol gauge calibration + alert thresholds, edited on A via the `cfg` serial console and stored in NVS) on change and every 5 s. Alerts are decided here; B only renders them. Spec: `docs/UART_PROTOCOL.md`. Bench-verified with both transports live and B deduplicating every frame `(verified 2026-09-21)`.
|
||||||
|
|
||||||
Controller B's side of this (receiver, ESP-NOW channel hopping, gauge outputs, bench wiring) is documented in the sibling wiki: `../../ESP32-S3-LCD-1.3/wiki/pages/controller-link.md` and `patrol-gauge-outputs.md`.
|
**ESP-NOW and Wi-Fi share the radio** `(verified 2026-09-26)`. When A joins a Wi-Fi network (for OTA), its channel follows the AP (seen: 6, 9, 11) and B hops to find it; ESP-NOW kept running (6,410 frames, 0 failed). Until 2026-09-26 the Wi-Fi code powered the radio off on connect/disconnect (`WiFi.disconnect(true)`), which silently killed ESP-NOW and left B on the wire only — fixed, and `EspNowLink::send()` now re-initialises ESP-NOW if the driver drops it. Planned: **Inst. Cluster's firmware updates will travel from A over ESP-NOW** (bidirectional, unlike the one-way wire) → [[ota-updates]].
|
||||||
|
|
||||||
|
**A keeps the ESP-NOW channel stable (v0.1.5, 2026-09-27)** `(repo)`: Wi-Fi auto-reconnect is off. A tries the remembered network once at boot and once after a drop, then parks the radio back on channel 1 — an endless reconnect (e.g. driving away from home Wi-Fi) would keep hopping channels under the link to B. Scans happen only when someone opens the Wi-Fi page or taps Scan.
|
||||||
|
|
||||||
|
Inst. Cluster's side of this (receiver, ESP-NOW channel hopping, gauge outputs, bench wiring) is documented in the sibling wiki: `../../ESP32-S3-LCD-1.3/wiki/pages/controller-link.md` and `patrol-gauge-outputs.md`.
|
||||||
|
|
||||||
## Why it matters for the wiki
|
## Why it matters for the wiki
|
||||||
|
|
||||||
Any change to what data we extract from the [[can-bus-integration]] ripples into this packet **and** into Controller B's parser — both ends must move together: edit `include/protocol/automotive_data.h` here, bump `PACKET_VERSION`, copy the header byte-identical to B (B rejects other versions).
|
Any change to what data we extract from the [[can-bus-integration]] ripples into this packet **and** into Inst. Cluster's parser — both ends must move together: edit `include/protocol/automotive_data.h` here, bump `PACKET_VERSION`, copy the header byte-identical to B (B rejects other versions).
|
||||||
|
|
||||||
## Related
|
## Related
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
---
|
---
|
||||||
type: entity
|
type: entity
|
||||||
tags: [hardware, waveshare, display]
|
tags: [hardware, waveshare, display]
|
||||||
updated: 2026-07-16
|
updated: 2026-09-27
|
||||||
---
|
---
|
||||||
|
|
||||||
# Waveshare ESP32-S3-Touch-LCD-5B
|
# Waveshare ESP32-S3-Touch-LCD-5B
|
||||||
|
|
||||||
Controller A of the [[dual-controller-architecture]] — the main in-cabin display. SKU 28151, the 1024×600 capacitive-touch variant of the LCD-5 family. Primary reference: [[esp32-s3-touch-lcd-5b-waveshare-wiki]].
|
Main CTRL of the [[dual-controller-architecture]] — the main in-cabin display. SKU 28151, the 1024×600 capacitive-touch variant of the LCD-5 family. Primary reference: [[esp32-s3-touch-lcd-5b-waveshare-wiki]].
|
||||||
|
|
||||||
## Specs (source: waveshare-wiki)
|
## Specs (source: waveshare-wiki)
|
||||||
|
|
||||||
- ESP32-S3-WROOM-1-N16R8 module: dual-core LX7 @ 240 MHz, 16 MB flash, 8 MB OPI PSRAM
|
- ESP32-S3-WROOM-1-N16R8 module: dual-core LX7 @ 240 MHz, 16 MB flash, 8 MB OPI PSRAM
|
||||||
- 5" IPS 1024×600, 65K colors (16-bit), 550 cd/m², GT911 5-point capacitive touch, tempered glass
|
- 5" IPS 1024×600, 65K colors (16-bit), 550 cd/m², GT911 5-point capacitive touch, tempered glass
|
||||||
- 2.4 GHz Wi-Fi + BLE 5, onboard antenna (keep metal away from antenna area)
|
- 2.4 GHz Wi-Fi + BLE 5, onboard antenna (keep metal away from antenna area)
|
||||||
- Runs LVGL 8.4.0 at ~50 FPS via ESP32_Display_Panel v1.0.4 `(repo)`
|
- Runs LVGL 8.4.0 via ESP32_Display_Panel v1.0.4 `(repo)`. Real render FPS has **never been measured**: the Debug-panel "FPS" counts `loop()` passes (and `loop()` sleeps 100 ms), and the old "~50 FPS" figure had no measurement behind it `(verified 2026-09-26)`
|
||||||
|
|
||||||
## Power (source: waveshare-wiki)
|
## Power (source: waveshare-wiki)
|
||||||
|
|
||||||
@@ -21,6 +21,8 @@ Controller A of the [[dual-controller-architecture]] — the main in-cabin displ
|
|||||||
- Alternative inputs: USB Type-C 5 V; optional single-cell 3.7 V LiPo (CS8501 charge/boost, 580 mA)
|
- Alternative inputs: USB Type-C 5 V; optional single-cell 3.7 V LiPo (CS8501 charge/boost, 580 mA)
|
||||||
- Draw: ~450 mA @ 5 V (~2.3 W)
|
- Draw: ~450 mA @ 5 V (~2.3 W)
|
||||||
- Remaining caveat: automotive transient/load-dump spikes (ISO 7637) can exceed 36 V `(unverified)` → [[open-questions]]
|
- Remaining caveat: automotive transient/load-dump spikes (ISO 7637) can exceed 36 V `(unverified)` → [[open-questions]]
|
||||||
|
- **Power path** (source: [[esp32-s3-touch-lcd-5-schematic]]): VIN → 1N5822 reverse diode + SMAJ36CA TVS → SY8293 buck (2 A, "run the line at 2A") → 5 V rail → 3.3 V LDO. Screen alone ≈550 mA @ 5 V.
|
||||||
|
- **VOUT terminal = `I2C_VCC`, selected by solder jumper `H8`** (pad 1 = 3V3, pad 2 = VOUT, pad 3 = 5V; factory bridge 1–2 = 3.3 V). For 5 V: open 1–2, bridge 2–3, never all three. The external SDA/SCL are level-shifted (NDC7002N + 4.7 kΩ pull-ups to `I2C_VCC`), so the I2C lines follow. Headroom for a load on VOUT@5 V from the 12 V input ≈1 A `(unverified estimate)` — enough to power Inst. Cluster. Not on USB-only power.
|
||||||
|
|
||||||
> [!warning] Operating temperature 0–65 °C (source: waveshare-wiki)
|
> [!warning] Operating temperature 0–65 °C (source: waveshare-wiki)
|
||||||
> Tight for a car: sub-zero winters and sun-baked dashboards both fall outside spec. → [[open-questions]]
|
> Tight for a car: sub-zero winters and sun-baked dashboards both fall outside spec. → [[open-questions]]
|
||||||
@@ -37,12 +39,12 @@ Controller A of the [[dual-controller-architecture]] — the main in-cabin displ
|
|||||||
|
|
||||||
| Interface | Details |
|
| Interface | Details |
|
||||||
|-----------|---------|
|
|-----------|---------|
|
||||||
| RS485 | SP3485, auto TX/RX direction; terminal block used for UART1 → Controller B, GPIO 43/44, 115200 baud `(repo)` |
|
| RS485 | SP3485, auto TX/RX direction; terminal block used for UART1 → Inst. Cluster, GPIO 43/44, 115200 baud `(repo)` |
|
||||||
| Isolated I/O | Optocoupler digital in 5–36 V (dry/wet contact), open-drain out sinking 450 mA/ch — could read ignition-on or drive a relay later |
|
| Isolated I/O | Optocoupler digital in 5–36 V (dry/wet contact), open-drain out sinking 450 mA/ch — could read ignition-on or drive a relay later |
|
||||||
| I2C | External header; CH422G expander occupies 0x20–0x27 & 0x30–0x3F, GT911 touch at 0x5D — avoid these addresses |
|
| I2C | Terminal block SDA/SCL, level-shifted to `I2C_VCC` (= VOUT, 3.3 V or 5 V via `H8`); CH422G expander occupies 0x20–0x27 & 0x30–0x3F, GT911 touch at 0x5D — avoid these addresses |
|
||||||
| RTC | PCF85063 + CR927 coin cell |
|
| RTC | PCF85063 + CR927 coin cell |
|
||||||
| TF card | SD_CS driven via CH422G EXIO4 |
|
| TF card | SPI: MOSI IO11, SCK IO12, MISO IO13; SD_CS via CH422G EXIO4 (source: schematic) |
|
||||||
| USB Serial | UART0, debug @ 115200 `(repo)` |
|
| USB Serial | Native USB-CDC (`Serial`, enumerates 303A:1001, ~1 MB/s), console + CANRAW `(repo)`. **Opening the port with default DTR/RTS resets the board** (`rst:0x15`) — set both low before opening (`--dtr 0 --rts 0`) to attach without a reboot `(verified 2026-09-26)` |
|
||||||
|
|
||||||
Note: the screen occupies most GPIOs; auxiliary functions (backlight, reset, SD_CS) route through the CH422G IO expander — spare native GPIOs are scarce.
|
Note: the screen occupies most GPIOs; auxiliary functions (backlight, reset, SD_CS) route through the CH422G IO expander — spare native GPIOs are scarce.
|
||||||
|
|
||||||
@@ -52,7 +54,23 @@ Note: the screen occupies most GPIOs; auxiliary functions (backlight, reset, SD_
|
|||||||
- LCD wants a 16 MHz pixel clock with correct PCLK polarity.
|
- LCD wants a 16 MHz pixel clock with correct PCLK polarity.
|
||||||
- Backlight must be manually sequenced at boot to avoid a white flash.
|
- Backlight must be manually sequenced at boot to avoid a white flash.
|
||||||
- Flashing: use the Type-C port labeled UART; hold BOOT while connecting if the port isn't recognized (source: waveshare-wiki).
|
- Flashing: use the Type-C port labeled UART; hold BOOT while connecting if the port isn't recognized (source: waveshare-wiki).
|
||||||
|
- **Flash writes flicker the screen** `(verified 2026-09-26)`: flash and PSRAM share the MSPI cache, so every flash write/erase (NVS save, OTA) briefly cuts off the PSRAM framebuffer that the bounce-buffer refill copies from (the "no bounce buffer" claim written here earlier was wrong — see 2026-09-27). `CONFIG_LCD_RGB_RESTART_IN_VSYNC=y` resyncs next frame → flicker, not permanent drift. Mitigated (v0.1.2): Tuning edits saved to NVS once after 3 s idle, backlight off during OTA writes. Real cure: bounce buffers + `CONFIG_SPIRAM_XIP_FROM_PSRAM` → [[open-questions]] #13.
|
||||||
|
- **Full-screen transitions stutter** `(verified 2026-09-26)`: a fade re-renders and alpha-blends all 614k px in software every frame into the PSRAM framebuffer. Screen switches are instant (`LV_SCR_LOAD_ANIM_NONE`) since v0.1.2.
|
||||||
|
- **Internal RAM was nearly full** `(verified 2026-09-26)`: 15.9 KB free, largest block 7.6 KB with display + Wi-Fi up. Half the cause was LVGL's own 48 KB widget pool (`LV_MEM_SIZE`) sitting in internal `.bss`. **Moved to PSRAM and enlarged to 512 KB (2026-09-27)**: internal free now **69 KB, largest block 31.7 KB** `(verified)`. The 60-line LVGL draw buffer (~120 KB) is still internal, by design (render speed).
|
||||||
|
- **LVGL's widget pool ran out** `(verified 2026-09-27)`: Settings + its Wi-Fi list is ~15 KB; screen churn + list rebuilds took the 48 KB pool to 87% used / 31% fragmented / 4.5 KB biggest block, then a label draw failed `lv_mem_buf_get()` (backtrace decoded with addr2line). With the 512 KB PSRAM pool: 10 Settings visits + 9 list rebuilds, peak 4%, 0 crashes; swipes feel better (user).
|
||||||
|
- **LVGL asserts used to freeze the board**: `LV_ASSERT_HANDLER` was `while(1);`, which spins inside the calling task *while it holds the LVGL lock* — UI frozen, `loop()`/console blocked on the lock, only the link task alive. Now `abort()`: backtrace on the console, core dump to flash (ELF), reboot. Decode with `xtensa-esp32s3-elf-addr2line -pfiaC -e firmware.elf <addrs>` (CI attaches `firmware.elf` to every release).
|
||||||
|
- **Background Wi-Fi scans caused the random flickering dots** `(verified by elimination 2026-09-27)`: the Wi-Fi task scanned every 10 s forever, connected or not, on any screen; Wi-Fi buffers live in PSRAM next to the framebuffer. Scanning is now limited to "network list on screen and not connected" — the dots are gone (user).
|
||||||
|
- **The dots came back on v0.1.4, gone on v0.1.5** `(verified 2026-09-27, user)`: v0.1.4 limited scans to "Settings open and not connected", but it forgot the network on every restart, so after the OTA restart it sat disconnected and rescanned every 10 s whenever Settings was open. v0.1.5 remembers the network and scans only when the Wi-Fi page opens or Scan is tapped. The underlying weakness remains: the RGB panel streams from PSRAM with no bounce buffer, so heavy Wi-Fi or flash traffic can still disturb the picture ([[open-questions]] #13).
|
||||||
|
- **Panel refresh rate ≈ 24 Hz** `(verified 2026-09-27, perf vsync counter)`: **21 MHz** pixel clock (board header, not the 16 MHz once written here) over 1368 × 637 clocks incl. porches → 24.1 Hz; one frame = 41.5 ms. **Bounce buffers are on**: 2 × 10 lines (20 KB each, internal DMA RAM) set by the library's `BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_5_B.h`; the `platformio.ini` flag that said 0 was a dead name (removed 2026-09-27). A steady 41.5 ms longest-gap in `perf` means no DMA restart happened in that window; anything ≥ 83 ms is a dropped frame.
|
||||||
|
- **Idle screens must render nothing** `(verified 2026-09-27)`: the Driveline tick used to re-set every label at 10 Hz, costing a third of core 1 and 52 ms/s of PSRAM writes with constant data; writing only on change took it to 0 fps / 96 % idle → [[perf-baseline-2026-09-27]].
|
||||||
|
- **XIP from PSRAM cures the flash-write blanking** `(verified 2026-09-27, branch display-xip)`: with `CONFIG_SPIRAM_XIP_FROM_PSRAM` + `CONFIG_LCD_RGB_ISR_IRAM_SAFE` the panel kept 24 frames/s and a 41.5 ms gap through a whole OTA download (stock core: 4–8 frames/s). Costs ~1.7 MB of PSRAM for resident code and a core rebuild (`custom_sdkconfig`) → [[perf-xip-ota-2026-09-27]].
|
||||||
|
- **Dots are not dropped frames** `(verified 2026-09-27)`: with dots visible on an idle Driveline the panel completed 24 frames/s with a 41.5 ms gap — they are sub-frame FIFO underruns (a few wrong pixels, frame still on time), which the driver cannot detect; bounce buffers are the fix. **OTA collapses the panel to 4–8 frames/s** (gaps to 0.75 s) for the whole download → [[perf-dots-and-ota-2026-09-27]].
|
||||||
|
- **The dots are NOT fully gone** `(user, 2026-09-27)`: they still appear occasionally on v0.1.6 with scans limited — so scan policy only reduced the trigger; the PSRAM-streaming weakness itself is what shows. Structural fix (bounce buffers, then XIP-from-PSRAM) is now a committed job, not a nice-to-have → [[open-questions]] #13.
|
||||||
|
- **SquareLine's screen lifecycle was the freeze risk, not LVGL**: its generated screens are deleted on leave and rebuilt on entry, so any pointer kept elsewhere dangles. Since 2026-09-27 every screen is hand-coded, built once and kept `(repo)`.
|
||||||
|
- **Uploading over USB from a script on Windows**: esptool crashed printing its progress bar into a cp1252 pipe *in the middle of writing* and left the board frozen until a power cycle; the bootloader then fell back to the other OTA slot, so nothing was lost `(verified 2026-09-27)`. Set `PYTHONIOENCODING=utf-8` when piping upload output.
|
||||||
|
- **Never power the Wi-Fi radio off** (`WiFi.disconnect(true)`, `WiFi.mode(WIFI_OFF)`): it de-initialises ESP-NOW, the wireless leg of the link to B → [[dual-controller-architecture]].
|
||||||
|
- **Partition table is dual-slot OTA** since 2026-09-26 (2 × 7.9 MB, no SPIFFS, NVS offset unchanged) → [[ota-updates]].
|
||||||
|
|
||||||
## Related
|
## Related
|
||||||
|
|
||||||
[[dual-controller-architecture]] · [[can-bus-integration]] · [[esp32-s3-touch-lcd-5b-waveshare-wiki]]
|
[[dual-controller-architecture]] · [[can-bus-integration]] · [[ota-updates]] · [[esp32-s3-touch-lcd-5b-waveshare-wiki]] · [[esp32-s3-touch-lcd-5-schematic]]
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ updated: 2026-09-23
|
|||||||
|
|
||||||
# OBD / Diagnostic Polling
|
# OBD / Diagnostic Polling
|
||||||
|
|
||||||
Why some values never appear on the sniffer, how a scan tool gets them, and what it would take for Controller A to do the same. Several pages have linked here since July ([[can-id-candidates]], [[open-questions]] #7); the page was created on the [[google-ai-dde7m57-pids]] ingest, 2026-09-21.
|
Why some values never appear on the sniffer, how a scan tool gets them, and what it would take for Main CTRL to do the same. Several pages have linked here since July ([[can-id-candidates]], [[open-questions]] #7); the page was created on the [[google-ai-dde7m57-pids]] ingest, 2026-09-21.
|
||||||
|
|
||||||
## Broadcast vs polled
|
## Broadcast vs polled
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ The [[dwr-335d-torque-pids]] source is a worked, gauge-checked set of J1979 mode
|
|||||||
| `02 01 73` / `78` / `7A` / `83` | — | exhaust pressure / EGT / DPF ΔP / NOx — same caveat; DPF/SCR rows are meaningless on an M57N anyway |
|
| `02 01 73` / `78` / `7A` / `83` | — | exhaust pressure / EGT / DPF ΔP / NOx — same caveat; DPF/SCR rows are meaningless on an M57N anyway |
|
||||||
|
|
||||||
- **First test = the `01 00` bitmap query.** One frame on `0x7DF` with the engine running (no scan tool attached) answers both open points at once: does this DDE speak EOBD on the PT-CAN at all, and which PIDs does it offer. No reply → the DDE serves EOBD on K-line (or not on this bus) and only Route B remains.
|
- **First test = the `01 00` bitmap query.** One frame on `0x7DF` with the engine running (no scan tool attached) answers both open points at once: does this DDE speak EOBD on the PT-CAN at all, and which PIDs does it offer. No reply → the DDE serves EOBD on K-line (or not on this bus) and only Route B remains.
|
||||||
- **Implemented on Controller A (2026-09-21) `(repo)`** as the `diag` console command — see *Firmware: the `diag` probe* below. The whole test is `diag pids` typed on the USB console.
|
- **Implemented on Main CTRL (2026-09-21) `(repo)`** as the `diag` console command — see *Firmware: the `diag` probe* below. The whole test is `diag pids` typed on the USB console.
|
||||||
- Route A cannot give fault codes beyond generic mode `03` DTCs (P0xxx) — BMW-specific codes need Route B.
|
- Route A cannot give fault codes beyond generic mode `03` DTCs (P0xxx) — BMW-specific codes need Route B.
|
||||||
|
|
||||||
## Route B — BMW proprietary (KWP2000 on `0x6F1` → `0x612`) — **VERIFIED WORKING (2026-09-23)**
|
## Route B — BMW proprietary (KWP2000 on `0x6F1` → `0x612`) — **VERIFIED WORKING (2026-09-23)**
|
||||||
@@ -89,7 +89,7 @@ This depends on the DDE variant, which is still open ([[open-questions]] #2, [[b
|
|||||||
|
|
||||||
## Firmware: the `diag` probe `(repo, 2026-09-21)`
|
## Firmware: the `diag` probe `(repo, 2026-09-21)`
|
||||||
|
|
||||||
Controller A now has **one** transmit path onto the PT-CAN: `CANDriver::transmit()`, called only by `src/modules/diag_probe.cpp`. It sends nothing on its own; every frame is typed by a human on the USB console.
|
Main CTRL now has **one** transmit path onto the PT-CAN: `CANDriver::transmit()`, called only by `src/modules/diag_probe.cpp`. It sends nothing on its own; every frame is typed by a human on the USB console.
|
||||||
|
|
||||||
| Command | What it sends | What it prints |
|
| Command | What it sends | What it prints |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
@@ -128,7 +128,7 @@ Run via `tools/diag_session.py` (one serial session, logs straight into `wiki/ra
|
|||||||
- **The decode recipe (proven 2026-09-23):** log `CANRAW` while the Launch shows a live value → find the `2C 10 <id>` / `6C 10 <data>` pair whose data tracks the reading → calibrate scale against the display at two operating points (idle + a blip). One session per parameter. Boost, MAF, injection quantity, EGTs all reachable this way. Worked example: [[launch-capture-2026-09-23]] (rail pressure).
|
- **The decode recipe (proven 2026-09-23):** log `CANRAW` while the Launch shows a live value → find the `2C 10 <id>` / `6C 10 <data>` pair whose data tracks the reading → calibrate scale against the display at two operating points (idle + a blip). One session per parameter. Boost, MAF, injection quantity, EGTs all reachable this way. Worked example: [[launch-capture-2026-09-23]] (rail pressure).
|
||||||
- A continuous poller (Route A or B) would reuse the same transmit path with a fixed request list: one request per ≥100 ms, one identifier at a time, only while no scan tool is connected, never a session-control or write service. Still a design decision: a request storm or a malformed frame can disturb the DDE/EGS.
|
- A continuous poller (Route A or B) would reuse the same transmit path with a fixed request list: one request per ≥100 ms, one identifier at a time, only while no scan tool is connected, never a session-control or write service. Still a design decision: a request storm or a malformed frame can disturb the DDE/EGS.
|
||||||
- **What Route B self-polling actually requires (settled 2026-09-23):** just the `2C 10 15 E0` define then the `2C 10 <id>` poll — **no diagnostic session (`10`), no security access (`27`), no tester-present (`3E`)**, proven from the full Launch capture ([[launch-capture-2026-09-23]]). The `21`-block NRCs (0x22/0x33) that earlier looked like a session/security wall are a *different mechanism* and do not gate the `2C` path. `2C` is not strictly read-only (it writes a dynamic-identifier definition — harmless), so it stays out of the probe whitelist by policy.
|
- **What Route B self-polling actually requires (settled 2026-09-23):** just the `2C 10 15 E0` define then the `2C 10 <id>` poll — **no diagnostic session (`10`), no security access (`27`), no tester-present (`3E`)**, proven from the full Launch capture ([[launch-capture-2026-09-23]]). The `21`-block NRCs (0x22/0x33) that earlier looked like a session/security wall are a *different mechanism* and do not gate the `2C` path. `2C` is not strictly read-only (it writes a dynamic-identifier definition — harmless), so it stays out of the probe whitelist by policy.
|
||||||
- **Design decision — the "Diagnostics" screen (2026-09-23):** if active polling is ever built, it lives behind a **password-protected Diagnostics screen** on Controller A (authorized-technician gate), triggered manually, only while no scan tool is connected, read-oriented services only. This is the deliberate on/off switch for transmit-on-the-bus — not a background poller. Not built yet; captured here so the capability and its guard rails are not re-researched later.
|
- **Design decision — the "Diagnostics" screen (2026-09-23):** if active polling is ever built, it lives behind a **password-protected Diagnostics screen** on Main CTRL (authorized-technician gate), triggered manually, only while no scan tool is connected, read-oriented services only. This is the deliberate on/off switch for transmit-on-the-bus — not a background poller. Not built yet; captured here so the capability and its guard rails are not re-researched later.
|
||||||
- Protocol v2 dropped the `fault_codes` field in favour of the alert bitmap ([[dual-controller-architecture]]); polled values would need new DATA fields.
|
- Protocol v2 dropped the `fault_codes` field in favour of the alert bitmap ([[dual-controller-architecture]]); polled values would need new DATA fields.
|
||||||
- The same request path would also be the only way to read DTCs (service `0x18`/`0x19`, variant-dependent) → [[open-questions]] #7.
|
- The same request path would also be the only way to read DTCs (service `0x18`/`0x19`, variant-dependent) → [[open-questions]] #7.
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
type: synthesis
|
type: synthesis
|
||||||
tags: [meta, todo]
|
tags: [meta, todo]
|
||||||
updated: 2026-09-26
|
updated: 2026-09-27
|
||||||
---
|
---
|
||||||
|
|
||||||
# Open Questions
|
# Open Questions
|
||||||
@@ -24,7 +24,7 @@ The research frontier. Answering any of these should trigger updates across the
|
|||||||
|
|
||||||
## Design decisions (parked, not blocking)
|
## Design decisions (parked, not blocking)
|
||||||
|
|
||||||
12. **The "Diagnostics" screen (planned 2026-09-23).** Active diagnostic polling — replaying the `2C` live-data reads we decoded ([[launch-capture-2026-09-23]]) so values like rail pressure appear on Controller A without the Launch — is now technically unblocked (no session/security needed). Intended design when built: a **password-protected Diagnostics screen**, authorized-technician access only, manual trigger, refuses while a scan tool is connected, read-oriented services only. The same gate covers the general transmit-on-the-bus decision. This is deliberately deferred, but the capability, the byte sequences, and these guard rails are recorded so the work resumes from here, not from scratch. **Also the home of the OTA "check / install" controls (2026-09-26)** — today they are the `ota` console; the password must be stored as a salted hash in NVS because the firmware is public. → [[obd-diagnostic-polling]], [[dual-controller-architecture]], [[ota-updates]]
|
12. **The "Diagnostics" screen (planned 2026-09-23).** Active diagnostic polling — replaying the `2C` live-data reads we decoded ([[launch-capture-2026-09-23]]) so values like rail pressure appear on Main CTRL without the Launch — is now technically unblocked (no session/security needed). Intended design when built: a **password-protected Diagnostics screen**, authorized-technician access only, manual trigger, refuses while a scan tool is connected, read-oriented services only. The same gate covers the general transmit-on-the-bus decision. This is deliberately deferred, but the capability, the byte sequences, and these guard rails are recorded so the work resumes from here, not from scratch. OTA check/install was meant to live here too (2026-09-26); **decided otherwise 2026-09-27**: it is on the Settings screen behind a confirm dialog ([[ota-updates]]). Whatever password this screen gets must be stored as a salted hash in NVS because the firmware is public. → [[obd-diagnostic-polling]], [[dual-controller-architecture]], [[ota-updates]]
|
||||||
|
|
||||||
## Project context
|
## Project context
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ The research frontier. Answering any of these should trigger updates across the
|
|||||||
## Sourcing wishlist
|
## Sourcing wishlist
|
||||||
|
|
||||||
- ~~Waveshare product page~~ ✅ ingested → [[esp32-s3-touch-lcd-5b-waveshare-wiki]]
|
- ~~Waveshare product page~~ ✅ ingested → [[esp32-s3-touch-lcd-5b-waveshare-wiki]]
|
||||||
- Waveshare **schematic PDF** (linked from the product page: `ESP32-S3-Touch-LCD-5-Sch.pdf`) — would confirm CAN GPIO routing and power path
|
- ~~Waveshare **schematic PDF**~~ ✅ re-downloaded into `raw/` 2026-09-26 → [[esp32-s3-touch-lcd-5-schematic]] (VOUT/H8 selection, 5 V rail budget, SD pins)
|
||||||
- ~~A community DBC / CAN-ID list for the donor platform~~ ✅ ingested → [[e65-reverse-engineering-repo]]
|
- ~~A community DBC / CAN-ID list for the donor platform~~ ✅ ingested → [[e65-reverse-engineering-repo]]
|
||||||
- ~~A real candump log from the engine running~~ ✅ → [[can-capture-2026-07-15]] (engine confirmed running, 2026-07-17)
|
- ~~A real candump log from the engine running~~ ✅ → [[can-capture-2026-07-15]] (engine confirmed running, 2026-07-17)
|
||||||
- **`6HP26.pdf`** — sitting in the E65 repo's `docs/`. The ZF 6HP26 manual, very likely our exact gearbox: gear ratios would let us convert output-shaft rpm → road speed and self-check the D3/D4 scaling. → [[driveline-speed-signals]]
|
- **`6HP26.pdf`** — sitting in the E65 repo's `docs/`. The ZF 6HP26 manual, very likely our exact gearbox: gear ratios would let us convert output-shaft rpm → road speed and self-check the D3/D4 scaling. → [[driveline-speed-signals]]
|
||||||
@@ -70,4 +70,16 @@ The research frontier. Answering any of these should trigger updates across the
|
|||||||
- ~~A worked generic-PID set for an M57 diesel~~ ✅ ingested → [[dwr-335d-torque-pids]] (2009 335d, DDE7.3; J1979 mode-01 scalings gauge-checked by the author)
|
- ~~A worked generic-PID set for an M57 diesel~~ ✅ ingested → [[dwr-335d-torque-pids]] (2009 335d, DDE7.3; J1979 mode-01 scalings gauge-checked by the author)
|
||||||
- DWR's **Testo parameter list** (e90post "Testo" thread, post 175, German→English names of the DDE's non-standard values) — the pointer for Route B identifiers if our own Launch capture is not enough
|
- DWR's **Testo parameter list** (e90post "Testo" thread, post 175, German→English names of the DDE's non-standard values) — the pointer for Route B identifiers if our own Launch capture is not enough
|
||||||
|
|
||||||
13. **Internal RAM is nearly exhausted (found 2026-09-26).** With display + Wi-Fi up: 15.9 KB internal free, largest block 7.6 KB (PSRAM 7.1 MB free). OTA works around it ([[ota-updates]]), but anything else that needs an internal allocation (another task, a TLS client, a bigger Wi-Fi burst) can fail. Biggest known consumer: the LVGL 60-line DMA draw buffer (~120 KB). Options: shrink it to ~30–40 lines, or measure what else lives in internal RAM first (`heap_caps_print_heap_info`). Not urgent, but it limits every future feature. **Same project as the display flicker/lag (2026-09-26):** flash writes flicker the PSRAM-fed RGB panel (no bounce buffer) and full-screen transitions stutter. Espressif's cure is bounce buffers + `CONFIG_SPIRAM_XIP_FROM_PSRAM` (needs pioarduino `custom_sdkconfig`), and bounce buffers need internal RAM — so free RAM, add bounce buffers, and measure real render FPS (LVGL perf monitor; the Debug "FPS" counts `loop()` passes, not frames) in one bench session. Quick mitigations shipped in v0.1.2 (instant screen switches, deferred NVS saves, dark screen during OTA).
|
13. **Internal RAM is nearly exhausted (found 2026-09-26) — largely relieved 2026-09-27:** LVGL's 48 KB pool moved to PSRAM (512 KB) → internal free 16 → **69 KB**, largest block 7.6 → **31.7 KB**, enough for bounce buffers to be attempted. Original finding: With display + Wi-Fi up: 15.9 KB internal free, largest block 7.6 KB (PSRAM 7.1 MB free). OTA works around it ([[ota-updates]]), but anything else that needs an internal allocation (another task, a TLS client, a bigger Wi-Fi burst) can fail. Biggest known consumer: the LVGL 60-line DMA draw buffer (~120 KB). Options: shrink it to ~30–40 lines, or measure what else lives in internal RAM first (`heap_caps_print_heap_info`). Not urgent, but it limits every future feature. **Same project as the display flicker/lag (2026-09-26):** flash writes flicker the PSRAM-fed RGB panel (no bounce buffer) and full-screen transitions stutter. Espressif's cure is bounce buffers + `CONFIG_SPIRAM_XIP_FROM_PSRAM` (needs pioarduino `custom_sdkconfig`), and bounce buffers need internal RAM — so free RAM, add bounce buffers, and measure real render FPS (LVGL perf monitor; the Debug "FPS" counts `loop()` passes, not frames) in one bench session. Quick mitigations shipped in v0.1.2 (instant screen switches, deferred NVS saves, dark screen during OTA).
|
||||||
|
|
||||||
|
**Decision 2026-09-27 (user): this is a must-fix, all steps through XIP, bench time is no constraint.** Two corrections to the record: (a) the flickering dots **still appear occasionally** on v0.1.6 — the scan policy reduced the trigger, it did not remove the weakness; (b) the dark screen during OTA is a **safety/UX defect**, not a mitigation: with no feedback a driver may switch the ignition off mid-update. Requirement: the screen stays on during an update with a visible progress bar and a "do not switch off" message — which needs Step B (flash writes must stop blanking the panel), plus an OTA progress callback on the Updates page. (The OTA design already survives a power cut — the new image is only confirmed after 30 s, else it rolls back — so the risk is a wasted update and a confused user, not a bricked board.)
|
||||||
|
|
||||||
|
**Plan agreed 2026-09-27 (next display session, bench + USB, `dev` builds only until verified):**
|
||||||
|
1. **Baseline first**: Settings → System → Performance overlay (LVGL's perf monitor = real render FPS + CPU; never measured before). Provoke each symptom on purpose: a Wi-Fi scan (dots), a Tuning edit that gets saved (flash write), an update (flash writes). Without numbers there is no telling whether a change helped. **Tooling landed 2026-09-27 `(repo)`**: the `perf` console command (`perf on 1` streams a `PERF,` CSV line per second: fps, ms/frame, flush ms/s, LVGL idle, core idle, heap). **Idle baseline, Driveline screen, bench/USB, v0.1.6+perf**: 9.7 fps rendered (= the screen's own update rate), 30 ms per frame avg (122 ms worst in the first window), ~40 kpx/frame, 52 ms/s copying into the PSRAM framebuffer, LVGL idle 68 %, core 0 idle 94 %, core 1 idle 66 %, internal 66.9 KB free / 31.7 KB largest, PSRAM 6.6 MB free. **Provoke session logged 2026-09-27 → [[perf-baseline-2026-09-27]]**: Driveline redraws ~10×/s with nothing changing (39 kpx, 30 ms, a third of core 1 — an unconditional `lv_label_set_text` every 100 ms `(repo)`); screen changes are single 140–330 ms frames (= the swipe lag; not a bounce-buffer matter); the Simulation tab is the heaviest normal load (2 Mpx/s, 26 % of the time writing PSRAM, LVGL idle 9 %); a flash write is invisible to the LVGL counters, so the monitor needs a **panel vsync/refresh counter** to see flicker and dots directly; the monitor is blind during OTA (ticks from the blocked `loop()`). Heap flat throughout (66–67 KB internal, 31.7 KB largest, 6.6 MB PSRAM). **Plan amended**: 1b = stop the Driveline redraw + add vsync counter + timer-driven PERF, re-baseline; step 2 judged on the Simulation tab and during a scan, by the refresh counter. **Step 1b done 2026-09-27 `(verified, bench)`**: Driveline `tick()` now writes labels/chips only on change → idle Driveline 0 fps, 0 ms/s PSRAM copies, LVGL idle 96 %, core 1 idle 96 % (was 9.7 fps / 52 ms/s / 68 % / 66 %). `perf` gained the panel counters: **~24 vsync/s, longest gap 41.5 ms when healthy** — a DMA restart must show as a gap ≥ 2 frames (≈ 83 ms). Reporting runs from an esp_timer, so OTA is no longer a blind spot. **Second session 2026-09-27 → [[perf-dots-and-ota-2026-09-27]]**: (a) with dots on screen and everything idle the panel refreshed perfectly (24/s, 41.5 ms) — **dots are sub-frame DMA data glitches, invisible to the vsync counter, judged by eye only; bounce buffers are the designed fix**; (b) during `ota install` the panel drops to **4–8 refreshes/s with 290–747 ms gaps** — flash writes blank it ~75 % of the time; **no progress bar is possible before step 3**; target 24/s + 41.5 ms during an install. Tuning save and `ota check` lost no frame. **Correction the same evening**: the panel library already runs **10-line bounce buffers** and a **21 MHz** clock (the `platformio.ini` flags saying otherwise were dead names) — so the dots are *late bounce refills* re-sending the previous 10-line chunk (the photo shows text pixels echoed below each line), and step 2 as written is moot. **Step 3 (`CONFIG_SPIRAM_XIP_FROM_PSRAM` + `CONFIG_LCD_RGB_ISR_IRAM_SAFE`, pioarduino `custom_sdkconfig`, branch `display-xip`) now targets both the dots and the OTA blanking.** Fallbacks if dots remain: lower pixel clock (18 MHz), larger bounce buffers, Wi-Fi/LWIP buffers back to internal RAM (`CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=n`, costs internal RAM). **Step 3 built and measured 2026-09-27 17:46 → [[perf-xip-ota-2026-09-27]]: during a full `ota install` the panel held 24–25 refreshes/s with a 41.5 ms gap (stock core: 4–8/s, 290–747 ms). The flash-write blanking is fixed `(verified)`; a progress bar during updates is now possible (step 4). PSRAM free 6.6 → 4.9 MB (code resident there); no render slow-down seen in the one full-redraw sample. Dots on the XIP build still to be judged by eye (Wi-Fi up, idle screen).** **Step 4 done 2026-09-27**: the OTA notice keeps the screen on with a progress bar and "Do not switch off the ignition"; second forced install under `perf`: 24–25 frames/s, 41.5 ms gap throughout, bar redrawing 2–3×/s; user: "the progress bar appeared and no flickering or other issues" `(verified)`. **Merged to main and tagged v0.1.7 (2026-09-27, user decision)** after the user exercised the XIP build (Wi-Fi scan, update check and install) with no flicker or other issues reported. Whether the dots are fully gone in longer use stays open — report any sighting on v0.1.7 and the fallbacks above apply. First CI run with the core rebuild = the v0.1.7 tag build; if it fails, the release is missing until the workflow is fixed.
|
||||||
|
2. ~~**Step A - bounce buffers only**~~ **(void — already on, 10 lines, via the board header; 2026-09-27)** (`ESP_PANEL_LCD_RGB_BOUNCE_BUF_SIZE`, today 0; start at 10 lines = 1024x10 px, ~20 KB each, two buffers, internal DMA-capable RAM). The panel then reads from internal RAM that the CPU refills from PSRAM, so it tolerates short PSRAM stalls. **Expected to cure the Wi-Fi-traffic dots; will NOT cure flash-write flicker**: while flash is written the cache is disabled, so the refill has nothing to read from either. RAM: 67 KB internal free but the largest block is ~32 KB, so two 20 KB buffers may not fit - if not, shrink the LVGL draw buffer 60 -> 40 lines (frees ~40 KB) and check render speed. The refill costs CPU (measure).
|
||||||
|
3. **Step B - `CONFIG_SPIRAM_XIP_FROM_PSRAM` (+ `CONFIG_SPIRAM_RODATA`)** via pioarduino `custom_sdkconfig`: code and constants run from PSRAM, so flash writes no longer block PSRAM. **Cures flash-write flicker** (screen could stay on during OTA with a progress bar instead of going dark). Cost/risk: `custom_sdkconfig` rebuilds the Arduino core from source (much slower builds, locally and in CI), and may not work cleanly with this platform version - do it on a branch, release only once it works.
|
||||||
|
4. **Measure again after each step** (FPS, CPU, which symptoms still reproduce) and record the numbers here and on [[esp32-s3-touch-lcd-5b]].
|
||||||
|
|
||||||
|
Not affected by any of this: CAN, the RS485 wire and ESP-NOW - small, bursty, with their own hardware FIFOs and internal-RAM queues; none streams from PSRAM on a deadline (discussed 2026-09-27). The only reverse risk is the CAN RX FIFO overflowing during a flash write (ISR delayed); negligible for rebroadcast values and irrelevant while parked. A dropped-frame counter (TWAI `rx_missed_count` / `rx_overrun_count`) was offered and **deferred by the user**; it becomes worth adding if a value ever glitches while driving, or before diagnostic polling (multi-frame replies must arrive whole).
|
||||||
|
|
||||||
|
14. **Wi-Fi UX (found 2026-09-26) — RESOLVED 2026-09-27 (v0.1.5):** Settings rebuilt as a hand-coded screen (the SquareLine one is deleted) with Wi-Fi / Updates / System sections: connection status with failure reasons, networks nearby, full-screen password page, **one remembered network joined at boot**, scans only on request. User: "Wow, I like it" / "All good". Remaining housekeeping below still applies. Original finding: The Settings Wi-Fi screen had never worked (switch shipped disabled) and, now usable, is "a disaster UX" (user): SquareLine-generated, runtime SSID buttons + floating keyboard + loading overlay, **no on-screen confirmation of a successful join**. Also: A **forgets the network on every reboot** (each boot needs `wifi join`). To do: redesign as a hand-coded screen (like Driveline/Tuning, safe from SquareLine re-exports), show connection state, remember the network in NVS and auto-join; consider housing it on the Diagnostics screen (#12) next to the OTA controls, since Wi-Fi now mainly serves updates. Fixed 2026-09-27: the SSID buttons' pointers dangled after SquareLine deleted the Settings screen (use-after-free on the next scan), and scans ran every 10 s on every screen even when connected (flickering dots) — see [[esp32-s3-touch-lcd-5b]]. Housekeeping: **delete the `v0.1.0` release** on Gitea — installing it would strand the board without working OTA (USB only). → [[ota-updates]]
|
||||||
|
|||||||
+31
-12
@@ -1,12 +1,12 @@
|
|||||||
---
|
---
|
||||||
type: concept
|
type: concept
|
||||||
tags: [ota, firmware, gitea, ci, security, signing, design-decision, controller-a]
|
tags: [ota, firmware, gitea, ci, security, signing, design-decision, controller-a]
|
||||||
updated: 2026-09-26
|
updated: 2026-09-27
|
||||||
---
|
---
|
||||||
|
|
||||||
# OTA Firmware Updates
|
# OTA Firmware Updates
|
||||||
|
|
||||||
How Controller A updates itself from this repo's Gitea releases, why each piece is the way it is, and what is still to do (Controller B). Built 2026-09-26. Design decisions by the user are marked **(decision)**.
|
How Main CTRL updates itself from this repo's Gitea releases, why each piece is the way it is, and what is still to do (Inst. Cluster). Built 2026-09-26. Design decisions by the user are marked **(decision)**.
|
||||||
|
|
||||||
## The pipeline
|
## The pipeline
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ git push tag vX.Y.Z ──► Gitea Actions (.gitea/workflows/firmware.yml, runn
|
|||||||
sign "patrol-a|vX.Y.Z|<sha256>" with secret BMW_NISSAN_FIRMWARE_SIGNING_KEY
|
sign "patrol-a|vX.Y.Z|<sha256>" with secret BMW_NISSAN_FIRMWARE_SIGNING_KEY
|
||||||
release vX.Y.Z: firmware.bin + firmware.elf + manifest.txt
|
release vX.Y.Z: firmware.bin + firmware.elf + manifest.txt
|
||||||
│ public repo, HTTPS, no token
|
│ public repo, HTTPS, no token
|
||||||
Controller A `ota install` ◄──────┘ (parked, Wi-Fi joined)
|
Main CTRL Settings → Updates → Install ◄──┘ (or `ota install`; parked, Wi-Fi joined)
|
||||||
GET /api/v1/repos/art/ESP32-S3-Touch-LCD-5B/releases/latest → tag
|
GET /api/v1/repos/art/ESP32-S3-Touch-LCD-5B/releases/latest → tag
|
||||||
GET /releases/download/<tag>/manifest.txt → verify signature FIRST
|
GET /releases/download/<tag>/manifest.txt → verify signature FIRST
|
||||||
GET /releases/download/<tag>/firmware.bin → idle slot, hashed while streaming
|
GET /releases/download/<tag>/firmware.bin → idle slot, hashed while streaming
|
||||||
@@ -24,22 +24,37 @@ Controller A `ota install` ◄──────┘ (parked, Wi-Fi joined)
|
|||||||
new image PENDING_VERIFY → confirmed after 30 s uptime, else bootloader rolls back
|
new image PENDING_VERIFY → confirmed after 30 s uptime, else bootloader rolls back
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**To release:** `git tag -a vX.Y.Z -m "..." && git push --follow-tags origin main` — a plain `git push` sends the commit but **not the tag**, so only `main-latest` gets built and the board keeps offering the previous release (happened with v0.1.5, 2026-09-27; fixed with `git push origin vX.Y.Z`) — one push, one (tag) build: a `main` push skips itself when its commit already has a `v*` tag, and when it only changes `wiki/**` or `*.md` (checked inside the job, so a tag build is never skipped by a path filter).
|
||||||
|
|
||||||
Push to `main` (no tag) builds a rolling **pre-release `main-latest`** — unsigned, no manifest, for bench/USB testing. `/releases/latest` skips pre-releases, so the car is never offered it `(repo)`.
|
Push to `main` (no tag) builds a rolling **pre-release `main-latest`** — unsigned, no manifest, for bench/USB testing. `/releases/latest` skips pre-releases, so the car is never offered it `(repo)`.
|
||||||
|
|
||||||
## Status: VERIFIED end-to-end `(verified 2026-09-26, bench, USB power, Wi-Fi Personal1)`
|
## Status: VERIFIED end-to-end `(verified 2026-09-26, bench, USB power, Wi-Fi Personal1)`
|
||||||
|
|
||||||
`dev` (USB-flashed) → `ota install` → **v0.1.1** from CI: 1.65 MB downloaded + written in ~60 s (~27 KB/s), sha256 + signature OK, rebooted into `app1` as PENDING_VERIFY, ESP-NOW up, **confirmed after 30 s**. The installed v0.1.1 then ran `ota check` itself ("up to date") — it can take the next update. Previous image kept in `app0` for `ota rollback`.
|
| Cycle (performed by the *running* firmware) | Result |
|
||||||
|
|---|---|
|
||||||
|
| `dev` (USB-flashed) → **v0.1.1**, into `app1` | ✅ 1.65 MB in ~60 s (~27 KB/s), confirmed after 30 s; v0.1.1 then passed `ota check` itself |
|
||||||
|
| v0.1.1 → **v0.1.2**, into `app0` | ✅ slots alternate as designed |
|
||||||
|
| v0.1.2 → v0.1.2 (`ota install force`), attempt 1 | ❌ download aborted at 570 B — the loop treated a momentary TLS `connected()==false` as a drop. The **failure path worked**: aborted cleanly, "Update failed / still running v0.1.2" notice, stayed on v0.1.2 |
|
||||||
|
| same, attempt 2 | ✅ into `app1`, confirmed — first install run by the dark-screen code |
|
||||||
|
| **v0.1.3** (published 2026-09-26) | fixes the 570 B abort (a drop only counts after 2 s of silence); installed, ran until 2026-09-27 |
|
||||||
|
| `dev` → **v0.1.4**, from the **screen** (2026-09-27) | ✅ first install driven by the user from Settings → Updates (Check → Install → confirm): dark ~1 min, restart, version label `A v0.1.4`. v0.1.4 still had the old Wi-Fi code, so it came back disconnected and the flickering dots returned — see [[esp32-s3-touch-lcd-5b]] |
|
||||||
|
| `dev` → **v0.1.5**, from the screen (2026-09-27) | ✅ user: "All good" — new Settings/Tuning screens, Wi-Fi rejoined by itself after the restart, no dots |
|
||||||
|
|
||||||
During the write the backlight is off (flash writes flicker the PSRAM-fed panel): a full-screen notice "Updating to vX … do not switch off" shows for 3 s first, then "Installed vX / Restarting" or "Update failed / still running vY" (v0.1.2+). The running version is always shown bottom-right on every screen.
|
Always remember: an install is performed by the firmware that is **already running**, so a fix to the install path only takes effect on the update *after* the one that delivers it (v0.1.1 → v0.1.2 still flickered because v0.1.1 did the writing).
|
||||||
|
|
||||||
|
**CI note (2026-09-27):** the v0.1.7 tag build failed with `ModuleNotFoundError: No module named 'SCons.Tool.FortranCommon'` — upstream PlatformIO core + pioarduino's stripped SCons 4.8.1 on the new ESP-IDF (custom_sdkconfig) build path. Fixed by installing pioarduino's core fork in the workflow (same pin the platform uses locally); the tag was moved to the fix commit and pushed again.
|
||||||
|
|
||||||
|
**Progress bar on screen (branch `display-xip`, 2026-09-27; supersedes the dark-screen writes of v0.1.2–v0.1.6).** With the core rebuilt to execute from PSRAM and an IRAM-safe panel refill (see [[perf-xip-ota-2026-09-27]]), flash writes no longer blank the panel, so the full-screen notice now stays lit: "Updating to vX", a bar driven per percent from the download loop, and an amber "Do not switch off the ignition". Verified 2026-09-27 by the user ("the progress bar appeared and no flickering") and by `perf`: 24–25 panel frames/s, 41.5 ms gap for the whole download. Previously (v0.1.2–v0.1.6) the backlight was off while the image was written: a full-screen notice "Updating to vX — the screen goes dark for about a minute — do not switch off" shows for 3 s first, then "Installed vX / Restarting…" or "Update failed / Still running vY". Seen by the user on the 2026-09-27 screen installs: dark for about a minute, then the restart. The running version is always shown bottom-right on every screen (`A v0.1.2`).
|
||||||
|
|
||||||
Known quirk: `ota status` shows the *other* slot's "built" date from the framework's precompiled app descriptor (e.g. "Nov 4 2025"), not our build time — ignore it.
|
Known quirk: `ota status` shows the *other* slot's "built" date from the framework's precompiled app descriptor (e.g. "Nov 4 2025"), not our build time — ignore it.
|
||||||
|
|
||||||
## Decisions and why
|
## Decisions and why
|
||||||
|
|
||||||
- **Manual trigger only (decision, 2026-09-26).** An install ends in a reboot, which blanks Controller B's gauges; nothing checks or installs in the background. Today the trigger is the `ota` serial console; the intended home is the password-gated **Diagnostics screen** ([[open-questions]] #12), the same gate as active CAN polling.
|
- **Manual trigger only (decision, 2026-09-26).** An install ends in a reboot, which blanks Inst. Cluster's gauges; nothing checks or installs in the background.
|
||||||
|
- **On the Settings screen, behind a confirm dialog (decision, 2026-09-27)** — replacing the earlier plan to put it on the password-gated Diagnostics screen. Settings → Updates shows installed vs latest and a **Check for updates** button; **Install vX** appears only when the latest release differs and asks "Install vX? The screen goes dark for about a minute… only while parked". The user chose a confirm dialog over a PIN: the parked gate and the signature already guard the dangerous parts; a PIN can come with the Diagnostics screen ([[open-questions]] #12). The `ota` console stays for bench work and `rollback`.
|
||||||
- **Parked gate** `(repo)`: refused if engine rpm > 0 / run state running or starting, output shaft turning, or lever in a drive gear. A silent bus (>2 s no frames: ignition off, bench) counts as parked. Checked before the download **and again** before the slot switch. `ota check` is exempt (read-only).
|
- **Parked gate** `(repo)`: refused if engine rpm > 0 / run state running or starting, output shaft turning, or lever in a drive gear. A silent bus (>2 s no frames: ignition off, bench) counts as parked. Checked before the download **and again** before the slot switch. `ota check` is exempt (read-only).
|
||||||
- **HTTPS pull from a public repo (decision).** Both repos were made public 2026-09-26 so the device needs **no token** — the same reasoning as `parking_solution`'s public releases mirror: a read token in shipped firmware leaks with the device. History was scanned before/after going public: no secrets, no full VIN (only the 10-char prefix in ident logs), no SSIDs `(verified 2026-09-26)`.
|
- **HTTPS pull from a public repo (decision).** Both repos were made public 2026-09-26 so the device needs **no token** — the same reasoning as `parking_solution`'s public releases mirror: a read token in shipped firmware leaks with the device. History was scanned before/after going public: no secrets, no full VIN (only the 10-char prefix in ident logs), no SSIDs `(verified 2026-09-26)`.
|
||||||
- **Signed images (decision).** HTTPS only proves the file came from the server; the ECDSA P-256 signature proves it came from our CI key. The signed statement is `target|version|sha256`, so a Controller B image can't be installed on A even with a shared key, and the manifest version can't be swapped. The firmware contains no secrets, so public binaries are fine — **keep it that way**: the future Diagnostics-screen password must be a salted hash in NVS, never a literal in source.
|
- **Signed images (decision).** HTTPS only proves the file came from the server; the ECDSA P-256 signature proves it came from our CI key. The signed statement is `target|version|sha256`, so a Inst. Cluster image can't be installed on A even with a shared key, and the manifest version can't be swapped. The firmware contains no secrets, so public binaries are fine — **keep it that way**: the future Diagnostics-screen password must be a salted hash in NVS, never a literal in source.
|
||||||
- **TLS trust = Let's Encrypt roots, not the leaf** `(verified 2026-09-26)`: the server chain is leaf (SAN `git.infra.msai.al`) → YR2 → Root YR (cross-signed by ISRG Root X1). Both ISRG Root X1 (to 2035) and Root YR (to 2045) are embedded in `include/config/ota_config.h`, and each verifies the chain alone. Leaf certs rotate ~90 days — never pin them. The framework's mbedtls has `MBEDTLS_HAVE_TIME_DATE` off, so no NTP is needed (and cert dates aren't checked; the signature is the real guarantee).
|
- **TLS trust = Let's Encrypt roots, not the leaf** `(verified 2026-09-26)`: the server chain is leaf (SAN `git.infra.msai.al`) → YR2 → Root YR (cross-signed by ISRG Root X1). Both ISRG Root X1 (to 2035) and Root YR (to 2045) are embedded in `include/config/ota_config.h`, and each verifies the chain alone. Leaf certs rotate ~90 days — never pin them. The framework's mbedtls has `MBEDTLS_HAVE_TIME_DATE` off, so no NTP is needed (and cert dates aren't checked; the signature is the real guarantee).
|
||||||
- **Rollback**: the framework bootloader has `CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE=y`, but Arduino's `initArduino()` marks a new image valid *before* `setup()`. `ota_update.cpp` overrides `verifyRollbackLater()` → the image stays PENDING_VERIFY until `Ota::tick()` confirms it after 30 s. Consequence: **power off within 30 s of an update's first boot = back to the old version** (by design).
|
- **Rollback**: the framework bootloader has `CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE=y`, but Arduino's `initArduino()` marks a new image valid *before* `setup()`. `ota_update.cpp` overrides `verifyRollbackLater()` → the image stays PENDING_VERIFY until `Ota::tick()` confirms it after 30 s. Consequence: **power off within 30 s of an update's first boot = back to the old version** (by design).
|
||||||
|
|
||||||
@@ -50,7 +65,7 @@ With the display, Wi-Fi and all tasks up, **internal RAM is nearly exhausted: 15
|
|||||||
- This framework's mbedtls is built with `CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y` (~40 KB internal per TLS session → impossible). During a job, `mbedtls_platform_set_calloc_free()` routes TLS to PSRAM, and restores it after (both sides free with `heap_caps_free`, so the swap is safe).
|
- This framework's mbedtls is built with `CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y` (~40 KB internal per TLS session → impossible). During a job, `mbedtls_platform_set_calloc_free()` routes TLS to PSRAM, and restores it after (both sides free with `heap_caps_free`, so the swap is safe).
|
||||||
- No room for a dedicated 10–16 KB task stack, and a PSRAM stack is forbidden because `esp_ota_write()` disables the flash cache. So jobs run **inside the Arduino loop task** (8 KB internal stack): `ota check` peaked leaving **3.6 KB headroom**. The console and screen value ticks pause while a job runs.
|
- No room for a dedicated 10–16 KB task stack, and a PSRAM stack is forbidden because `esp_ota_write()` disables the flash cache. So jobs run **inside the Arduino loop task** (8 KB internal stack): `ota check` peaked leaving **3.6 KB headroom**. The console and screen value ticks pause while a job runs.
|
||||||
|
|
||||||
The low internal heap is a system-wide risk beyond OTA (the LVGL 60-line DMA draw buffer alone is ~120 KB of internal SRAM) — see [[open-questions]].
|
Update 2026-09-27: with LVGL's pool moved to PSRAM, internal free is 69 KB (largest block 31.7 KB); jobs still run in the loop task (it works, 3.6 KB headroom). The low internal heap was a system-wide risk beyond OTA (the LVGL 60-line DMA draw buffer alone is ~120 KB of internal SRAM) — see [[open-questions]].
|
||||||
|
|
||||||
## Partition table (changed 2026-09-26)
|
## Partition table (changed 2026-09-26)
|
||||||
|
|
||||||
@@ -73,7 +88,11 @@ SPIFFS (3.4 MB, unused by any code) was dropped. Firmware is ~1.65 MB (19.8 % of
|
|||||||
| `ota install [force]` | full install; `force` reinstalls the same version |
|
| `ota install [force]` | full install; `force` reinstalls the same version |
|
||||||
| `ota rollback` | boot the other slot (or reject an unconfirmed image) — parked only |
|
| `ota rollback` | boot the other slot (or reject an unconfirmed image) — parked only |
|
||||||
|
|
||||||
Wi-Fi must be joined first — `wifi join <ssid> [pass]` on the console (`wifi status`, `wifi off`), or the Settings screen. **Do not install `v0.1.0`**: it predates the loop-task/PSRAM-TLS fix, so once installed it can't run OTA again (it boots fine, so rollback won't save it — USB only). Joining an AP moves the radio channel; the ESP-NOW link to B follows it (B hops). `diag raw off` first keeps CANRAW from burying the progress lines. The screen may flicker while flash is written (RGB panel + flash cache) `(unverified)`.
|
Wi-Fi must be joined first — Settings → Wi-Fi (remembered from then on) or `wifi join <ssid> [pass]` on the console (`wifi status | forget | scan | on | off`). **Do not install `v0.1.0`**: it predates the loop-task/PSRAM-TLS fix, so once installed it can't run OTA again (it boots fine, so rollback won't save it — USB only). Joining an AP moves the radio channel; the ESP-NOW link to B follows it (B hops). `diag raw off` first keeps CANRAW from burying the progress lines.
|
||||||
|
|
||||||
|
- **Wi-Fi is remembered (v0.1.5+)**: one network, saved after a successful join, rejoined ~3 s after boot — including the boot that ends an update `(verified 2026-09-27)`. Before v0.1.5 every boot needed a new join.
|
||||||
|
- **Open the console without resetting the board**: `pio device monitor -p COM10 -b 115200 --dtr 0 --rts 0 --echo` (pio lives at `%USERPROFILE%\.platformio\penv\Scripts\pio.exe`). Opening the port with default DTR/RTS resets it (`rst:0x15 USB_UART_CHIP_RESET`), which drops the Wi-Fi join `(verified 2026-09-26)`.
|
||||||
|
- **Flicker cause** `(verified 2026-09-26)`: flash and PSRAM share the MSPI cache; every flash write stalls the PSRAM framebuffer that the panel's bounce-buffer refill copies from (the "no bounce buffer" wording here was wrong — the board header enables 10-line bounce buffers). Hence the dark screen of v0.1.2–v0.1.6; cured by XIP from PSRAM + `LCD_RGB_ISR_IRAM_SAFE` (2026-09-27) → [[perf-xip-ota-2026-09-27]].
|
||||||
|
|
||||||
## Secrets and keys
|
## Secrets and keys
|
||||||
|
|
||||||
@@ -85,11 +104,11 @@ Wi-Fi must be joined first — `wifi join <ssid> [pass]` on the console (`wifi s
|
|||||||
|
|
||||||
- **Settings Wi-Fi switch was disabled since the first SquareLine export** (`LV_STATE_DISABLED`) — the Wi-Fi UI had never worked. Re-enabled at runtime in `UIStateManager` (survives re-exports; untick "Disabled" in the SquareLine project too).
|
- **Settings Wi-Fi switch was disabled since the first SquareLine export** (`LV_STATE_DISABLED`) — the Wi-Fi UI had never worked. Re-enabled at runtime in `UIStateManager` (survives re-exports; untick "Disabled" in the SquareLine project too).
|
||||||
- **Joining Wi-Fi killed ESP-NOW**: the Wi-Fi task used `WiFi.disconnect(true)` (true = radio off), which drops ESP-NOW; B then ran on the wire only. Now `WiFi.disconnect()`, and `EspNowLink::send()` re-initialises ESP-NOW if the driver ever drops it. Verified: joined Personal1 (channel 9), ESP-NOW 195 sent / 0 failed.
|
- **Joining Wi-Fi killed ESP-NOW**: the Wi-Fi task used `WiFi.disconnect(true)` (true = radio off), which drops ESP-NOW; B then ran on the wire only. Now `WiFi.disconnect()`, and `EspNowLink::send()` re-initialises ESP-NOW if the driver ever drops it. Verified: joined Personal1 (channel 9), ESP-NOW 195 sent / 0 failed.
|
||||||
- `showConnectionResult()` took the LVGL lock with a 0 ms try-lock, ignored the result, and touched widgets that are NULL off the Settings screen — now waits for the lock and null-checks. It still shows **no success feedback** on screen; the Wi-Fi UI needs a redesign (user: "a disaster UX").
|
- `showConnectionResult()` took the LVGL lock with a 0 ms try-lock, ignored the result, and touched widgets that are NULL off the Settings screen — now waits for the lock and null-checks. It still showed **no success feedback** on screen (user: "a disaster UX") — resolved by the hand-coded Settings screen in v0.1.5 ([[open-questions]] #14).
|
||||||
|
|
||||||
## Controller B (not built yet)
|
## Inst. Cluster (implemented 2026-09-27)
|
||||||
|
|
||||||
Plan agreed 2026-09-26: B is updated **by A over ESP-NOW**, not by the RS485 wire (the wire is one-way A→B; ESP-NOW is bidirectional and faster). A downloads B's signed image (target `patrol-b`) from B's repo releases, sends it with acks, B verifies the signature and swaps slots with the same rollback scheme. Prerequisites: B moves off the stock `default.csv` (1.25 MB slots, 1.07 MB firmware → too tight) to a 16 MB layout (confirm B's flash size first; one USB flash); ESP-NOW pairing/encryption so only A can talk to B; protocol frames for the transfer (shared `automotive_data.h` → version bump in both repos). B's repo still answered 404 anonymously on 2026-09-26 — check its visibility setting. Wire stays for gauge-data redundancy.
|
The 2026-09-26 idea (A streams B's image over ESP-NOW) was dropped for a **pull design** the user chose on 2026-09-27: B downloads its own signed release (target `patrol-b`, B's repo, same key) over Wi-Fi; A only hands over the credentials and the trigger. Full design, verification state and the first-pairing procedure live in B's wiki (`../../ESP32-S3-LCD-1.3/wiki/pages/controller-b-ota.md`). A's side: `src/modules/link_peer.cpp` - `link pair` sends a random key over the UART wire once (never by radio; both repos are public), B's `STATUS` frames (version, phase, progress) arrive over ESP-NOW unicast, credentials and OTA commands go to B inside AES-256-GCM `SECURE` frames, and Settings → Updates gained a **Inst. Cluster** card (Installed / Latest / Check / Install) next to Main CTRL's. B's install is behind the same parking gate plus "A must be on Wi-Fi" (same AP ⇒ same channel ⇒ B's progress frames keep arriving). Console: `link status | pair | unpair | creds | ota check | ota install [force] | ota rollback`. **Verified end-to-end on the bench 2026-09-27**: `link pair` over the wire, automatic credential push, `link ota check` / `link ota install` from A's console took B from `dev` to `v0.1.0` (1,248,432 B in ~50 s), B rebooted, reported `v0.1.0` and confirmed itself after 30 s. The Updates-page buttons share the same request functions but have not been tapped yet.
|
||||||
|
|
||||||
## Related
|
## Related
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ updated: 2026-09-22
|
|||||||
|
|
||||||
# Patrol instrument cluster — signal expectations
|
# Patrol instrument cluster — signal expectations
|
||||||
|
|
||||||
What the target vehicle's cluster ([[nissan-patrol-swap]]) needs on its tach and temp inputs, from the first day of driving it with Controller B's outputs through the low-side FET stage ([[canny-5-3-pico-gauge-drive]]). Patrol generation still unidentified — Y60/GQ vs Y61/GU matters for gauge internals → [[open-questions]].
|
What the target vehicle's cluster ([[nissan-patrol-swap]]) needs on its tach and temp inputs, from the first day of driving it with Inst. Cluster's outputs through the low-side FET stage ([[canny-5-3-pico-gauge-drive]]). Patrol generation still unidentified — Y60/GQ vs Y61/GU matters for gauge internals → [[open-questions]].
|
||||||
|
|
||||||
## Tachometer
|
## Tachometer
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 975 KiB |
@@ -0,0 +1,274 @@
|
|||||||
|
16:46:21.404 >>> perf on 1
|
||||||
|
16:46:21.459 [perf] periodic every 1 s (columns: ts,fps,avg_ms,max_ms,kpx,flush_ms/s,lv_idle,idle0,idle1,int_free,int_largest,psram)
|
||||||
|
16:46:22.498 PERF,12532,9.5,29.4,32,39,51,67,95,67,67472,31732,6602668
|
||||||
|
16:46:23.195 [ 13215][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v183 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:46:23.515 PERF,13549,9.8,30.0,32,39,52,67,94,66,67472,31732,6602664
|
||||||
|
16:46:23.695 [ 13710][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #50 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=55 fail=0]
|
||||||
|
16:46:24.017 [ 14049][I][settings_screen.cpp:730] build(): [Settings] Settings screen built
|
||||||
|
16:46:24.581 PERF,14615,5.6,46.0,148,131,85,30,93,55,67228,31732,6602552
|
||||||
|
16:46:25.184 [ 15217][I][main.cpp:152] loop(): [LOOP] Heartbeat - system running
|
||||||
|
16:46:25.589 PERF,15623,0.0,0.0,0,0,0,92,95,94,67228,31732,6602328
|
||||||
|
16:46:26.590 PERF,16624,0.0,0.0,0,0,0,92,96,95,67228,31732,6602328
|
||||||
|
16:46:26.819 tworks
|
||||||
|
16:46:26.823 [wifi] -51 dBm ArtServis
|
||||||
|
16:46:27.598 PERF,17631,5.9,11.0,40,42,29,79,96,87,67228,31732,6602664
|
||||||
|
16:46:28.207 [ 18227][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v183 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:46:28.598 PERF,18632,0.0,0.0,0,0,0,93,95,95,67228,31732,6602664
|
||||||
|
16:46:28.976 [ 18991][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #75 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=81 fail=0]
|
||||||
|
16:46:29.716 PERF,19750,1.7,77.0,142,334,63,94,95,81,67228,31732,6602664
|
||||||
|
16:46:30.219 [ 20251][I][main.cpp:152] loop(): [LOOP] Heartbeat - system running
|
||||||
|
16:46:30.723 PERF,20757,1.9,4.0,4,0,0,93,96,94,67228,31732,6602664
|
||||||
|
16:46:31.730 PERF,21764,4.9,39.2,96,150,72,0,96,76,67228,31732,6602664
|
||||||
|
16:46:32.807 PERF,22841,3.7,75.5,104,301,122,61,96,67,67228,31732,6602664
|
||||||
|
16:46:33.219 [ 23240][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v183 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:46:33.854 PERF,23887,4.7,60.4,102,232,121,53,94,67,67228,31732,6602664
|
||||||
|
16:46:34.259 [ 24275][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #100 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=107 fail=0]
|
||||||
|
16:46:34.900 PERF,24933,3.8,51.0,104,196,81,76,94,75,67228,31732,6602664
|
||||||
|
16:46:35.268 [ 25301][I][main.cpp:152] loop(): [LOOP] Heartbeat - system running
|
||||||
|
16:46:35.903 PERF,25937,4.9,78.0,104,314,166,36,96,56,67228,31732,6602664
|
||||||
|
16:46:36.968 PERF,27002,4.6,77.6,102,314,152,72,96,59,67228,31732,6602664
|
||||||
|
16:46:37.970 PERF,28003,10.9,6.5,18,14,18,87,96,88,67228,31732,6602664
|
||||||
|
16:46:38.233 [ 28253][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v183 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:46:38.970 PERF,29004,2.9,4.6,6,0,0,92,95,94,67228,31732,6602664
|
||||||
|
16:46:39.433 [ 29470][W][STA.cpp:543] disconne[cwifti] j(oini)ng ':ArtServis'...
|
||||||
|
16:46:39.435 STA already disconnected.
|
||||||
|
16:46:39.543 [ 29558][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #125 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=133 fail=0]
|
||||||
|
16:46:39.977 PERF,30010,26.8,10.6,134,26,82,56,90,64,66908,31732,6601804
|
||||||
|
16:46:40.279 [ 30312][I][main.cpp:152] loop(): [LOOP] Heartbeat - system running
|
||||||
|
16:46:40.985 PERF,31019,49.5,4.7,12,0,12,70,94,70,66908,31732,6601708
|
||||||
|
16:46:41.187 l 1
|
||||||
|
16:46:41.199 [wifi] 'ArtServis' remembered - joins automatically at boot
|
||||||
|
16:46:42.062 PERF,32096,24.1,7.5,66,12,38,60,94,75,66908,31732,6601744
|
||||||
|
16:46:43.075 PERF,33109,0.9,10.0,10,19,2,88,95,93,66908,31732,6601744
|
||||||
|
16:46:43.256 [ 33276][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v183 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:46:44.081 PERF,34114,2.9,44.0,114,165,58,87,94,81,66752,31732,6601744
|
||||||
|
16:46:44.806 [ 34821][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #150 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=159 fail=0]
|
||||||
|
16:46:45.092 PERF,35125,3.9,8.0,10,22,12,92,94,91,66752,31732,6601744
|
||||||
|
16:46:45.163 [ota] working - console and screen values pause until done
|
||||||
|
16:46:46.806 [ota] running dev | latest release v0.1.6 (1709280 bytes, signature OK) - `ota install` to update
|
||||||
|
16:46:46.813 [ota] loop stack headroom after job: 3640 B
|
||||||
|
16:46:46.908 [ 36941][I][main.cpp:152] loop(): [LOOP] Heartbeat - system running
|
||||||
|
16:46:46.915 PERF,36947,5.4,11.4,34,32,24,91,92,25,66256,31732,6601556
|
||||||
|
16:46:47.917 PERF,37951,2.9,8.0,8,22,8,91,95,92,66256,31732,6601556
|
||||||
|
16:46:48.273 [ 38293][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v183 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:46:48.924 PERF,38958,0.0,0.0,0,0,0,91,94,94,66256,31732,6601556
|
||||||
|
16:46:49.926 PERF,39962,0.0,0.0,0,0,0,92,96,94,66256,31732,6601556
|
||||||
|
16:46:50.093 [ 40108][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #175 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=185 fail=0]
|
||||||
|
16:46:50.969 PERF,41002,2.8,46.6,120,163,56,71,94,81,66256,31732,6601556
|
||||||
|
16:46:51.999 [ 42032][I][main.cpp:152] loop(): [LOOP] Heartbeat - system running
|
||||||
|
16:46:52.006 PERF,42038,0.9,22.0,22,66,7,88,96,92,66256,31732,6601556
|
||||||
|
16:46:53.028 PERF,43061,7.8,39.0,116,110,100,48,95,64,66256,31732,6601556
|
||||||
|
16:46:53.287 [ 43307][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v183 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:46:53.729 [ 43761][I][tuning_screen.cpp:558] build(): [Tuning] Gauge tuning screen built
|
||||||
|
16:46:54.055 PERF,44088,6.8,71.1,312,121,97,29,92,35,66256,31732,6601556
|
||||||
|
16:46:55.052 PERF,45089,0.9,6.0,6,5,0,92,96,94,66256,31732,6601556
|
||||||
|
16:46:55.369 [ 45392][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #200 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=211 fail=0]
|
||||||
|
16:46:56.055 PERF,46089,0.0,0.0,0,0,0,92,94,95,66256,31732,6601556
|
||||||
|
16:46:57.055 [ 47090][I][main.cpp:152] loop(): [LOOP] Heartbeat - system running
|
||||||
|
16:46:57.060 PERF,47097,0.0,0.0,0,0,0,92,96,94,66256,31732,6601556
|
||||||
|
16:46:58.060 PERF,48097,0.0,0.0,0,0,0,93,96,94,66256,31732,6601556
|
||||||
|
16:46:58.294 [ 48318][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v183 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:46:59.061 PERF,49098,0.0,0.0,0,0,0,92,95,95,66256,31732,6601556
|
||||||
|
16:47:00.061 PERF,50099,0.0,0.0,0,0,0,94,96,95,66256,31732,6601556
|
||||||
|
16:47:00.658 [ 50673][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #225 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=237 fail=0]
|
||||||
|
16:47:01.066 PERF,51100,0.0,0.0,0,0,0,91,94,94,66256,31732,6601556
|
||||||
|
16:47:02.072 [ 52103][I][main.cpp:152] loop(): [LOOP] Heartbeat - system running
|
||||||
|
16:47:02.079 PERF,52109,0.0,0.0,0,0,0,94,96,94,66256,31732,6601556
|
||||||
|
16:47:03.077 PERF,53110,0.0,0.0,0,0,0,92,96,94,66256,31732,6601556
|
||||||
|
16:47:03.214 [ 53239][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v184 (changed): ppr=2 trim=-12 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:03.384 [ 53404][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v185 (changed): ppr=2 trim=-11 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:03.540 [ 53568][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v186 (changed): ppr=2 trim=-10 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:03.683 [ 53703][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v187 (changed): ppr=2 trim=-9 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:03.811 [ 53837][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v188 (changed): ppr=2 trim=-8 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:03.951 [ 53971][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v189 (changed): ppr=2 trim=-7 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:04.078 PERF,54111,25.9,5.5,12,9,30,74,87,77,66256,31732,6601556
|
||||||
|
16:47:04.110 [ 54136][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v190 (changed): ppr=2 trim=-6 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:04.250 [ 54269][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v191 (changed): ppr=2 trim=-5 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:04.440 [ 54464][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v192 (changed): ppr=2 trim=-4 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:05.080 PERF,55113,24.9,4.9,10,7,25,68,91,80,66256,31732,6601556
|
||||||
|
16:47:05.178 [ 55198][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v193 (changed): ppr=2 trim=-5 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:05.312 [ 55331][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v194 (changed): ppr=2 trim=-6 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:05.475 [ 55496][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v195 (changed): ppr=2 trim=-7 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:05.670 [ 55689][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v196 (changed): ppr=2 trim=-8 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:05.893 [ 55913][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v197 (changed): ppr=2 trim=-9 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:06.033 [ 56048][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #250 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=276 fail=0]
|
||||||
|
16:47:06.081 PERF,56114,28.9,5.2,10,8,30,76,86,76,66256,31732,6601556
|
||||||
|
16:47:06.105 [ 56124][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v198 (changed): ppr=2 trim=-10 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:06.300 [ 56318][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v199 (changed): ppr=2 trim=-11 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:06.853 [ 56873][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v200 (changed): ppr=2 trim=-12 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:07.083 [ 57115][I][main.cpp:152] loop(): [LOOP] Heartbeat - system running
|
||||||
|
16:47:07.092 PERF,57126,19.7,4.7,10,7,16,85,91,84,66256,31732,6601556
|
||||||
|
16:47:07.196 [ 57217][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v201 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:08.097 PERF,58130,7.9,4.7,10,7,7,86,94,91,66256,31732,6601556
|
||||||
|
16:47:09.099 PERF,59132,0.0,0.0,0,0,0,93,96,94,66256,31732,6601556
|
||||||
|
16:47:10.100 PERF,60133,0.0,0.0,0,0,0,92,96,94,66256,31732,6601556
|
||||||
|
16:47:11.115 PERF,61148,0.9,8.0,8,9,1,92,95,93,66256,31732,6601556
|
||||||
|
16:47:11.327 [ 61342][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #19 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=305 fail=0]
|
||||||
|
16:47:12.117 [ 62149][I][main.cpp:152] loop(): [LOOP] Heartbeat - system running
|
||||||
|
16:47:12.124 PERF,62155,0.0,0.0,0,0,0,92,94,93,66256,31732,6601556
|
||||||
|
16:47:12.209 [ 62228][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v201 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:13.144 PERF,63177,6.8,24.5,136,83,67,60,94,78,66256,31732,6601556
|
||||||
|
16:47:14.144 [ 64164][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v202 (changed): ppr=2 trim=-13 temp_hz=20000 slope=145 offset=50 min=40 override=0
|
||||||
|
16:47:14.150 PERF,64179,6.9,6.5,18,9,8,86,94,90,66256,31732,6601556
|
||||||
|
16:47:14.339 [ 64358][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v203 (changed): ppr=2 trim=-13 temp_hz=20000 slope=140 offset=50 min=40 override=0
|
||||||
|
16:47:14.503 [ 64523][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v204 (changed): ppr=2 trim=-13 temp_hz=20000 slope=135 offset=50 min=40 override=0
|
||||||
|
16:47:14.698 [ 64717][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v205 (changed): ppr=2 trim=-13 temp_hz=20000 slope=130 offset=50 min=40 override=0
|
||||||
|
16:47:14.862 [ 64881][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v206 (changed): ppr=2 trim=-13 temp_hz=20000 slope=125 offset=50 min=40 override=0
|
||||||
|
16:47:14.996 [ 65016][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v207 (changed): ppr=2 trim=-13 temp_hz=20000 slope=120 offset=50 min=40 override=0
|
||||||
|
16:47:15.147 PERF,65180,34.9,4.8,10,7,33,70,88,75,66256,31732,6601556
|
||||||
|
16:47:15.761 [ 65781][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v208 (changed): ppr=2 trim=-13 temp_hz=20000 slope=125 offset=50 min=40 override=0
|
||||||
|
16:47:15.955 [ 65976][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v209 (changed): ppr=2 trim=-13 temp_hz=20000 slope=130 offset=50 min=40 override=0
|
||||||
|
16:47:16.114 [ 66141][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v210 (changed): ppr=2 trim=-13 temp_hz=20000 slope=135 offset=50 min=40 override=0
|
||||||
|
16:47:16.150 PERF,66183,18.9,5.2,10,7,22,68,91,82,66256,31732,6601556
|
||||||
|
16:47:16.286 [ 66305][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v211 (changed): ppr=2 trim=-13 temp_hz=20000 slope=140 offset=50 min=40 override=0
|
||||||
|
16:47:16.691 [ 66709][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v212 (changed): ppr=2 trim=-13 temp_hz=20000 slope=145 offset=50 min=40 override=0
|
||||||
|
16:47:16.769 [ 66784][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #44 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=342 fail=0]
|
||||||
|
16:47:17.140 [ 67161][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v213 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:17.154 [ 67186][I][main.cpp:152] loop(): [LOOP] Heartbeat - system running
|
||||||
|
16:47:17.157 PERF,67193,29.7,4.8,12,7,28,76,89,77,66256,31732,6601556
|
||||||
|
16:47:18.157 PERF,68193,4.9,4.0,4,5,4,90,95,92,66256,31732,6601556
|
||||||
|
16:47:19.156 PERF,69193,0.0,0.0,0,0,0,90,96,94,66256,31732,6601556
|
||||||
|
16:47:20.171 PERF,70204,0.0,0.0,0,0,0,91,95,94,66256,31732,6601556
|
||||||
|
16:47:21.172 PERF,71205,0.9,8.0,8,9,1,92,96,94,66256,31732,6601556
|
||||||
|
16:47:22.051 [ 72065][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #69 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=368 fail=0]
|
||||||
|
16:47:22.153 [ 72172][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v213 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:22.172 [ 72206][I][main.cpp:152] loop(): [LOOP] Heartbeat - system running
|
||||||
|
16:47:22.177 PERF,72213,0.0,0.0,0,0,0,93,93,94,66256,31732,6601556
|
||||||
|
16:47:23.202 PERF,73235,8.8,16.0,98,68,61,91,95,80,66256,31732,6601556
|
||||||
|
16:47:24.208 [ 74228][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v214 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:24.215 PERF,74243,4.9,6.4,16,10,6,88,94,91,66256,31732,6601556
|
||||||
|
16:47:24.403 [ 74422][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v215 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:24.687 [ 74707][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v216 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:24.852 [ 74872][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v217 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:24.988 [ 75007][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v218 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:25.182 [ 75201][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v219 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:25.216 PERF,75251,24.8,5.8,14,8,27,68,88,78,66256,31732,6601556
|
||||||
|
16:47:25.346 [ 75366][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v220 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:25.480 [ 75499][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v221 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:25.885 [ 75905][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v222 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:26.013 [ 76039][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v223 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:26.184 [ 76204][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v224 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:26.226 PERF,76259,28.7,5.2,10,8,31,73,88,76,66256,31732,6601556
|
||||||
|
16:47:26.739 [ 76759][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v225 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:27.084 [ 77104][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v226 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:27.230 [ 77262][I][main.cpp:152] loop(): [LOOP] Heartbeat - system running
|
||||||
|
16:47:27.237 PERF,77269,26.7,4.6,10,6,24,73,92,80,66256,31732,6601556
|
||||||
|
16:47:27.463 [ 77478][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #94 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=407 fail=0]
|
||||||
|
16:47:27.565 [ 77584][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v227 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:28.237 PERF,78270,16.9,4.4,10,6,15,88,92,85,66256,31732,6601556
|
||||||
|
16:47:28.269 [ 78288][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v228 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:28.434 [ 78452][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v229 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:28.958 [ 78977][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v230 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:29.253 PERF,79287,19.6,5.4,12,7,20,78,91,82,66256,31732,6601556
|
||||||
|
16:47:29.482 [ 79502][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v231 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:30.252 PERF,80288,10.9,4.9,12,7,10,92,94,88,66256,31732,6601556
|
||||||
|
16:47:30.578 [ 80598][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v232 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:30.803 [ 80823][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v233 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:30.969 [ 80987][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v234 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:31.162 [ 81182][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v235 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:31.255 PERF,81289,31.9,5.3,12,7,30,67,90,76,66256,31732,6601556
|
||||||
|
16:47:31.715 [ 81737][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v236 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:32.257 [ 82289][I][main.cpp:152] loop(): [LOOP] Heartbeat - system running
|
||||||
|
16:47:32.264 PERF,82296,14.9,4.5,10,6,12,85,94,86,66256,31732,6601556
|
||||||
|
16:47:32.422 [ 82441][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v237 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:32.856 [ 82876][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #119 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=443 fail=0]
|
||||||
|
16:47:32.964 [ 82983][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v238 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:33.269 PERF,83301,21.8,4.8,10,7,20,81,91,82,66256,31732,6601556
|
||||||
|
16:47:33.398 [ 83418][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v239 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:34.267 PERF,84302,9.9,5.0,12,7,9,92,94,89,66256,31732,6601556
|
||||||
|
16:47:35.270 PERF,85303,0.0,0.0,0,0,0,93,96,95,66256,31732,6601556
|
||||||
|
16:47:36.271 PERF,86304,0.0,0.0,0,0,0,92,96,94,66256,31732,6601556
|
||||||
|
16:47:37.288 [ 87319][I][main.cpp:152] loop(): [LOOP] Heartbeat - system running
|
||||||
|
16:47:37.294 PERF,87326,0.9,6.0,6,9,1,89,95,92,66256,31732,6601556
|
||||||
|
16:47:38.122 [ 88143][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #144 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=470 fail=0]
|
||||||
|
16:47:38.294 PERF,88327,0.0,0.0,0,0,0,93,94,95,66256,31732,6601556
|
||||||
|
16:47:38.410 [ 88429][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v239 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:39.295 PERF,89328,0.0,0.0,0,0,0,93,95,94,66256,31732,6601556
|
||||||
|
16:47:40.296 PERF,90329,0.0,0.0,0,0,0,92,96,94,66256,31732,6601556
|
||||||
|
16:47:41.297 PERF,91330,0.0,0.0,0,0,0,91,96,95,66256,31732,6601556
|
||||||
|
16:47:42.301 [ 92332][I][main.cpp:152] loop(): [LOOP] Heartbeat - system running
|
||||||
|
16:47:42.307 PERF,92338,0.0,0.0,0,0,0,91,96,94,66256,31732,6601556
|
||||||
|
16:47:43.306 PERF,93339,0.0,0.0,0,0,0,92,96,94,66256,31732,6601556
|
||||||
|
16:47:43.410 [ 93424][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #169 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=496 fail=0]
|
||||||
|
16:47:43.452 [ 93470][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v239 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:44.422 PERF,94455,6.2,24.0,134,89,61,84,93,79,66256,31732,6601556
|
||||||
|
16:47:45.423 PERF,95455,0.9,6.0,6,17,2,92,96,93,66256,31732,6601556
|
||||||
|
16:47:46.429 PERF,96461,0.0,0.0,0,0,0,93,96,95,66256,31732,6601556
|
||||||
|
16:47:47.331 [ 97362][I][main.cpp:152] loop(): [LOOP] Heartbeat - system running
|
||||||
|
16:47:47.435 PERF,97468,0.0,0.0,0,0,0,92,96,94,66256,31732,6601556
|
||||||
|
16:47:48.476 [ 98495][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v239 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:48.535 PERF,98567,19.1,26.6,34,94,200,9,93,41,66256,31732,6601556
|
||||||
|
16:47:48.676 [ 98690][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #194 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=523 fail=0]
|
||||||
|
16:47:48.759 [cfg] override mode=0 rpm=0 duty=0 (not saved)
|
||||||
|
16:47:48.776 [ 98797][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v240 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:49.558 PERF,99590,8.8,25.7,32,93,88,87,92,70,66256,31732,6601556
|
||||||
|
16:47:49.772 [cfg] override mode=1 rpm=0 duty=0 (not saved)
|
||||||
|
16:47:49.812 [ 99831][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v241 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=1
|
||||||
|
16:47:50.559 PERF,100591,4.9,6.4,8,8,5,86,94,91,66256,31732,6601556
|
||||||
|
16:47:51.589 PERF,101621,9.7,29.0,34,98,109,80,95,65,66256,31732,6601556
|
||||||
|
16:47:52.355 [102386][I][main.cpp:152] loop(): [LOOP] Heartbeat - system running
|
||||||
|
16:47:52.601 PERF,102633,22.7,29.3,36,99,261,44,94,25,66256,31732,6601556
|
||||||
|
16:47:52.793 [cfg] override mode=1 rpm=0 duty=0 (not saved)
|
||||||
|
16:47:52.830 [102849][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v242 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=1
|
||||||
|
16:47:53.502 [cfg] override mode=0 rpm=0 duty=0 (not saved)
|
||||||
|
16:47:53.534 [103554][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v243 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:53.625 PERF,103657,12.6,17.5,34,59,81,89,92,71,66256,31732,6601556
|
||||||
|
16:47:53.975 [103989][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #219 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=552 fail=0]
|
||||||
|
16:47:54.403 [cfg] override mode=2 rpm=0 duty=0 (not saved)
|
||||||
|
16:47:54.437 [104456][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v244 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=2
|
||||||
|
16:47:54.627 PERF,104659,4.9,7.2,12,8,5,92,93,90,66256,31732,6601556
|
||||||
|
16:47:55.684 PERF,105716,12.3,26.0,34,91,125,67,95,61,66256,31732,6601556
|
||||||
|
16:47:56.400 [cfg] override mode=2 rpm=0 duty=0 (not saved)
|
||||||
|
16:47:56.432 [106451][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v245 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=2
|
||||||
|
16:47:56.764 PERF,106796,19.4,25.3,34,91,197,19,93,42,66256,31732,6601556
|
||||||
|
16:47:57.141 [cfg] override mode=0 rpm=0 duty=0 (not saved)
|
||||||
|
16:47:57.158 [107186][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v246 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:47:57.372 [107406][I][main.cpp:152] loop(): [LOOP] Heartbeat - system running
|
||||||
|
16:47:57.776 PERF,107812,5.9,6.6,10,7,5,84,94,90,66256,31732,6601556
|
||||||
|
16:47:58.780 PERF,108813,0.0,0.0,0,0,0,92,96,94,66256,31732,6601556
|
||||||
|
16:47:59.279 [109301][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #244 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=580 fail=0]
|
||||||
|
16:47:59.866 PERF,109898,9.2,24.2,114,81,81,84,94,72,66256,31732,6601556
|
||||||
|
16:48:00.879 PERF,110911,9.8,29.6,32,39,51,63,95,64,66256,31732,6601556
|
||||||
|
16:48:01.975 PERF,112010,4.5,52.0,142,154,76,93,95,71,66256,31732,6601556
|
||||||
|
16:48:02.179 [112197][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v246 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:48:02.389 [112420][I][main.cpp:152] loop(): [LOOP] Heartbeat - system running
|
||||||
|
16:48:03.067 PERF,113099,2.7,48.6,114,181,57,94,94,80,66256,31732,6601556
|
||||||
|
16:48:04.100 PERF,114131,6.7,46.8,276,106,79,45,95,62,66256,31732,6601556
|
||||||
|
16:48:04.561 [114583][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #13 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=606 fail=0]
|
||||||
|
16:48:05.103 PERF,115135,0.0,0.0,0,0,0,91,94,94,66256,31732,6601556
|
||||||
|
16:48:06.107 PERF,116139,0.0,0.0,0,0,0,93,96,94,66256,31732,6601556
|
||||||
|
16:48:07.036 [ota] working - console and screen values pause until done
|
||||||
|
16:48:07.193 [117212][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v246 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:48:07.198 PERF,117214,1.8,82.0,134,329,63,92,95,78,66080,31732,6601556
|
||||||
|
16:48:08.765 [ota] installing v0.1.6 -> app1 (1709280 bytes)
|
||||||
|
16:48:09.855 [119869][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #38 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=632 fail=0]
|
||||||
|
16:48:12.206 [122227][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v246 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:48:12.670 [ota] 0%
|
||||||
|
16:48:15.397 [125372][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #63 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=658 fail=0]
|
||||||
|
16:48:16.508 [ota] 10%
|
||||||
|
16:48:17.241 [127258][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v246 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:48:20.131 [ota] 20%
|
||||||
|
16:48:21.127 [131107][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #88 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=684 fail=0]
|
||||||
|
16:48:22.263 [132282][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v246 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:48:23.917 [ota] 30%
|
||||||
|
16:48:26.655 [136669][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #113 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=710 fail=0]
|
||||||
|
16:48:27.290 [137309][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v246 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:48:27.630 [ota] 40%
|
||||||
|
16:48:31.439 [ota] 50%
|
||||||
|
16:48:32.285 [142262][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #138 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=736 fail=0]
|
||||||
|
16:48:32.358 [142374][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v246 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:48:35.093 [ota] 60%
|
||||||
|
16:48:37.410 [147395][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v246 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:48:37.842 [147824][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #163 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=763 fail=0]
|
||||||
|
16:48:38.668 [ota] 70%
|
||||||
|
16:48:42.029 [ota] 80%
|
||||||
|
16:48:42.449 [152434][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v246 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:48:43.427 [153409][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #188 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=789 fail=0]
|
||||||
|
16:48:45.431 [ota] 90%
|
||||||
|
16:48:47.459 [157447][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v246 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:48:48.896 [ota] 100%
|
||||||
|
16:48:48.914 [158935][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #213 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=815 fail=0]
|
||||||
|
16:48:49.326 [ota] verified and installed v0.1.6. Rebooting in 3 s; it confirms itself after 30 s of uptime.
|
||||||
|
16:48:52.331 [162361][W][STA.cpp:137] _onStaArduinoEvent(): Reason: 8 - ASSOC_LEAVE
|
||||||
|
16:58:59.826 >>> python tools\perf_session.py COM14
|
||||||
|
16:58:59.826 >>> perf off
|
||||||
@@ -0,0 +1,146 @@
|
|||||||
|
16:59:03.876 >>> perf on 1
|
||||||
|
16:59:03.880 [ 30257][I][main.cpp:152] loop(): [LOOP] Heartbeat - system runn[188177][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #107 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=914 fail=0]
|
||||||
|
16:59:03.962 [perf] periodic every 1 s (columns: ts,fps,avg_ms,max_ms,kpx,flush_ms/s,lv_idle,idle0,idle1,int_free,int_largest,psram,vsync/s,vsync_gap_max_us)
|
||||||
|
16:59:04.496 [188793][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v239 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:59:04.948
|
||||||
|
16:59:05.956 PERF,190262,1.0,8.0,8,19,2,91,96,94,66820,31732,6601780,25,41612
|
||||||
|
16:59:06.948 41501
|
||||||
|
16:59:07.195 [191501][I][main.cpp:152] loop(): [LOOP] Heartbeat - system running
|
||||||
|
16:59:07.955 PERF,192262,0.0,0.0,0,0,0,93,96,94,66820,31732,6601780,24,41498
|
||||||
|
16:59:08.534 [ota] working - console and screen values pause until done
|
||||||
|
16:59:08.956 PERF,193262,11.0,7.8,16,25,35,80,94,65,63800,31732,6542036,24,41594
|
||||||
|
16:59:09.170 [193457][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #132 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=940 fail=0]
|
||||||
|
16:59:09.514 [193807][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v239 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:59:09.952 PERF,194262,0.0,0.0,0,0,0,92,89,25,61380,31732,6556892,24,41837
|
||||||
|
16:59:10.230 [ota] running dev | latest release v0.1.6 (1709280 bytes, signature OK) - `ota install` to update
|
||||||
|
16:59:10.234 [ota] loop stack headroom after job: 3556 B
|
||||||
|
16:59:10.956 PERF,195262,6.0,12.3,34,34,24,79,95,61,66320,31732,6601580,24,41591
|
||||||
|
16:59:11.955 PERF,196262,0.0,0.0,0,0,0,91,96,94,66320,31732,6601580,24,41500
|
||||||
|
16:59:12.237 [196543][I][main.cpp:152] loop(): [LOOP] Heartbeat - system running
|
||||||
|
16:59:12.955 PERF,197262,0.0,0.0,0,0,0,91,96,94,66320,31732,6601580,24,41511
|
||||||
|
16:59:13.956 PERF,198262,1.0,116.0,116,614,64,0,96,83,66320,31732,6601580,24,41584
|
||||||
|
16:59:14.069 [198374][I][tuning_screen.cpp:558] build(): [Tuning] Gauge tuning screen built
|
||||||
|
16:59:14.455 [198742][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #157 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=966 fail=0]
|
||||||
|
16:59:14.521 [198819][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v239 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:59:14.956 PERF,199262,2.0,154.0,302,310,64,92,92,54,66320,31732,6601580,24,41625
|
||||||
|
16:59:15.955 PERF,200262,0.0,0.0,0,0,0,91,96,95,66320,31732,6601580,25,41497
|
||||||
|
16:59:16.399 [200694][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v240 (changed): ppr=2 trim=-12 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:59:16.595 [200888][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v241 (changed): ppr=2 trim=-11 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:59:16.819 [201112][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v242 (changed): ppr=2 trim=-10 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:59:16.955 PERF,201262,26.0,4.8,14,7,26,74,91,79,66320,31732,6601580,24,41721
|
||||||
|
16:59:17.301 [201607][I][main.cpp:152] loop(): [LOOP] Heartbeat - system running
|
||||||
|
16:59:17.733 [202027][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v243 (changed): ppr=2 trim=-11 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:59:17.955 PERF,202262,8.0,5.0,10,7,7,82,94,89,66320,31732,6601580,24,41645
|
||||||
|
16:59:17.988 [202281][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v244 (changed): ppr=2 trim=-12 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:59:18.209 [202504][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v245 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:59:18.955 PERF,203262,14.0,4.8,12,7,13,91,93,86,66320,31732,6601580,24,41563
|
||||||
|
16:59:19.790 [204079][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #182 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=998 fail=0]
|
||||||
|
16:59:19.955 PERF,204262,0.0,0.0,0,0,0,92,94,95,66320,31732,6601580,24,41505
|
||||||
|
16:59:20.956 PERF,205262,7.0,24.2,134,83,66,90,95,78,66320,31732,6601580,24,41504
|
||||||
|
16:59:21.956 PERF,206262,11.0,13.2,96,58,65,64,95,78,66320,31732,6601580,24,41508
|
||||||
|
16:59:22.316 [206622][I][main.cpp:152] loop(): [LOOP] Heartbeat - system running
|
||||||
|
16:59:22.955 PERF,207262,6.0,6.3,8,16,14,91,96,90,66320,31732,6601580,24,41729
|
||||||
|
16:59:23.227 [207519][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v245 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:59:23.889 [cfg] override mode=1 rpm=0 duty=0 (not saved)
|
||||||
|
16:59:23.931 [208224][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v246 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=1
|
||||||
|
16:59:23.953 PERF,208262,5.0,33.2,136,114,66,63,92,77,66320,31732,6601580,24,41751
|
||||||
|
16:59:24.955 PERF,209262,3.0,14.0,32,38,13,89,96,90,66320,31732,6601580,24,41498
|
||||||
|
16:59:25.084 [209379][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #207 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=1025 fail=0]
|
||||||
|
16:59:25.330 [cfg] override mode=1 rpm=3952 duty=0 (not saved)
|
||||||
|
16:59:25.365 [209665][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v247 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=1
|
||||||
|
16:59:25.956 PERF,210262,14.0,23.7,34,86,135,28,92,59,66320,31732,6601580,25,41597
|
||||||
|
16:59:26.728 [cfg] override mode=0 rpm=3952 duty=0 (not saved)
|
||||||
|
16:59:26.759 [211059][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v248 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:59:26.951 PERF,211262,5.0,6.4,8,8,5,92,95,91,66320,31732,6601580,24,41537
|
||||||
|
16:59:27.389 [211694][I][main.cpp:152] loop(): [LOOP] Heartbeat - system running
|
||||||
|
16:59:27.955 PERF,212262,10.0,29.6,36,98,121,0,95,60,66320,31732,6601580,24,41556
|
||||||
|
16:59:27.992 [cfg] override mode=0 rpm=0 duty=0 (not saved)
|
||||||
|
16:59:28.033 [212333][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v249 (changed): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:59:28.952 PERF,213262,5.0,17.2,32,71,31,83,94,88,66320,31732,6601580,24,41501
|
||||||
|
16:59:29.949 ,41617
|
||||||
|
16:59:30.399 [214688][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #232 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=1053 fail=0]
|
||||||
|
16:59:30.956 PERF,215262,1.0,138.0,138,614,62,64,94,80,66320,31732,6601580,24,41599
|
||||||
|
16:59:31.956 PERF,216262,1.0,8.0,8,27,3,0,96,92,66320,31732,6601580,24,41498
|
||||||
|
16:59:32.476 [216782][I][main.cpp:152] loop(): [LOOP] Heartbeat - system running
|
||||||
|
16:59:32.956 PERF,217262,3.0,46.0,120,163,68,0,96,77,66320,31732,6601580,24,41506
|
||||||
|
16:59:33.051 [217345][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v249 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:59:33.957 PERF,218262,7.0,22.0,116,82,92,0,94,61,66320,31732,6601580,24,41602
|
||||||
|
16:59:34.955 PERF,219262,2.0,147.0,278,318,26,91,96,86,66320,31732,6601580,24,41660
|
||||||
|
16:59:35.681 [219970][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #1 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=1079 fail=0]
|
||||||
|
16:59:35.729 [ota] working - console and screen values pause until done
|
||||||
|
16:59:35.956 PERF,220262,4.0,46.5,140,176,77,86,94,73,63800,31732,6558824,25,41725
|
||||||
|
16:59:36.955 PERF,221262,0.0,0.0,0,0,0,91,92,22,61428,31732,6550072,24,41637
|
||||||
|
16:59:37.503 [ota] installing v0.1.6 -> app1 (1709280 bytes)
|
||||||
|
16:59:37.958 PERF,222262,1.0,160.0,160,614,70,64,94,39,66320,31732,6601580,24,42322
|
||||||
|
16:59:38.063 [222356][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v249 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:59:38.955 PERF,223262,0.0,0.0,0,0,0,93,94,94,66320,31732,6601580,24,41525
|
||||||
|
16:59:39.956 PERF,224262,0.0,0.0,0,0,0,92,96,95,66320,31732,6601580,24,41510
|
||||||
|
16:59:40.963 [225251][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #26 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=1105 fail=0]
|
||||||
|
16:59:41.250 [ota] 0%
|
||||||
|
16:59:41.969 PERF,226271,0.0,0.0,0,0,0,95,43,26,59376,31732,6544660,5,331969
|
||||||
|
16:59:42.972 PERF,227278,0.0,0.0,0,0,0,96,37,28,59376,31732,6542356,4,747276
|
||||||
|
16:59:43.098 [227385][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v249 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:59:43.994 PERF,228297,0.0,0.0,0,0,0,91,37,29,59376,31732,6544768,6,373448
|
||||||
|
16:59:44.956 PERF,229262,0.0,0.0,0,0,0,96,39,31,59376,31732,6556888,6,291250
|
||||||
|
16:59:45.138 [ota] 10%
|
||||||
|
16:59:45.956 PERF,230262,0.0,0.0,0,0,0,82,32,23,59376,31732,6556876,5,331968
|
||||||
|
16:59:46.683 [230982][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #51 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=1131 fail=0]
|
||||||
|
16:59:46.990 PERF,231295,0.0,0.0,0,0,0,93,33,27,59376,31732,6542384,4,331968
|
||||||
|
16:59:47.973 PERF,232283,0.0,0.0,0,0,0,85,37,29,59376,31732,6544788,6,331969
|
||||||
|
16:59:48.110 [232411][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v249 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:59:48.743 [ota] 20%
|
||||||
|
16:59:48.954 PERF,233264,0.0,0.0,0,0,0,94,35,27,59376,31732,6544804,4,331969
|
||||||
|
16:59:49.952 PERF,234262,0.0,0.0,0,0,0,95,39,31,59376,31732,6547224,6,331969
|
||||||
|
16:59:50.965 PERF,235274,0.0,0.0,0,0,0,93,36,28,59376,31732,6547216,4,331967
|
||||||
|
16:59:51.952 PERF,236262,0.0,0.0,0,0,0,95,33,25,59376,31732,6552048,4,331969
|
||||||
|
16:59:52.227 [236529][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #76 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=1157 fail=0]
|
||||||
|
16:59:52.392 [ota] 30%
|
||||||
|
16:59:52.952 PERF,237262,0.0,0.0,0,0,0,91,33,25,59156,31732,6551976,4,331968
|
||||||
|
16:59:53.123 [237416][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v249 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:59:53.990 PERF,238295,0.0,0.0,0,0,0,96,33,26,59376,31732,6544788,6,331968
|
||||||
|
16:59:54.960 PERF,239269,0.0,0.0,0,0,0,94,44,36,59376,31732,6547188,8,331969
|
||||||
|
16:59:55.957 PERF,240262,0.0,0.0,0,0,0,94,36,30,59376,31732,6556876,7,331968
|
||||||
|
16:59:56.222 [ota] 40%
|
||||||
|
16:59:56.979 PERF,241286,0.0,0.0,0,0,0,95,33,25,59376,31732,6542304,5,331968
|
||||||
|
16:59:57.960 PERF,242264,0.0,0.0,0,0,0,95,44,34,59376,31732,6547100,7,332029
|
||||||
|
16:59:58.020 [242287][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #101 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=1183 fail=0]
|
||||||
|
16:59:58.156 [242459][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v249 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
16:59:58.986 PERF,243293,0.0,0.0,0,0,0,94,32,24,59376,31732,6544660,4,331968
|
||||||
|
17:00:00.068 PERF,244262,0.0,0.0,0,0,0,0,34,26,59376,31732,6549452,5,331802
|
||||||
|
17:00:00.069 [ota] 50%
|
||||||
|
17:00:00.988 PERF,245297,0.0,0.0,0,0,0,94,35,27,59376,31732,6542348,6,331968
|
||||||
|
17:00:01.958 PERF,246268,0.0,0.0,0,0,0,97,34,26,59376,31732,6542388,6,290838
|
||||||
|
17:00:02.984 PERF,247289,0.0,0.0,0,0,0,95,37,29,59376,31732,6547224,4,331969
|
||||||
|
17:00:03.186 [247487][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v249 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
17:00:03.585 [247886][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #126 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=1210 fail=0]
|
||||||
|
17:00:03.876 [ota] 60%
|
||||||
|
17:00:03.953 PERF,248262,0.0,0.0,0,0,0,94,35,29,59376,31732,6556876,7,331968
|
||||||
|
17:00:04.948
|
||||||
|
17:00:05.956 PERF,250262,0.0,0.0,0,0,0,94,37,28,59376,31732,6556888,7,290482
|
||||||
|
17:00:06.958 PERF,251262,0.0,0.0,0,0,0,95,39,30,59376,31732,6556892,6,290844
|
||||||
|
17:00:07.248 [ota] 70%
|
||||||
|
17:00:07.956 PERF,252262,0.0,0.0,0,0,0,90,39,29,59376,31732,6556876,6,290471
|
||||||
|
17:00:08.233 [252497][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v249 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
17:00:08.953 PERF,253262,0.0,0.0,0,0,0,93,35,26,59376,31732,6556876,4,331971
|
||||||
|
17:00:09.128 [253396][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #151 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=1236 fail=0]
|
||||||
|
17:00:10.835 PERF,254262,0.0,0.0,0,0,0,0,38,30,59376,31732,6556876,6,291034
|
||||||
|
17:00:10.836 [ota] 80%
|
||||||
|
17:00:10.956 PERF,255262,0.0,0.0,0,0,0,95,38,28,59376,31732,6556876,7,291116
|
||||||
|
17:00:11.951 PERF,256262,0.0,0.0,0,0,0,86,37,29,59376,31732,6556876,6,290473
|
||||||
|
17:00:12.948
|
||||||
|
17:00:13.226 [257521][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v249 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
17:00:13.949
|
||||||
|
17:00:14.257 [ota] 90%
|
||||||
|
17:00:14.616 [258876][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #176 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=1262 fail=0]
|
||||||
|
17:00:14.952 PERF,259262,0.0,0.0,0,0,0,95,39,33,59376,31732,6547200,6,290474
|
||||||
|
17:00:15.955 PERF,260262,0.0,0.0,0,0,0,94,38,29,59376,31732,6544784,5,290836
|
||||||
|
17:00:16.955 PERF,261262,0.0,0.0,0,0,0,95,39,30,59376,31732,6556888,7,290894
|
||||||
|
17:00:17.623 [ota] 100%
|
||||||
|
17:00:17.956 PERF,262262,0.0,0.0,0,0,0,95,53,17,66068,31732,6601536,10,373467
|
||||||
|
17:00:18.049 [ota] verified and installed v0.1.6. Rebooting in 3 s; it confirms itself after 30 s of uptime.
|
||||||
|
17:00:18.234 [262527][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v249 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
17:00:18.958 PERF,263262,1.0,148.0,148,614,65,65,91,72,66320,31732,6601580,22,124588
|
||||||
|
17:00:20.072 PERF,264262,0.0,0.0,0,0,0,0,96,94,66320,31732,6601580,24,41564
|
||||||
|
17:00:20.095 [264372][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #201 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=1288 fail=0]
|
||||||
|
17:00:20.949
|
||||||
|
17:00:21.051 [265359][W][STA.cpp:137] _onStaArduinoEvent(): Reason: 8 - ASSOC_LEAVE
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
17:46:18.747 >>> perf on 1
|
||||||
|
17:46:18.831 [ 23256][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] [perf] periodic every 1 s (columns: ts,fps,avg_ms,max_ms,kpx,flush_ms/s,lv_idle,idle0,idle1,int_free,int_largest,psram,vsync/s,vsync_gap_max_us)
|
||||||
|
17:46:19.228 [ 60516][I][main.cpp:152] loop(): [LOOP] Heartbeat - system running
|
||||||
|
17:46:19.828 PERF,61113,0.0,0.0,0,0,0,100,96,95,63268,31732,4891400,24,41576
|
||||||
|
17:46:19.941 [ 61220][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #19 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=289 fail=0]
|
||||||
|
17:46:21.826 PERF,62113,0.0,0.0,0,0,0,99,95,96,63268,31732,4891400,24,41496
|
||||||
|
17:46:21.830 PERF,63113,0.0,0.0,0,0,0,100,96,96,63268,31732,4891400,24,41498
|
||||||
|
17:46:22.054 [ 63336][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v245 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
17:46:22.827 PERF,64113,0.0,0.0,0,0,0,100,95,96,63268,31732,4891400,24,41497
|
||||||
|
17:46:22.827 >>> wifi status
|
||||||
|
17:46:22.850 [wifi] connected to 'ArtServis', IP 10.0.10.104, RSSI -53 dBm, channel 1
|
||||||
|
17:46:22.851 [wifi] saved network: ArtServis
|
||||||
|
17:46:22.853 [wifi] ESP-NOW ready, sent 303, failed 0
|
||||||
|
17:46:23.826 PERF,65113,0.0,0.0,0,0,0,100,96,96,63268,31732,4891400,24,41510
|
||||||
|
17:46:24.256 [ 65543][I][main.cpp:152] loop(): [LOOP] Heartbeat - system running
|
||||||
|
17:46:24.826 PERF,66113,0.0,0.0,0,0,0,100,96,95,63268,31732,4891400,24,41500
|
||||||
|
17:46:25.033 >>> ota install force
|
||||||
|
17:46:25.067 [ota] working - console and screen values pause until done
|
||||||
|
17:46:25.226 [ 66500][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #44 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=315 fail=0]
|
||||||
|
17:46:26.585 PERF,67113,0.0,0.0,0,0,0,99,92,50,57880,31732,4839564,24,41604
|
||||||
|
17:46:26.588 [ota] installing v0.1.6 -> app1 (1709280 bytes)
|
||||||
|
17:46:26.831 PERF,68113,1.0,142.0,142,614,67,100,95,18,62772,31732,4888752,24,41569
|
||||||
|
17:46:27.067 [ 68349][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v245 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
17:46:28.831 PERF,70113,0.0,0.0,0,0,0,100,96,96,62772,31732,4891200,24,41497
|
||||||
|
17:46:29.827 PERF,71113,0.0,0.0,0,0,0,100,96,83,60124,31732,4831640,25,41598
|
||||||
|
17:46:30.304 [ota] 0%
|
||||||
|
17:46:30.507 [ 71784][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #69 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=341 fail=0]
|
||||||
|
17:46:30.826 PERF,72113,0.0,0.0,0,0,0,100,91,25,55828,31732,4836836,24,41504
|
||||||
|
17:46:31.826 PERF,73113,0.0,0.0,0,0,0,100,92,30,55828,31732,4836836,24,41496
|
||||||
|
17:46:32.083 [ 73365][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v245 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
17:46:33.728 PERF,74113,0.0,0.0,0,0,0,99,91,30,55828,31732,4834420,24,41515
|
||||||
|
17:46:33.728 [ota] 10%
|
||||||
|
17:46:33.826 PERF,75113,0.0,0.0,0,0,0,99,93,30,55828,31732,4834420,24,41496
|
||||||
|
17:46:34.824
|
||||||
|
17:46:35.801 [ 77080][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #94 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=367 fail=0]
|
||||||
|
17:46:36.825 PERF,77113,0.0,0.0,0,0,0,99,91,33,55828,31732,4846500,24,41499
|
||||||
|
17:46:36.827
|
||||||
|
17:46:37.016 [ota] 20%
|
||||||
|
17:46:37.113 [ 78386][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v245 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
17:46:37.828 PERF,79113,0.0,0.0,0,0,0,100,91,29,55828,31732,4834420,24,41497
|
||||||
|
17:46:38.831 PERF,80113,0.0,0.0,0,0,0,100,92,29,55828,31732,4834420,24,41500
|
||||||
|
17:46:40.443 PERF,81113,0.0,0.0,0,0,0,99,92,37,55828,31732,4836836,25,41503
|
||||||
|
17:46:40.444 [ota] 30%
|
||||||
|
17:46:40.827 PERF,82113,0.0,0.0,0,0,0,100,92,28,55828,31732,4832004,24,41525
|
||||||
|
17:46:41.090 [ 82368][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #119 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=393 fail=0]
|
||||||
|
17:46:41.826 PERF,83113,0.0,0.0,0,0,0,100,91,29,55828,31732,4846500,24,41539
|
||||||
|
17:46:42.122 [ 83404][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v245 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
17:46:42.826 PERF,84113,0.0,0.0,0,0,0,100,91,30,55828,31732,4846500,24,41497
|
||||||
|
17:46:43.786 [ota] 40%
|
||||||
|
17:46:44.827 PERF,85113,0.0,0.0,0,0,0,99,92,29,55828,31732,4846500,24,41611
|
||||||
|
17:46:44.829 PERF,86113,0.0,0.0,0,0,0,100,92,30,55828,31732,4846500,24,41565
|
||||||
|
17:46:46.379 PERF,87113,0.0,0.0,0,0,0,99,92,32,55620,31732,4841636,24,41560
|
||||||
|
17:46:46.396 [ 87657][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #144 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=419 fail=0]
|
||||||
|
17:46:47.143 [ 88424][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v245 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
17:46:47.181 [ota] 50%
|
||||||
|
17:46:47.826 PERF,89113,0.0,0.0,0,0,0,100,91,27,55828,31732,4834420,24,41697
|
||||||
|
17:46:48.829 PERF,90113,0.0,0.0,0,0,0,99,92,30,55828,31732,4836836,24,41498
|
||||||
|
17:46:49.827 PERF,91113,0.0,0.0,0,0,0,100,92,27,55828,31732,4834420,25,41507
|
||||||
|
17:46:50.527 [ota] 60%
|
||||||
|
17:46:50.830 PERF,92113,0.0,0.0,0,0,0,100,92,30,55828,31732,4834420,24,41497
|
||||||
|
17:46:51.669 [ 92948][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #169 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=445 fail=0]
|
||||||
|
17:46:52.164 PERF,93113,0.0,0.0,0,0,0,99,91,32,55828,31732,4846500,24,41579
|
||||||
|
17:46:52.171 [ 93445][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v245 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
17:46:52.825 55828,31732,4841668,24,41499
|
||||||
|
17:46:53.782 [ota] 70%
|
||||||
|
17:46:54.827 PERF,95113,0.0,0.0,0,0,0,99,92,30,55828,31732,4832004,24,41634
|
||||||
|
17:46:55.830 PERF,97113,0.0,0.0,0,0,0,0,92,37,55828,31732,4844084,24,41496
|
||||||
|
17:46:56.801 [ota] 80%
|
||||||
|
17:46:56.831 PERF,98113,0.0,0.0,0,0,0,99,92,29,55828,31732,4829588,24,41505
|
||||||
|
17:46:56.967 [ 98241][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #194 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=471 fail=0]
|
||||||
|
17:46:57.186 [ 98467][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v245 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
17:46:57.826 PERF,99113,0.0,0.0,0,0,0,0,90,32,55828,31732,4846500,24,41528
|
||||||
|
17:46:58.828 PERF,100113,0.0,0.0,0,0,0,100,91,34,55828,31732,4829492,24,41522
|
||||||
|
17:46:59.825 P
|
||||||
|
17:46:59.903 [ota] 90%
|
||||||
|
17:47:01.025 P
|
||||||
|
17:47:01.826 ERF,102113,0.0,0.0,0,0,0,99,93,32,55828,31732,4846500,24,41548
|
||||||
|
17:47:01.828 PERF,103113,0.0,0.0,0,0,0,100,92,38,55828,31732,4846500,24,41715
|
||||||
|
17:47:02.196 [103478][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v245 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
17:47:02.273 [103552][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #219 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=498 fail=0]
|
||||||
|
17:47:02.830 PERF,104113,0.0,0.0,0,0,0,99,89,30,55828,31732,4834412,24,41610
|
||||||
|
17:47:03.055 [ota] 100%
|
||||||
|
17:47:03.458 [ota] verified and installed v0.1.6. Rebooting in 3 s; it confirms itself after 30 s of uptime.
|
||||||
|
17:47:03.827 PERF,105113,1.0,128.0,128,614,62,73,95,28,62772,31732,4891200,24,41616
|
||||||
|
17:47:04.828 PERF,106113,0.0,0.0,0,0,0,99,96,96,62772,31732,4891200,24,41496
|
||||||
|
17:47:05.831 PERF,107113,0.0,0.0,0,0,0,100,96,96,62552,31732,4891200,24,41496
|
||||||
|
17:47:06.457 [107742][W][STA.cpp:137] _onStaArduinoEvent(): Reason: 8 - ASSOC_LEAVE
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
17:55:22.250 [ 23254][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v245 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
17:55:23.071 >>> perf on 1
|
||||||
|
17:55:23.091 [perf] periodic every 1 s (columns: ts,fps,avg_ms,max_ms,kpx,flush_ms/s,lv_idle,idle0,idle1,int_free,int_largest,psram,vsync/s,vsync_gap_max_us)
|
||||||
|
17:55:23.260 [ 24258][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #100 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=107 fail=0]
|
||||||
|
17:55:24.081 PERF,25097,0.0,0.0,0,0,0,100,95,98,63452,31732,4891400,23,41498
|
||||||
|
17:55:24.092 [ 25098][I][main.cpp:152] loop(): [LOOP] Heartbeat - system running
|
||||||
|
17:55:25.084 PERF,26097,0.0,0.0,0,0,0,0,96,97,63452,31732,4891400,24,41496
|
||||||
|
17:55:26.082 PERF,27097,0.0,0.0,0,0,0,100,96,97,63452,31732,4891400,24,41498
|
||||||
|
17:55:27.085 PERF,28097,0.0,0.0,0,0,0,100,96,97,63452,31732,4891400,24,41496
|
||||||
|
17:55:27.085 >>> wifi status
|
||||||
|
17:55:27.094 [wifi] connected to 'ArtServis', IP 10.0.10.104, RSSI -51 dBm, channel 1
|
||||||
|
17:55:27.096 [wifi] saved network: ArtServis
|
||||||
|
17:55:27.100 [wifi] ESP-NOW ready, sent 125, failed 0
|
||||||
|
17:55:27.252 [ 28264][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v245 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
17:55:28.080 PERF,29097,0.0,0.0,0,0,0,100,95,98,63452,31732,4891400,24,41497
|
||||||
|
17:55:28.541 [ 29538][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #125 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=133 fail=0]
|
||||||
|
17:55:29.085 PERF,30097,0.0,0.0,0,0,0,100,95,97,63452,31732,4891400,24,41519
|
||||||
|
17:55:29.094 [ 30106][I][main.cpp:152] loop(): [LOOP] Heartbeat - system running
|
||||||
|
17:55:29.094 >>> ota install force
|
||||||
|
17:55:29.200 [ota] working - console and screen values pause until done
|
||||||
|
17:55:30.083 PERF,31097,0.0,0.0,0,0,0,100,93,38,58044,31732,4831368,24,41563
|
||||||
|
17:55:30.673 [ota] installing v0.1.6 -> app1 (1709280 bytes)
|
||||||
|
17:55:31.081 PERF,32097,1.0,118.0,118,614,63,100,95,18,60296,31732,4831628,24,41523
|
||||||
|
17:55:31.526 [ota] 0%
|
||||||
|
17:55:32.085 PERF,33097,2.0,7.0,10,15,2,100,93,29,56000,31732,4836832,24,41504
|
||||||
|
17:55:32.269 [ 33278][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v245 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
17:55:33.083 PERF,34097,3.0,12.0,12,27,9,98,91,36,56000,31732,4832004,25,41629
|
||||||
|
17:55:33.825 [ 34824][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #150 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=159 fail=0]
|
||||||
|
17:55:34.084 PERF,35097,2.0,11.0,12,27,6,98,91,34,56000,31732,4844072,24,41500
|
||||||
|
17:55:35.085 PERF,36097,3.0,10.0,10,27,8,98,93,35,56000,31732,4844072,24,41590
|
||||||
|
17:55:35.124 [ota] 10%
|
||||||
|
17:55:36.085 PERF,37097,3.0,12.0,12,27,9,98,93,33,56000,31732,4846492,24,41499
|
||||||
|
17:55:37.083 PERF,38097,3.0,11.3,12,27,7,96,92,32,56000,31732,4846492,24,41501
|
||||||
|
17:55:37.292 [ 38299][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v245 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
17:55:38.082 PERF,39097,3.0,12.0,12,27,9,95,91,34,56000,31732,4846492,24,41499
|
||||||
|
17:55:38.608 [ota] 20%
|
||||||
|
17:55:39.079 PERF,461
|
||||||
|
17:55:39.109 [ 40114][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #175 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=185 fail=0]
|
||||||
|
17:55:40.082 PERF,41097,3.0,10.0,10,28,7,98,91,32,56000,31732,4844084,24,41609
|
||||||
|
17:55:41.083 PERF,42097,3.0,12.0,12,28,9,98,92,29,56000,31732,4844076,24,41516
|
||||||
|
17:55:42.082 PERF,43097,2.0,11.0,12,28,5,97,92,29,56000,31732,4834412,24,41527
|
||||||
|
17:55:42.091 [ota] 30%
|
||||||
|
17:55:42.304 [ 43315][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v245 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
17:55:43.081 PERF,44097,3.0,12.0,12,28,9,96,91,35,56000,31732,4836824,25,41496
|
||||||
|
17:55:44.083 PERF,45097,3.0,12.6,14,28,8,95,93,33,56000,31732,4841672,24,41513
|
||||||
|
17:55:44.403 [ 45411][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #200 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=211 fail=0]
|
||||||
|
17:55:45.085 PERF,46097,3.0,11.3,12,28,9,95,90,31,56000,31732,4834404,24,41599
|
||||||
|
17:55:45.584 [ota] 40%
|
||||||
|
17:55:46.084 PERF,47097,3.0,11.3,12,28,8,98,93,34,54364,31732,4844072,24,41767
|
||||||
|
17:55:47.082 PERF,48097,3.0,10.6,12,28,7,98,93,31,56000,31732,4846492,24,41594
|
||||||
|
17:55:47.339 [ 48341][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v245 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
17:55:48.085 PERF,49097,3.0,10.6,12,28,9,98,92,31,56000,31732,4846492,24,41563
|
||||||
|
17:55:49.028 [ota] 50%
|
||||||
|
17:55:49.083 PERF,50097,3.0,11.3,12,28,8,98,93,29,56000,31732,4846492,24,41499
|
||||||
|
17:55:49.699 [ 50696][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #225 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=237 fail=0]
|
||||||
|
17:55:50.081 PERF,51097,2.0,12.0,12,28,6,98,91,31,56000,31732,4846504,24,41634
|
||||||
|
17:55:51.081 PERF,52097,3.0,10.6,12,28,7,96,93,33,56000,31732,4846504,24,41500
|
||||||
|
17:55:52.083 PERF,53097,3.0,11.3,12,28,8,0,92,31,56000,31732,4846504,24,41611
|
||||||
|
17:55:52.348 [ 53354][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v245 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
17:55:52.655 [ota] 60%
|
||||||
|
17:55:53.081 PERF,54097,3.0,11.3,12,28,8,96,91,33,56000,31732,4834408,24,41549
|
||||||
|
17:55:54.081 PERF,55097,3.0,12.0,12,28,9,95,92,37,56000,31732,4846492,24,41607
|
||||||
|
17:55:54.982 [ 55989][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #250 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=263 fail=0]
|
||||||
|
17:55:55.085 PERF,56097,3.0,11.3,12,28,8,99,90,35,56000,31732,4844076,24,41505
|
||||||
|
17:55:55.876 [ota] 70%
|
||||||
|
17:55:56.085 PERF,57097,3.0,11.3,12,28,8,96,92,29,56000,31732,4834416,24,41516
|
||||||
|
17:55:57.083 PERF,58097,3.0,11.3,12,28,8,95,93,35,56000,31732,4836820,24,41543
|
||||||
|
17:55:57.375 [ 58384][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v245 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
17:55:58.086 PERF,59097,3.0,11.3,12,28,9,98,91,31,56000,31732,4831984,24,41498
|
||||||
|
17:55:59.082 PERF,60097,3.0,10.6,12,28,6,97,92,35,56000,31732,4846492,24,41570
|
||||||
|
17:55:59.236 [ota] 80%
|
||||||
|
17:56:00.079 6
|
||||||
|
17:56:00.272 [ 61279][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #19 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=289 fail=0]
|
||||||
|
17:56:01.085 PERF,62097,3.0,11.3,12,28,8,96,91,36,56000,31732,4841656,24,41652
|
||||||
|
17:56:02.085 PERF,63097,3.0,11.3,12,28,9,98,92,35,56000,31732,4829588,24,41566
|
||||||
|
17:56:02.394 [ 63398][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v245 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
17:56:02.474 [ota] 90%
|
||||||
|
17:56:03.082 PERF,64097,3.0,11.3,12,28,9,98,91,32,56000,31732,4829576,24,41506
|
||||||
|
17:56:04.079 7
|
||||||
|
17:56:05.082 PERF,66097,3.0,12.0,12,28,7,96,92,35,56000,31732,4846492,24,41499
|
||||||
|
17:56:05.568 [ 66574][I][uart_manager.cpp:126] sendDataFrame(): [UARTTask] TX #44 gear=P(t0/e0) rpm=0 cool=89.0 gb=85.0 batt=12.45 alerts=0x00 valid=0x3F [27 B uart+espnow, espnow tx=315 fail=0]
|
||||||
|
17:56:05.644 [ota] 100%
|
||||||
|
17:56:06.045 [ota] verified and installed v0.1.6. Rebooting in 3 s; it confirms itself after 30 s of uptime.
|
||||||
|
17:56:06.081 PERF,67097,3.0,12.0,12,28,29,0,92,14,62964,31732,4891196,24,41503
|
||||||
|
17:56:07.082 PERF,68097,1.0,112.0,112,614,42,100,96,90,62964,31732,4891200,24,41504
|
||||||
|
17:56:07.410 [ 68420][I][uart_manager.cpp:158] sendConfigFrame(): [UARTTask] TX CONFIG v245 (periodic): ppr=2 trim=-13 temp_hz=20000 slope=150 offset=50 min=40 override=0
|
||||||
|
17:56:08.082 PERF,69097,0.0,0.0,0,0,0,100,95,98,62964,31732,4891200,24,41498
|
||||||
|
17:56:09.050 [ 70065][W][STA.cpp:137] _onStaArduinoEvent(): Reason: 8 - ASSOC_LEAVE
|
||||||
@@ -6,7 +6,7 @@ updated: 2026-09-23
|
|||||||
|
|
||||||
# Route A probe — first live run (2026-09-23)
|
# Route A probe — first live run (2026-09-23)
|
||||||
|
|
||||||
First execution of the [[obd-diagnostic-polling]] Route A test: the `diag` console probe on Controller A, engine idling, Launch unplugged, tapped PT-CAN. Two sessions, raw console logs (CANRAW + CANTX + diag output interleaved):
|
First execution of the [[obd-diagnostic-polling]] Route A test: the `diag` console probe on Main CTRL, engine idling, Launch unplugged, tapped PT-CAN. Two sessions, raw console logs (CANRAW + CANTX + diag output interleaved):
|
||||||
|
|
||||||
- `raw/diag-20260923-111737.log` — `pids`, `pid 0C`, `pid 05`, `pid 0B`, `pid 70`, `vin`, `ecu`, `status`
|
- `raw/diag-20260923-111737.log` — `pids`, `pid 0C`, `pid 05`, `pid 0B`, `pid 70`, `vin`, `ecu`, `status`
|
||||||
- `raw/diag-20260923-111851.log` — `pid 10`, `pid 04`, `pid 0F`, `pid 0D`, `pid 1C`, `pid 01`, `pid 21`, `status`
|
- `raw/diag-20260923-111851.log` — `pid 10`, `pid 04`, `pid 0F`, `pid 0D`, `pid 1C`, `pid 01`, `pid 21`, `status`
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ raw: raw/ESP32-S3-Touch-LCD-5-details-intro.jpg
|
|||||||
|
|
||||||
## Relevance
|
## Relevance
|
||||||
|
|
||||||
- Confirms the terminal-block signal set and that the RS485 pair is the only UART1 exit → `(sibling: 1.3 wiki → controller-link)` open question #1 on how the wire to Controller B is really made
|
- Confirms the terminal-block signal set and that the RS485 pair is the only UART1 exit → `(sibling: 1.3 wiki → controller-link)` open question #1 on how the wire to Inst. Cluster is really made
|
||||||
- Confirms one shared termination switch for CAN and RS485 — keep it **OFF** when tapping the vehicle CAN bus, which also leaves the RS485 link unterminated on this end
|
- Confirms one shared termination switch for CAN and RS485 — keep it **OFF** when tapping the vehicle CAN bus, which also leaves the RS485 link unterminated on this end
|
||||||
- Strapping pads IO0/IO3/IO4/IO46 exist as solder points — the only bare GPIO access on the board, and all four are already committed (G3, VSYNC, CTP_IRQ, HSYNC)
|
- Strapping pads IO0/IO3/IO4/IO46 exist as solder points — the only bare GPIO access on the board, and all four are already committed (G3, VSYNC, CTP_IRQ, HSYNC)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
---
|
||||||
|
type: source
|
||||||
|
tags: [hardware, waveshare, schematic, power, i2c, verified-source]
|
||||||
|
updated: 2026-09-26
|
||||||
|
---
|
||||||
|
|
||||||
|
# Waveshare ESP32-S3-Touch-LCD-5 schematic (`ESP32-S3-Touch-LCD-5-Sch.pdf`)
|
||||||
|
|
||||||
|
Raw: `raw/ESP32-S3-Touch-LCD-5-Sch.pdf` (3 sheets, V1.2), re-downloaded 2026-09-26 from `https://files.waveshare.com/wiki/ESP32-S3-Touch-LCD-5/ESP32-S3-Touch-LCD-5-Sch.pdf`. The LCD-5 and LCD-5B share this sheet (the B is the 1024×600 panel variant). Its net list was read once in the 2026-09-21 session and then lost; this copy is the one to keep. Read for the **VOUT question** (2026-09-26); the rest of the sheet is only indexed here.
|
||||||
|
|
||||||
|
## VOUT / I2C_VCC selection — answered
|
||||||
|
|
||||||
|
- Terminal block `P1` pin 3 (silkscreen **VOUT**) is net **`I2C_VCC`** (sheet 1, the 16-way header: `VIN GND I2C_VCC GND D_SDA D_SCL CANL CANH RS485_TX- RS485_TX+ DOUT0 DOUT1 DI_COM GND DIN0 DIN1`).
|
||||||
|
- `I2C_VCC` is chosen by **`H8`, a three-pad solder jumper**, not a resistor: pad 1 = `3V3`, pad 2 (centre) = `I2C_VCC`, pad 3 = `5V`. Sheet note: *"The default paste is 3V3"* — the factory solder bridge joins pads 1–2.
|
||||||
|
- **To get 5 V on VOUT: remove the bridge between pads 1–2 and bridge pads 2–3.** Never leave all three joined (it shorts the 3.3 V regulator output to the 5 V rail).
|
||||||
|
- The external SDA/SCL are **level-shifted** through `M1` (NDC7002N dual MOSFET) with 4.7 kΩ pull-ups `R101`/`R102` to `I2C_VCC` on the terminal side and `R99`/`R100` to `3V3` on the ESP side — so moving `H8` to 5 V also makes the terminal-block I2C lines 5 V logic, safely. This is what the Waveshare wiki means by "sets the supply voltage and I/O level for I2C devices".
|
||||||
|
- `I2C_VCC` also appears at header `H8`'s neighbour `H1` (touch-panel FPC) area only as a label; the touch panel itself runs on `3V3`.
|
||||||
|
|
||||||
|
## 5 V rail budget (for whatever hangs on VOUT)
|
||||||
|
|
||||||
|
- `VIN` (7–36 V terminal) → `D17` 1N5822 reverse-protection Schottky + `D3` SMAJ36CA TVS → `U1` **SY8293** synchronous buck → **`DC_5V`**, `L3` 4.7 µH 8 A, note *"Run the line at current 2A"*. `DC_5V` feeds the 5 V rail (and VBUS via `Q4` AO3401 ideal-diode-style switch).
|
||||||
|
- Sheet note: *"The screen itself consumes close to 550 mA"*; the wiki's whole-board figure is ~450 mA @ 5 V. Realistic headroom on VOUT@5 V from the 12 V input: **roughly 1 A**, comfortably enough for Inst. Cluster (~150–200 mA) `(unverified estimate; the regulator is rated for 2 A total)`.
|
||||||
|
- On USB-only power the 5 V rail is the host's 500 mA — do not load VOUT then.
|
||||||
|
- Caveat for the vehicle: the 36 V TVS is the only transient clamp; the ISO 7637 concern in [[open-questions]] #6 stands.
|
||||||
|
|
||||||
|
## Other confirmations (index only)
|
||||||
|
|
||||||
|
- CAN: `CANTX` = IO15, `CANRX` = IO16 (matches `(repo)`); RS485: `RS485_TXD` = IO44, `RS485_RXD` = IO43 (matches [[esp32-s3-touch-lcd-5-intro-photo]]).
|
||||||
|
- SD card on `MOSI` IO11 / `SCK` IO12 / `MISO` IO13, `SDCS` on CH422G `EXIO4` — the pin facts needed for the SD "black box" idea in [[obd-diagnostic-polling]].
|
||||||
|
- Isolated outputs `DO0`/`DO1` via PC817 optocouplers driven from `OD0`/`OD1` (CH422G), inputs `DI0`/`DI1` via PC814.
|
||||||
|
- Input detail (read 2026-09-29 for [[diff-lock-inputs]]): `DINx` → PC814 LED → 3.6 kΩ 1206 → `DI_COM`, 100 nF across. `DI_COM` is also fed from 5 V via D4 1N5822 + R79 220 Ω, for dry contacts. The phototransistor pulls `DI0`/`DI1` (4.7 kΩ to 3V3) low. The net table maps `DI0` = **EXIO0** and `DI1` = **EXIO5**. The rest of the bank: EXIO1 `CTP_RST`, EXIO2 `DISP`, EXIO3 `LCD_RST`, EXIO4 `SDCS`.
|
||||||
|
- Strapping pads `R87–R94` (IO0/IO3/IO45/IO46).
|
||||||
|
|
||||||
|
## Related
|
||||||
|
|
||||||
|
[[esp32-s3-touch-lcd-5b]] · [[esp32-s3-touch-lcd-5b-waveshare-wiki]] · [[esp32-s3-touch-lcd-5-intro-photo]] · [[dual-controller-architecture]]
|
||||||
@@ -23,7 +23,7 @@ Official product documentation for the ESP32-S3-Touch-LCD-5 family. Covers four
|
|||||||
- **120 Ω termination resistor switch, OFF by default** — correct setting for tapping into an existing, already-terminated vehicle bus; leave it off.
|
- **120 Ω termination resistor switch, OFF by default** — correct setting for tapping into an existing, already-terminated vehicle bus; leave it off.
|
||||||
|
|
||||||
**Other onboard peripherals:**
|
**Other onboard peripherals:**
|
||||||
- RS485 via SP3485, automatic TX/RX direction switching (this is the terminal block the firmware uses for UART1 → Controller B `(repo)`).
|
- RS485 via SP3485, automatic TX/RX direction switching (this is the terminal block the firmware uses for UART1 → Inst. Cluster `(repo)`).
|
||||||
- Optocoupler-isolated digital I/O: inputs 5–36 V (dry/wet contact, NPN or PNP), open-drain outputs sinking up to 450 mA/channel.
|
- Optocoupler-isolated digital I/O: inputs 5–36 V (dry/wet contact, NPN or PNP), open-drain outputs sinking up to 450 mA/channel.
|
||||||
- PCF85063 RTC with CR927 coin-cell holder.
|
- PCF85063 RTC with CR927 coin-cell holder.
|
||||||
- TF card slot (SD_CS must be driven via CH422G EXIO4).
|
- TF card slot (SD_CS must be driven via CH422G EXIO4).
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ updated: 2026-09-23
|
|||||||
|
|
||||||
# Launch live-data capture — rail pressure decoded (2026-09-23)
|
# Launch live-data capture — rail pressure decoded (2026-09-23)
|
||||||
|
|
||||||
The capture-with-Launch session that [[obd-diagnostic-polling]] had been pointing at since July, finally run. Engine idling, our read-only logger (`tools/serial_logger.py`) on Controller A's USB recording the full `CANRAW` stream while the Launch polled the DDE; then the user selected **Rail Pressure (actual)** and blipped to 2500 rpm for a second calibration point. Raw: `raw/serial-COM10-20260923-163511.log` (~13 MB, both halves of every exchange).
|
The capture-with-Launch session that [[obd-diagnostic-polling]] had been pointing at since July, finally run. Engine idling, our read-only logger (`tools/serial_logger.py`) on Main CTRL's USB recording the full `CANRAW` stream while the Launch polled the DDE; then the user selected **Rail Pressure (actual)** and blipped to 2500 rpm for a second calibration point. Raw: `raw/serial-COM10-20260923-163511.log` (~13 MB, both halves of every exchange).
|
||||||
|
|
||||||
## Headline: rail pressure actual is decoded and VERIFIED
|
## Headline: rail pressure actual is decoded and VERIFIED
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ This is the key operational finding: **rail pressure is served in the DDE's defa
|
|||||||
- **The method generalises**: any value the Launch will display can be decoded the same way — capture the `2C`/`6C` pair while its screen shows the number, calibrate scale against the display at two points. Boost, MAF, injection quantity, EGTs are each one session away. See [[obd-diagnostic-polling]] "Beyond the probe".
|
- **The method generalises**: any value the Launch will display can be decoded the same way — capture the `2C`/`6C` pair while its screen shows the number, calibrate scale against the display at two points. Boost, MAF, injection quantity, EGTs are each one session away. See [[obd-diagnostic-polling]] "Beyond the probe".
|
||||||
- **Self-poll is feasible without any secret.** To read rail pressure ourselves: send the one-time define `2C 10 15 E0`, then poll `2C 10 00 DF` → parse `6C 10 HHLL`. **No `10` session, no `27` security, no `3E` tester-present required** (proven above). The only barriers are our own choices, not the ECU's — see the two below.
|
- **Self-poll is feasible without any secret.** To read rail pressure ourselves: send the one-time define `2C 10 15 E0`, then poll `2C 10 00 DF` → parse `6C 10 HHLL`. **No `10` session, no `27` security, no `3E` tester-present required** (proven above). The only barriers are our own choices, not the ECU's — see the two below.
|
||||||
- **It is still a transmit-on-the-bus action, and `2C` is not strictly read-only** (it writes a definition into the ECU's dynamic-identifier table — harmless, but a state change). So it stays outside the current probe whitelist by policy.
|
- **It is still a transmit-on-the-bus action, and `2C` is not strictly read-only** (it writes a definition into the ECU's dynamic-identifier table — harmless, but a state change). So it stays outside the current probe whitelist by policy.
|
||||||
- **Intended home (design decision, 2026-09-23):** any active polling belongs behind a **password-protected "Diagnostics" screen** on Controller A — authorized-technician gate — never a background/automatic poller and never while a scan tool is connected. Records [[open-questions]]; not built yet.
|
- **Intended home (design decision, 2026-09-23):** any active polling belongs behind a **password-protected "Diagnostics" screen** on Main CTRL — authorized-technician gate — never a background/automatic poller and never while a scan tool is connected. Records [[open-questions]]; not built yet.
|
||||||
- No EGS traffic (`0x618`) — only the DDE (`0x612`) answered; the Launch was on an engine page.
|
- No EGS traffic (`0x618`) — only the DDE (`0x612`) answered; the Launch was on an engine page.
|
||||||
|
|
||||||
## Related
|
## Related
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
---
|
||||||
|
type: source
|
||||||
|
tags: [display, performance, lvgl, psram, baseline, verified]
|
||||||
|
updated: 2026-09-27
|
||||||
|
---
|
||||||
|
|
||||||
|
# Display performance baseline session (2026-09-27)
|
||||||
|
|
||||||
|
Raw: `raw/perf-20260927-164620.log` — first run of `tools/perf_session.py COM14` on firmware `dev` = v0.1.6 + the new `perf` monitor `(repo)`. Bench, both controllers on laptop USB, no car, Wi-Fi joined to the home AP during the run. 2 min 30 s, `PERF,` line every second, no `#` markers typed — the timeline below is reconstructed from the board's own log lines (screen "built" messages, CONFIG frames, `[ota]`/`[wifi]` output). Columns: fps = frames LVGL rendered per second; avg/max = ms per frame (render + copy into the PSRAM framebuffer); kpx = pixels redrawn per frame; flush = ms per second spent copying into the framebuffer; LVGL idle %, core 0 / core 1 idle %.
|
||||||
|
|
||||||
|
## Timeline and numbers (verified)
|
||||||
|
|
||||||
|
| Time | What was happening | fps | ms/frame avg / max | kpx/frame | flush ms/s | LVGL idle | core 1 idle |
|
||||||
|
|---|---|---|---|---|---|---|---|
|
||||||
|
| 16:46:22 | Driveline, idle, bench data constant | 9.5–9.8 | 30 / 32 | 39 | 51 | 67 % | 66 % |
|
||||||
|
| 16:46:24 | swipe → Settings (full-screen redraw) | 5.6 | 46 / **148** | 131 | 85 | 30 % | 55 % |
|
||||||
|
| 16:46:25 | Settings, static | 0 | – | 0 | 0 | 92 % | 94 % |
|
||||||
|
| 16:46:27–37 | Wi-Fi page: scan, network list drawn | 1.7–5.9 | 40–78 / **142–104** | 150–334 | 63–166 | 36–94 % | 56–87 % |
|
||||||
|
| 16:46:39–42 | joining the AP (spinner) | 24–49 | 5–11 / 134 | <1–26 | 12–82 | 56–70 % | 64–75 % |
|
||||||
|
| 16:46:45–47 | `ota check` (TLS in the loop task) | 3–5 | 8–11 / 34 | 22–32 | 8–24 | 91 % | **25 %** |
|
||||||
|
| 16:46:53–54 | swipe → Gauge Tuning (build + redraw) | 7–8 | 39–71 / **116–312** | 110–121 | 97–100 | 29–48 % | 35–64 % |
|
||||||
|
| 16:47:03–07 | trim −/+ held (hold-repeat, tiny redraws) | 20–29 | 5 / 10–12 | 7–9 | 16–30 | 68–85 % | 76–84 % |
|
||||||
|
| 16:47:10–11 | the deferred NVS save (flash write) | 0–0.9 | – | – | – | 92 % | 93 % |
|
||||||
|
| 16:47:48–57 | Simulation tab: override switches / sliders | 9–23 | 25–29 / 32–36 | 91–99 | **200–261** | **9–19 %** | **25–42 %** |
|
||||||
|
| 16:48:00 | back on Driveline | 9.8 | 30 / 32 | 39 | 51 | 63 % | 64 % |
|
||||||
|
| 16:48:01–04 | Settings again (redraws) | 2.7–6.7 | 47–52 / 142–276 | 106–181 | 57–79 | 45–94 % | 62–80 % |
|
||||||
|
| 16:48:07 → 16:48:49 | `ota install` v0.1.6: **no PERF lines** — the job blocks `loop()` for the whole 41 s download (1.71 MB, ~42 KB/s), then reboot | – | – | – | – | – | – |
|
||||||
|
|
||||||
|
Heap never moved: internal 66.1–67.5 KB free, largest block 31.7 KB throughout; PSRAM 6.60 MB free. No leak across screen changes, scan, OTA check.
|
||||||
|
|
||||||
|
## Findings
|
||||||
|
|
||||||
|
1. **The Driveline screen redraws ~10 times a second with nothing changing** — 39 kpx and 30 ms per frame, 51 ms/s of PSRAM copying, a third of core 1, permanently. Something in its `tick()` invalidates every 100 ms even when every value is constant `(repo, to be found)`. This is the largest steady PSRAM writer in normal driving and therefore the biggest steady contributor to the dots' opportunity window. Cheapest win on the whole page.
|
||||||
|
2. **Screen changes cost 140–330 ms in one frame** (full 614 kpx redraw ≈ 2–4 Mpx/s render+copy). That single frame holds the LVGL lock — this *is* the swipe lag. Cannot be fixed by bounce buffers; only by drawing less (or faster).
|
||||||
|
3. **The Simulation tab is the heaviest normal-use load**: ~95 kpx per frame at ~20 fps → 2 Mpx/s, 26 % of the time copying into PSRAM, LVGL idle down to 9 %, core 1 idle 25 %. Bounce-buffer refill will compete with exactly this; step 2 must be measured on this tab, not on an idle screen.
|
||||||
|
4. **Wi-Fi scan window**: core 1 idle 55–60 %, frames to 148 ms, PSRAM traffic from the list redraw plus the radio's own buffers — the scenario that produces dots. No marker was typed, so whether dots showed this time is not in the log (ask the user).
|
||||||
|
5. **A flash write is invisible to these counters** (16:47:10 save: nothing in the numbers). The flicker happens on the panel's DMA side, not in LVGL. The monitor needs a **panel refresh counter** (vsync events per second; a DMA restart drops a frame) to measure flicker and dots directly — otherwise steps 2 and 3 can only be judged by eye.
|
||||||
|
6. **During OTA the monitor is blind** because it ticks from `loop()`, which the OTA job occupies for ~41 s. Needs a timer-driven report (or a tick from the OTA progress callback) before the OTA-with-screen-on work.
|
||||||
|
7. **`ota check` drops core 1 idle to 25 %**: the TLS handshake runs in the loop task on core 1 next to LVGL. Not a display defect, but it explains a stutter at that moment.
|
||||||
|
|
||||||
|
## Consequences for the plan ([[open-questions]] #13)
|
||||||
|
|
||||||
|
- Add to the monitor before step 2: vsync/panel-refresh counter, timer-driven reporting.
|
||||||
|
- Add a step 1b: find and stop the Driveline 10 Hz redraw; re-baseline (expect Driveline to look like static Settings: 0 fps, ~94 % idle).
|
||||||
|
- Judge bounce buffers on the Simulation tab and during a Wi-Fi scan, by the refresh counter, not by fps.
|
||||||
|
|
||||||
|
## Related
|
||||||
|
|
||||||
|
[[open-questions]] · [[esp32-s3-touch-lcd-5b]] · [[ota-updates]]
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
---
|
||||||
|
type: source
|
||||||
|
tags: [display, performance, psram, dma, flicker, ota, verified]
|
||||||
|
updated: 2026-09-27
|
||||||
|
---
|
||||||
|
|
||||||
|
# Perf session with dots on screen, then an OTA (2026-09-27, 16:59–17:00)
|
||||||
|
|
||||||
|
Raw: `raw/perf-20260927-165903.log` — second `tools/perf_session.py COM14` run, firmware `dev` = v0.1.6 + perf monitor with the **panel vsync counter** (step 1b). Bench, USB, Wi-Fi joined. The user started the session **while the screen was showing horizontally aligned small dots and dashes** on the idle Driveline screen, then ran `ota check`, edited trim on Gauge Tuning (deferred NVS save), toggled the Simulation override, and installed v0.1.6 over the air. No `#` markers were typed; the timeline comes from the board's own lines.
|
||||||
|
|
||||||
|
## The two results
|
||||||
|
|
||||||
|
### 1. Dots are NOT dropped panel frames `(verified)`
|
||||||
|
|
||||||
|
| 16:59:05–07, Driveline idle, dots visible (user) | value |
|
||||||
|
|---|---|
|
||||||
|
| frames LVGL rendered | 0–1 per second |
|
||||||
|
| PSRAM copy time | 0–2 ms/s |
|
||||||
|
| LVGL idle / core 0 idle / core 1 idle | 91–93 % / 96 % / 94 % |
|
||||||
|
| **panel refreshes** | **24–25 per second** |
|
||||||
|
| **longest gap between refreshes** | **41.5–41.6 ms = exactly one frame** |
|
||||||
|
|
||||||
|
The RGB panel completed every frame on time while the dots were on screen, with the CPUs idle and nothing being drawn. So the dots are **not** the DMA restart the driver knows about (`RESTART_IN_VSYNC`) — they are **sub-frame data glitches**: the LCD DMA's FIFO runs dry for a handful of pixels while the PSRAM bus is busy elsewhere, the peripheral keeps clocking, wrong pixels go out, the frame still ends on time. That is why they look like short horizontal dashes and why the vsync counter cannot see them. Who was using the PSRAM/flash bus with LVGL idle: Wi-Fi (associated), ESP-NOW every 200 ms, the UART/console tasks, and every **flash cache miss** — on this module the flash and the OPI PSRAM share the SPI0 bus, so instruction fetches from flash steal cycles from the framebuffer DMA `(unverified: bus-sharing detail)`. > [!warning] Correction (same day, after reading the panel library)
|
||||||
|
> **Bounce buffers are already active.** The board header `BOARD_WAVESHARE_ESP32_S3_TOUCH_LCD_5_B.h` sets `ESP_PANEL_BOARD_LCD_RGB_BOUNCE_BUF_SIZE = width × 10` (two 10-line, 20 KB internal buffers) and `ESP_PANEL_BOARD_LCD_RGB_CLK_HZ = 21 MHz`; the `-DESP_PANEL_LCD_RGB_BOUNCE_BUF_SIZE=0` flag in `platformio.ini` used a name the library never reads (removed). The wiki's earlier "no bounce buffer, 16 MHz" claims were wrong. 21 MHz over 1368 × 637 clocks per frame = 24.1 Hz — matches the measured vsync rate exactly `(verified)`.
|
||||||
|
>
|
||||||
|
> With bounce buffers in use the dots have a sharper explanation: the DMA streams 10-line chunks from internal SRAM while an interrupt refills the other chunk from the PSRAM framebuffer (a 20 KB copy every ~690 µs, ~29 MB/s). When that refill is late — PSRAM/flash bus busy (Wi-Fi/LWIP buffers live in PSRAM: `CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y`; flash cache misses on either core), or the interrupt delayed — the DMA re-sends **the previous chunk's pixels**, i.e. content from ~10 lines above appears displaced: exactly the text-coloured dashes under each text line in the photo. Frame timing is untouched, so vsync stays perfect. The fix is therefore not "add bounce buffers" but **make the refill never miss**: `CONFIG_LCD_RGB_ISR_IRAM_SAFE` (refill ISR keeps running while flash is busy) and `CONFIG_SPIRAM_XIP_FROM_PSRAM` (code and constants execute from PSRAM, so flash writes no longer stop the world and there is no flash↔PSRAM switching) — both sdkconfig options, i.e. step 3 covers the dots as well as the OTA blanking.
|
||||||
|
|
||||||
|
**Photo evidence** `raw/dots-20260927_170136.jpg` (user, 17:01, Settings screen static, Wi-Fi connected): the dashes sit a few rows *below* each text line and carry **that line's colour** — green under the green SSID, white under white labels. They are the text's own pixels arriving late and being clocked out in the wrong place: a FIFO underrun of a few pixels with the frame timing intact. Exactly the sub-frame glitch the counters cannot see.
|
||||||
|
|
||||||
|
Consequence for measurement: **dots can only be judged by eye** (or a camera); the vsync gap is the instrument for *flicker* and *frame loss*, not for dots.
|
||||||
|
|
||||||
|
### 2. During an OTA the panel loses ~75 % of its frames `(verified)`
|
||||||
|
|
||||||
|
| 16:59:41 → 17:00:17, `ota install` v0.1.6 (1.71 MB, ~42 KB/s) | value |
|
||||||
|
|---|---|
|
||||||
|
| panel refreshes | **4–8 per second** (healthy: 24) |
|
||||||
|
| longest gap | **290–747 ms** (healthy: 41.5) — repeatedly 332 ms ≈ 8 frames |
|
||||||
|
| core 0 / core 1 idle | 33–44 % / 23–31 % |
|
||||||
|
| LVGL rendered frames | 0 (the job owns the loop; nothing is drawn) |
|
||||||
|
| internal free | 59.4 KB (TLS buffers); back to 66 KB after |
|
||||||
|
|
||||||
|
Every flash write disables the cache, the PSRAM framebuffer becomes unreadable, the DMA underruns, the driver restarts at the next vsync — and the next sector write hits again. With ~42 KB/s of writes the panel is dead about three quarters of the time. This is the mechanism behind "the screen goes dark during updates", independent of the backlight: **no on-screen progress bar is possible until flash writes stop blanking the panel** → step 3 (`CONFIG_SPIRAM_XIP_FROM_PSRAM`). Target after step 3: 24 refreshes/s and a 41.5 ms gap throughout `ota install`.
|
||||||
|
|
||||||
|
Reboot after install: gap 373 ms at 17:00:17 (slot switch), 125 ms at 17:00:18 (first full redraw, 614 kpx, 148 ms), back to 41.5 ms at 17:00:20.
|
||||||
|
|
||||||
|
## Other observations
|
||||||
|
|
||||||
|
- `ota check` (16:59:08–10): core 1 idle fell to 25 % (TLS in the loop task), internal free dipped to 61 KB, **no frame lost** (gap 41.8 ms).
|
||||||
|
- Trim edits (16:59:16–18) and the deferred NVS save ~3 s later: **no frame lost** (gap 41.5 ms). A single small NVS write is short enough to hide inside a frame; the old per-tap saves were many of them in a row.
|
||||||
|
- Screen changes are single 116–160 ms frames of 614 kpx, as in the first session — the swipe lag, unaffected by 1b (only idle redraws were removed).
|
||||||
|
- Step 1b confirmed in the wild: idle Driveline windows show 0 fps and 0 ms/s of PSRAM copying.
|
||||||
|
|
||||||
|
## Consequences for [[open-questions]] #13
|
||||||
|
|
||||||
|
- **Step 2 as written (add bounce buffers) is moot** — they are already on. What remains of step 2: the refill's slack can be widened by a lower pixel clock (21 → 18 MHz ≈ 20.7 Hz refresh) or bigger bounce buffers (internal RAM cost); both are fallbacks if step 3 leaves residual dots.
|
||||||
|
- **Step 3 (XIP from PSRAM)** is aimed at the OTA collapse and any flash-write flicker. Success criterion: 24 vsync/s, 41.5 ms gap during `ota install`. Only then does step 4 (progress bar on screen) make sense.
|
||||||
|
|
||||||
|
## Related
|
||||||
|
|
||||||
|
[[perf-baseline-2026-09-27]] · [[open-questions]] · [[esp32-s3-touch-lcd-5b]] · [[ota-updates]]
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
---
|
||||||
|
type: source
|
||||||
|
tags: [display, performance, psram, xip, ota, flicker, verified]
|
||||||
|
updated: 2026-09-27
|
||||||
|
---
|
||||||
|
|
||||||
|
# OTA under XIP-from-PSRAM: the panel keeps every frame (2026-09-27, 17:46)
|
||||||
|
|
||||||
|
Raw: `raw/perf-xip-ota-20260927-174617.log` — scripted session on COM14 (attach without reset, `perf on 1`, `wifi status`, `ota install force`, log until the reboot). Firmware: branch `display-xip` `dev` build = v0.1.6 + perf monitor + **core rebuilt with `CONFIG_SPIRAM_XIP_FROM_PSRAM=y` (`FETCH_INSTRUCTIONS`, `RODATA`) and `CONFIG_LCD_RGB_ISR_IRAM_SAFE=y`** via pioarduino `custom_sdkconfig`. Bench, USB, Wi-Fi joined (RSSI −53 dBm, channel 1). Same test as in [[perf-dots-and-ota-2026-09-27]] an hour earlier on the stock core.
|
||||||
|
|
||||||
|
## Result `(verified)`
|
||||||
|
|
||||||
|
| `ota install force`, v0.1.6, 1.71 MB | stock core (16:59) | XIP core (17:46) |
|
||||||
|
|---|---|---|
|
||||||
|
| panel refreshes per second during the download | **4–8** | **24–25** |
|
||||||
|
| longest gap between refreshes | **290–747 ms** | **41.5–41.7 ms** (one frame) |
|
||||||
|
| download time | ~36 s | ~33 s |
|
||||||
|
| core 1 idle during download | 23–31 % | 25–38 % |
|
||||||
|
| core 0 idle during download | 33–44 % | 89–93 % |
|
||||||
|
| internal free during download | 59.4 KB | 55.8 KB |
|
||||||
|
| PSRAM free (idle, before) | 6.60 MB | **4.89 MB** (code + rodata now resident in PSRAM, ~1.7 MB) |
|
||||||
|
|
||||||
|
Not one dropped frame in 33 s of continuous flash writes. The mechanism in the earlier page — cache disabled for every sector write → framebuffer refill starves → restart at vsync — no longer applies: with the code executing from PSRAM the flash operation does not take the PSRAM away, and with the refill interrupt in IRAM it keeps running while flash is busy. **The screen can stay on during an update; a progress bar is now possible** (step 4).
|
||||||
|
|
||||||
|
Also seen:
|
||||||
|
- Boot / first full redraw under XIP: 614 kpx in 142 ms (stock: ~148 ms) — no measurable render slow-down from executing code out of PSRAM in this one sample; screen-change frames should be compared over a real session.
|
||||||
|
- Idle Driveline under XIP: 0 fps, LVGL idle 99–100 %, cores 95–96 % idle, 24 vsync/s, gap 41.5 ms — same as the stock core after step 1b.
|
||||||
|
- Internal free at idle 63.3 KB (stock 66.3 KB); largest block unchanged at 31.7 KB.
|
||||||
|
- Cost: `custom_sdkconfig` rebuilds the Arduino core: first build 20 min (and it failed on RainMaker/Insights embedding `https_server.crt` until those unused components were dropped with `custom_component_remove`), rebuilds ~3 min, normal incremental builds unchanged. Generated `sdkconfig.defaults`, `sdkconfig.<env>`, `managed_components/`, `.dummy/` are git-ignored. CI must be able to do the same rebuild (open).
|
||||||
|
|
||||||
|
## Second run, with the progress bar (17:55, `raw/perf-xip-ota-20260927-175522.log`)
|
||||||
|
|
||||||
|
Same forced install with the new on-screen notice (bar updated per percent from the download loop, screen lit). Panel: **24–25 frames/s, 41.5–41.8 ms gap throughout**; LVGL rendered 2–3 small frames/s (~28 kpx, the bar) at 10–12 ms each; core 1 idle 29–38 %. User watching the screen: "the progress bar appeared and no flickering or other issues" `(verified)`.
|
||||||
|
|
||||||
|
## Still to verify (needs eyes)
|
||||||
|
|
||||||
|
- **Dots**: idle screen with Wi-Fi associated, several minutes, on the XIP build. The vsync counter cannot see them; only the user can. If the refill ISR being IRAM-safe and the flash traffic being gone were the cause, they are gone; if PSRAM bandwidth contention alone can still delay a refill, some may remain → fallbacks on [[open-questions]] #13 (lower pixel clock, larger bounce buffers, Wi-Fi/LWIP buffers to internal RAM).
|
||||||
|
- **Swipe lag**: screen-change frame times on the XIP build vs the 140–330 ms measured on stock.
|
||||||
|
- **Gauge Tuning save flicker**: no frame was lost on stock either; expect none.
|
||||||
|
|
||||||
|
## Related
|
||||||
|
|
||||||
|
[[perf-dots-and-ota-2026-09-27]] · [[perf-baseline-2026-09-27]] · [[open-questions]] · [[ota-updates]] · [[esp32-s3-touch-lcd-5b]]
|
||||||
Reference in New Issue
Block a user