Rename -> Inst. Cluster (user); power manager: deep sleep on link silence, wake on IO1 or 60 s probe boot; Ota::isBusy; sleep bit in shared header
Firmware / build (push) Successful in 2m59s

This commit is contained in:
2026-09-28 16:38:23 +02:00
parent 43697f3cc8
commit 6854aa1c46
33 changed files with 266 additions and 97 deletions
+14 -7
View File
@@ -1,13 +1,14 @@
/**
* ESP32-S3-LCD-1.3 - Controller B
* ESP32-S3-LCD-1.3 - Inst. Cluster
*
* Receives the v2 link from Controller A on UART1 and ESP-NOW, shows the data
* Receives the v2 link from Main CTRL on UART1 and ESP-NOW, shows the data
* on the 1.3" round display, and drives the Nissan Patrol cluster's tachometer
* and coolant gauge from it (GaugeOutputs, IO7 / IO8).
*/
#include <Arduino.h>
#include <lvgl.h>
#include <esp_sleep.h>
#include "modules/display_init.h"
#include "modules/uart_receiver.h"
#include "modules/espnow_receiver.h"
@@ -17,6 +18,7 @@
#include "modules/link_peer.h"
#include "modules/console.h"
#include "modules/ota_update.h"
#include "modules/power_manager.h"
#include "config/ota_config.h"
// FreeRTOS task handles
@@ -42,15 +44,17 @@ void setup() {
Serial.println("\n[BOOT] ESP32-S3-LCD-1.3 starting...");
// A timer-wake probe boot (see PowerManager) must be quick: no serial waits.
bool probe = esp_sleep_get_wakeup_cause() == ESP_SLEEP_WAKEUP_TIMER;
unsigned long start_wait = millis();
while (!Serial && (millis() - start_wait < 3000)) {
while (!probe && !Serial && (millis() - start_wait < 3000)) {
delay(100);
}
delay(500);
if (!probe) delay(500);
Serial.println("[BOOT] Serial communication ready!");
Serial.println("\n\n=================================");
Serial.println("ESP32-S3-LCD-1.3 - Controller B");
Serial.println("ESP32-S3-LCD-1.3 - Inst. Cluster");
Serial.printf("Firmware %s | Link protocol v%u | UART + ESP-NOW | gauge outputs\n", FW_VERSION, PACKET_VERSION);
Serial.println("=================================\n");
@@ -67,6 +71,7 @@ void setup() {
}
GaugeScreen::init(); // hand-coded screen, built once, loaded
PowerManager::init(); // probe boot? keep the panel dark until the Main CTRL is heard
xTaskCreatePinnedToCore(lvglTask, "LVGL_Task", 8192, NULL, 2, &lvglTaskHandle, 1);
@@ -83,6 +88,7 @@ void setup() {
Ota::init(); // version + slot; hooks A's OTA commands
Console::addHandler(LinkPeer::handleCommand);
Console::addHandler(Ota::handleCommand);
Console::addHandler(PowerManager::handleCommand);
Serial.println("\n[UART] Initializing link receiver...");
if (!UARTReceiver::init()) {
@@ -113,6 +119,7 @@ void loop() {
// STATUS to A, PAIR/SECURE frames from A, serial console
LinkPeer::tick();
Ota::tick(); // runs a queued check/install (blocks the loop while it does)
PowerManager::tick(); // deep sleep when the Main CTRL has been silent for a minute
Console::tick();
// Apply a new CONFIG from A. Overrides are a bench tool: applied but not
@@ -151,9 +158,9 @@ void loop() {
last_connection_check = millis();
bool is_connected = UARTReceiver::isConnected(LINK_TIMEOUT_MS);
if (is_connected && !was_connected) {
Serial.println("[Link] Connection ESTABLISHED with Controller A");
Serial.println("[Link] Connection ESTABLISHED with Main CTRL");
} else if (!is_connected && was_connected) {
Serial.println("[Link] Connection LOST - no data from Controller A");
Serial.println("[Link] Connection LOST - no data from Main CTRL");
}
was_connected = is_connected;
}