Remove the deep-sleep feature entirely (user decision): power manager, Settings switch, NVS key, sleep bit in the shared header, wiki page and cheat-sheet entries
Firmware / build (push) Successful in 6m59s
Firmware / build (push) Successful in 6m59s
This commit is contained in:
@@ -88,7 +88,6 @@ src/
|
|||||||
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)
|
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
|
status_overlay.cpp # lv_layer_top() on EVERY screen: Wi-Fi chip top-right, blinking red / steady amber alert banner top-centre
|
||||||
power_manager.cpp # 'Sleep when the car is off': deep sleep after 60 s of quiet CAN + idle screen, wake on CAN RX; mirrors the switch to B
|
|
||||||
settings_manager.cpp # NVS persistent storage
|
settings_manager.cpp # NVS persistent storage
|
||||||
ui_state_manager.cpp # Debug flag (performance overlay, sent to B)
|
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
|
||||||
|
|||||||
@@ -132,14 +132,6 @@ diag raw on | off CANRAW frame logging
|
|||||||
diag status
|
diag status
|
||||||
```
|
```
|
||||||
|
|
||||||
### `sleep` — deep sleep when the car is off (Settings → System switch, default OFF)
|
|
||||||
```
|
|
||||||
sleep status enabled?, and what currently keeps the board awake
|
|
||||||
sleep on | off same as the switch; the Inst. Cluster follows through the CONFIG frame
|
|
||||||
sleep now deep sleep immediately - wake = CAN bus activity (GPIO 16) or power cycle
|
|
||||||
```
|
|
||||||
Asleep, the USB port disappears; on the bench only a power cycle or the reset button wakes a Main CTRL that has no CAN bus.
|
|
||||||
|
|
||||||
### Diagnostics
|
### Diagnostics
|
||||||
```
|
```
|
||||||
mem internal heap, PSRAM, LVGL pool
|
mem internal heap, PSRAM, LVGL pool
|
||||||
@@ -161,8 +153,6 @@ ota status version, slot, rollback state
|
|||||||
ota check join Wi-Fi, ask Gitea for the latest release, leave
|
ota check join Wi-Fi, ask Gitea for the latest release, leave
|
||||||
ota install [force] download, verify, flash, reboot (parked only)
|
ota install [force] download, verify, flash, reboot (parked only)
|
||||||
ota rollback
|
ota rollback
|
||||||
sleep status sleep flag received from the Main CTRL, link state
|
|
||||||
sleep now deep sleep now; wakes on the UART wire (IO1) or every 60 s for a 4 s listen
|
|
||||||
```
|
```
|
||||||
B prints a stats line every 5 s (`applied=… uart … espnow …`) — `uart alive` means the wire works.
|
B prints a stats line every 5 s (`applied=… uart … espnow …`) — `uart alive` means the wire works.
|
||||||
|
|
||||||
|
|||||||
@@ -187,10 +187,6 @@ typedef struct __attribute__((packed)) {
|
|||||||
|
|
||||||
#define OUT_ENABLE_TACH (1 << 0)
|
#define OUT_ENABLE_TACH (1 << 0)
|
||||||
#define OUT_ENABLE_TEMP (1 << 1)
|
#define OUT_ENABLE_TEMP (1 << 1)
|
||||||
// Not an output: the Main CTRL's "Sleep when the car is off" switch, carried in
|
|
||||||
// the same byte so the CONFIG layout (and PACKET_VERSION) stay unchanged. The
|
|
||||||
// Inst. Cluster caches CONFIG in NVS, so it knows the setting while A sleeps.
|
|
||||||
#define CFG_SLEEP_WHEN_SILENT (1 << 7)
|
|
||||||
#define OVERRIDE_TACH (1 << 0)
|
#define OVERRIDE_TACH (1 << 0)
|
||||||
#define OVERRIDE_TEMP (1 << 1)
|
#define OVERRIDE_TEMP (1 << 1)
|
||||||
|
|
||||||
|
|||||||
+1
-5
@@ -19,7 +19,6 @@
|
|||||||
#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/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/status_overlay.h" // Every screen: Wi-Fi chip top-right, blinking alert banner top-centre
|
||||||
#include "modules/power_manager.h" // Deep sleep when the car is off (Settings switch, `sleep` console)
|
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// MINIMAL LVGL + UI SETTINGS + WIFI + UART
|
// MINIMAL LVGL + UI SETTINGS + WIFI + UART
|
||||||
@@ -62,8 +61,7 @@ static bool memCommand(const char* line) {
|
|||||||
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) || memCommand(line) ||
|
WiFiManager::handleCommand(line) || memCommand(line) ||
|
||||||
PerfMon::handleCommand(line) || LinkPeer::handleCommand(line) ||
|
PerfMon::handleCommand(line) || LinkPeer::handleCommand(line);
|
||||||
PowerManager::handleCommand(line);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -101,7 +99,6 @@ void setup()
|
|||||||
Tunables::init();
|
Tunables::init();
|
||||||
DiagProbe::init();
|
DiagProbe::init();
|
||||||
Tunables::setExtraCommandHandler(consoleExtraCommand);
|
Tunables::setExtraCommandHandler(consoleExtraCommand);
|
||||||
PowerManager::init(SettingsManager::loadSleepState()); // after Tunables: mirrors the switch into the config
|
|
||||||
PerfMon::init();
|
PerfMon::init();
|
||||||
|
|
||||||
// Load saved switch states from NVS
|
// Load saved switch states from NVS
|
||||||
@@ -173,7 +170,6 @@ void loop()
|
|||||||
TuningScreen::tick();
|
TuningScreen::tick();
|
||||||
SettingsScreen::tick();
|
SettingsScreen::tick();
|
||||||
StatusOverlay::tick();
|
StatusOverlay::tick();
|
||||||
PowerManager::tick(); // deep sleep once the bus and the screen have been quiet for a minute
|
|
||||||
|
|
||||||
delay(100); // Check frequently to catch screen changes quickly
|
delay(100); // Check frequently to catch screen changes quickly
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,149 +0,0 @@
|
|||||||
/*
|
|
||||||
* Power Manager implementation (Main CTRL). See power_manager.h.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "power_manager.h"
|
|
||||||
#include "settings_manager.h"
|
|
||||||
#include "tunables.h"
|
|
||||||
#include "ota_update.h"
|
|
||||||
#include "link_peer.h"
|
|
||||||
#include "display_init.h"
|
|
||||||
#include "serial_lock.h"
|
|
||||||
#include "drivers/can_driver.h"
|
|
||||||
#include "display/lvgl_v8_port.h"
|
|
||||||
#include "protocol/automotive_data.h"
|
|
||||||
#include <lvgl.h>
|
|
||||||
#include <esp_sleep.h>
|
|
||||||
#include <driver/rtc_io.h>
|
|
||||||
#include <driver/gpio.h>
|
|
||||||
|
|
||||||
namespace PowerManager {
|
|
||||||
|
|
||||||
static const uint32_t SLEEP_AFTER_MS = 60000; // quiet bus + idle touch + uptime before sleeping
|
|
||||||
|
|
||||||
static bool g_enabled = false;
|
|
||||||
static uint32_t g_last_log = 0;
|
|
||||||
|
|
||||||
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 void mirrorToCluster() {
|
|
||||||
link_config_t cfg = Tunables::get();
|
|
||||||
uint8_t want = g_enabled ? (cfg.out_enable | CFG_SLEEP_WHEN_SILENT) : (cfg.out_enable & ~CFG_SLEEP_WHEN_SILENT);
|
|
||||||
if (want == cfg.out_enable) return;
|
|
||||||
cfg.out_enable = want;
|
|
||||||
Tunables::set(cfg); // bumps cfg_version -> CONFIG frame -> Inst. Cluster caches it in NVS
|
|
||||||
}
|
|
||||||
|
|
||||||
void init(bool enabled) {
|
|
||||||
g_enabled = enabled;
|
|
||||||
esp_sleep_wakeup_cause_t why = esp_sleep_get_wakeup_cause();
|
|
||||||
if (why == ESP_SLEEP_WAKEUP_EXT0) print("[sleep] woke up: CAN bus activity");
|
|
||||||
print("[sleep] sleep when the car is off: %s", g_enabled ? "ON (60 s of quiet bus + idle screen)" : "off");
|
|
||||||
mirrorToCluster();
|
|
||||||
}
|
|
||||||
|
|
||||||
void setEnabled(bool on) {
|
|
||||||
if (on == g_enabled) return;
|
|
||||||
g_enabled = on;
|
|
||||||
SettingsManager::saveSleepState(on);
|
|
||||||
mirrorToCluster();
|
|
||||||
print("[sleep] %s", on ? "enabled - both controllers sleep 60 s after the bus goes quiet" : "disabled");
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isEnabled() { return g_enabled; }
|
|
||||||
|
|
||||||
/** Why we are NOT sleeping right now, or NULL if every condition holds. */
|
|
||||||
static const char* blocker() {
|
|
||||||
if (!g_enabled) return "disabled";
|
|
||||||
if (millis() < SLEEP_AFTER_MS) return "just booted";
|
|
||||||
if (!CANDriver::isActive()) return "CAN switched off (no wake source)";
|
|
||||||
can_stats_t s = CANDriver::getStats();
|
|
||||||
if (s.messages_received > 0 && millis() - s.last_receive_time < SLEEP_AFTER_MS) return "bus alive";
|
|
||||||
Ota::ui_status_t o = Ota::getStatus();
|
|
||||||
if (o.phase == Ota::PHASE_CHECKING || o.phase == Ota::PHASE_INSTALLING) return "update running";
|
|
||||||
LinkPeer::peer_status_t p = LinkPeer::getStatus();
|
|
||||||
if (p.heard && (p.st.ota_phase == LINK_OTA_CHECKING || p.st.ota_phase == LINK_OTA_INSTALLING)) return "Inst. Cluster updating";
|
|
||||||
uint32_t idle = 0;
|
|
||||||
if (lvgl_port_lock(50)) { idle = lv_disp_get_inactive_time(NULL); lvgl_port_unlock(); }
|
|
||||||
else return "screen busy";
|
|
||||||
if (idle < SLEEP_AFTER_MS) return "screen in use";
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The RGB panel's 20 signal lines (Waveshare 5B board header). In deep sleep the
|
|
||||||
// LCD peripheral stops and these pins would float: a panel with no clock and
|
|
||||||
// floating data shows white/flickering edges if any light reaches it. Drive
|
|
||||||
// them low and HOLD them through the sleep, so the panel sees a black frame.
|
|
||||||
static const int RGB_PINS[] = {46, 3, 5, 7, 14, 38, 18, 17, 10, 39, 0, 45, 48, 47, 21, 1, 2, 42, 41, 40};
|
|
||||||
|
|
||||||
static void parkPanel() {
|
|
||||||
lvgl_port_lock(-1); // stop the render task from touching the panel while we take the pins
|
|
||||||
for (int pin : RGB_PINS) {
|
|
||||||
gpio_reset_pin((gpio_num_t)pin);
|
|
||||||
gpio_set_direction((gpio_num_t)pin, GPIO_MODE_OUTPUT);
|
|
||||||
gpio_set_level((gpio_num_t)pin, 0);
|
|
||||||
gpio_hold_en((gpio_num_t)pin);
|
|
||||||
}
|
|
||||||
gpio_deep_sleep_hold_en();
|
|
||||||
// the lock is deliberately not released: nothing must draw again before sleep
|
|
||||||
}
|
|
||||||
|
|
||||||
static void goToSleep(const char* reason) {
|
|
||||||
print("[sleep] %s - deep sleep now; the CAN bus wakes me", reason);
|
|
||||||
Tunables::flush();
|
|
||||||
DisplayInit::setBacklight(false); // CH422G EXIO2 low; the expander keeps it while we sleep
|
|
||||||
delay(50);
|
|
||||||
CANDriver::stop(); // frees GPIO 16 from the TWAI peripheral
|
|
||||||
delay(400); // let the CAN task deinit TWAI
|
|
||||||
parkPanel();
|
|
||||||
// CAN RX idles high (recessive); the first bit of any frame pulls it low.
|
|
||||||
rtc_gpio_pulldown_dis((gpio_num_t)CAN_RX_PIN);
|
|
||||||
rtc_gpio_pullup_en((gpio_num_t)CAN_RX_PIN);
|
|
||||||
esp_sleep_enable_ext0_wakeup((gpio_num_t)CAN_RX_PIN, 0);
|
|
||||||
SerialLock::lock();
|
|
||||||
Serial.flush();
|
|
||||||
SerialLock::unlock();
|
|
||||||
esp_deep_sleep_start();
|
|
||||||
}
|
|
||||||
|
|
||||||
void tick() {
|
|
||||||
static uint32_t last = 0;
|
|
||||||
if (millis() - last < 1000) return;
|
|
||||||
last = millis();
|
|
||||||
const char* b = blocker();
|
|
||||||
if (b == NULL) goToSleep("bus quiet and screen idle for 60 s");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void help() {
|
|
||||||
print("sleep status why the board is awake / when it would sleep");
|
|
||||||
print("sleep on | off same as the Settings switch (both controllers)");
|
|
||||||
print("sleep now deep sleep immediately (wake = CAN activity or power cycle)");
|
|
||||||
}
|
|
||||||
|
|
||||||
bool handleCommand(const char* line) {
|
|
||||||
if (strncmp(line, "sleep", 5) != 0 || (line[5] != 0 && line[5] != ' ')) return false;
|
|
||||||
const char* a = line + 5;
|
|
||||||
while (*a == ' ') a++;
|
|
||||||
if (!*a || !strcmp(a, "help")) { help(); return true; }
|
|
||||||
if (!strcmp(a, "status")) {
|
|
||||||
const char* b = blocker();
|
|
||||||
print("[sleep] %s | %s", g_enabled ? "enabled" : "disabled", b ? b : "about to sleep");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!strcmp(a, "on")) { setEnabled(true); return true; }
|
|
||||||
if (!strcmp(a, "off")) { setEnabled(false); return true; }
|
|
||||||
if (!strcmp(a, "now")) { goToSleep("console"); return true; }
|
|
||||||
help();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace PowerManager
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
/*
|
|
||||||
* Power Manager (Main CTRL) - deep sleep when the car is off.
|
|
||||||
*
|
|
||||||
* Toggle: Settings -> System -> "Sleep when the car is off" (NVS `sleep_en`,
|
|
||||||
* default OFF). The same switch is mirrored to the Inst. Cluster through the
|
|
||||||
* CONFIG frame (CFG_SLEEP_WHEN_SILENT bit), so one switch rules both boards.
|
|
||||||
*
|
|
||||||
* When enabled, this board goes to DEEP SLEEP once ALL of these hold:
|
|
||||||
* - CAN is switched on but the bus has been quiet for SLEEP_AFTER_MS
|
|
||||||
* (ignition off; a live car never stops talking)
|
|
||||||
* - nobody touched the screen for SLEEP_AFTER_MS
|
|
||||||
* - no update job is running here or on the Inst. Cluster
|
|
||||||
* - the board has been up for at least SLEEP_AFTER_MS
|
|
||||||
*
|
|
||||||
* Wake: the CAN RX pin (GPIO 16, an RTC IO on the S3) goes low with the first
|
|
||||||
* frame after the ignition comes back -> full reboot (~3 s to the Driveline).
|
|
||||||
* Nothing else wakes it: with the CAN wire unplugged, cycle the power.
|
|
||||||
*
|
|
||||||
* Console: sleep status | on | off | now
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <Arduino.h>
|
|
||||||
|
|
||||||
namespace PowerManager {
|
|
||||||
|
|
||||||
void init(bool enabled);
|
|
||||||
void setEnabled(bool on); // persists + mirrors to the Inst. Cluster config
|
|
||||||
bool isEnabled();
|
|
||||||
void tick(); // from loop()
|
|
||||||
bool handleCommand(const char* line);
|
|
||||||
|
|
||||||
} // namespace PowerManager
|
|
||||||
@@ -18,7 +18,6 @@ static const char* NVS_NAMESPACE = "settings";
|
|||||||
static const char* NVS_KEY_WIFI_ENABLED = "wifi_en";
|
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_SLEEP_ENABLED = "sleep_en";
|
|
||||||
static const char* NVS_KEY_CAN_ENABLED = "can_en";
|
static const char* NVS_KEY_CAN_ENABLED = "can_en";
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -67,20 +66,6 @@ void saveDebugState(bool enabled) {
|
|||||||
Serial.printf("[SettingsManager] Saved Debug state = %s\n", enabled ? "ON" : "OFF");
|
Serial.printf("[SettingsManager] Saved Debug state = %s\n", enabled ? "ON" : "OFF");
|
||||||
}
|
}
|
||||||
|
|
||||||
void saveSleepState(bool enabled) {
|
|
||||||
preferences.begin(NVS_NAMESPACE, false);
|
|
||||||
preferences.putBool(NVS_KEY_SLEEP_ENABLED, enabled);
|
|
||||||
preferences.end();
|
|
||||||
Serial.printf("[SettingsManager] Saved Sleep state = %s\n", enabled ? "ON" : "OFF");
|
|
||||||
}
|
|
||||||
|
|
||||||
bool loadSleepState() {
|
|
||||||
preferences.begin(NVS_NAMESPACE, true);
|
|
||||||
bool enabled = preferences.getBool(NVS_KEY_SLEEP_ENABLED, false);
|
|
||||||
preferences.end();
|
|
||||||
return enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool loadDebugState() {
|
bool loadDebugState() {
|
||||||
preferences.begin(NVS_NAMESPACE, true); // read-only mode
|
preferences.begin(NVS_NAMESPACE, true); // read-only mode
|
||||||
bool enabled = preferences.getBool(NVS_KEY_DEBUG_ENABLED, false); // default: OFF
|
bool enabled = preferences.getBool(NVS_KEY_DEBUG_ENABLED, false); // default: OFF
|
||||||
|
|||||||
@@ -60,10 +60,6 @@ bool loadDebugState();
|
|||||||
*/
|
*/
|
||||||
void saveCANState(bool enabled);
|
void saveCANState(bool enabled);
|
||||||
|
|
||||||
/** "Sleep when the car is off" (deep sleep after 60 s of quiet CAN bus). Default OFF. */
|
|
||||||
void saveSleepState(bool enabled);
|
|
||||||
bool loadSleepState();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Load CAN Bus enabled state from NVS
|
* @brief Load CAN Bus enabled state from NVS
|
||||||
* @return bool true if CAN Bus was enabled, false otherwise (default: false)
|
* @return bool true if CAN Bus was enabled, false otherwise (default: false)
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
#include "wifi_manager.h"
|
#include "wifi_manager.h"
|
||||||
#include "ota_update.h"
|
#include "ota_update.h"
|
||||||
#include "link_peer.h"
|
#include "link_peer.h"
|
||||||
#include "power_manager.h"
|
|
||||||
#include "uart_manager.h"
|
#include "uart_manager.h"
|
||||||
#include "espnow_link.h"
|
#include "espnow_link.h"
|
||||||
#include "settings_manager.h"
|
#include "settings_manager.h"
|
||||||
@@ -83,7 +82,6 @@ static Ota::phase_t g_upd_refusal_phase = Ota::PHASE_IDLE;
|
|||||||
static lv_obj_t* g_sys_can = NULL;
|
static lv_obj_t* g_sys_can = NULL;
|
||||||
static lv_obj_t* g_sys_link = NULL;
|
static lv_obj_t* g_sys_link = NULL;
|
||||||
static lv_obj_t* g_sys_dbg = NULL;
|
static lv_obj_t* g_sys_dbg = NULL;
|
||||||
static lv_obj_t* g_sys_sleep = NULL;
|
|
||||||
static lv_obj_t* g_sys_info = NULL; // values column; keys are static
|
static lv_obj_t* g_sys_info = NULL; // values column; keys are static
|
||||||
|
|
||||||
static void refresh(bool force);
|
static void refresh(bool force);
|
||||||
@@ -770,13 +768,7 @@ static void onDebugSwitch(lv_event_t* e) {
|
|||||||
UIStateManager::setDebugEnabled(on);
|
UIStateManager::setDebugEnabled(on);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void onSleepSwitch(lv_event_t* e) {
|
|
||||||
if (g_refreshing) return;
|
|
||||||
PowerManager::setEnabled(lv_obj_has_state(lv_event_get_target(e), LV_STATE_CHECKED));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void refreshSystem(bool force) {
|
static void refreshSystem(bool force) {
|
||||||
setChecked(g_sys_sleep, PowerManager::isEnabled());
|
|
||||||
setChecked(g_sys_can, CANDriver::isActive());
|
setChecked(g_sys_can, CANDriver::isActive());
|
||||||
setChecked(g_sys_link, UARTManager::getState() != UARTManager::UART_STATE_OFF);
|
setChecked(g_sys_link, UARTManager::getState() != UARTManager::UART_STATE_OFF);
|
||||||
setChecked(g_sys_dbg, UIStateManager::isDebugEnabled());
|
setChecked(g_sys_dbg, UIStateManager::isDebugEnabled());
|
||||||
@@ -818,8 +810,6 @@ static void buildSystemPage(lv_obj_t* page) {
|
|||||||
g_sys_link = toggle(right, onLinkSwitch, NULL);
|
g_sys_link = toggle(right, onLinkSwitch, NULL);
|
||||||
makeSettingRow(c, "Performance overlay", "Frame rate and CPU load in the corner", &right);
|
makeSettingRow(c, "Performance overlay", "Frame rate and CPU load in the corner", &right);
|
||||||
g_sys_dbg = toggle(right, onDebugSwitch, NULL);
|
g_sys_dbg = toggle(right, onDebugSwitch, NULL);
|
||||||
makeSettingRow(c, "Sleep when the car is off", "Both controllers sleep 60 s after the CAN bus goes quiet", &right);
|
|
||||||
g_sys_sleep = toggle(right, onSleepSwitch, NULL);
|
|
||||||
|
|
||||||
// two labels side by side, same line spacing, so keys and values line up
|
// two labels side by side, same line spacing, so keys and values line up
|
||||||
lv_obj_t* info = card(page);
|
lv_obj_t* info = card(page);
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ Catalog of every page in the wiki. Read this first when answering questions. Kee
|
|||||||
- [[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]] — Main CTRL → UART1 + ESP-NOW, protocol v2 → Inst. Cluster (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
|
||||||
- [[sleep-when-parked]] — **2026-09-28**: one Settings switch puts both controllers into deep sleep 60 s after the CAN bus goes quiet; Main CTRL wakes on CAN RX (GPIO 16), Inst. Cluster on the UART wire or a 60 s probe boot; bit 7 of `out_enable` carries the switch to B
|
|
||||||
- [[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`
|
- [[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
|
||||||
|
|||||||
@@ -214,3 +214,7 @@ User: "if there is no info from CAN bus, no values should be shown". Until now `
|
|||||||
## [2026-09-28] update | Boards renamed Main CTRL / Inst. Cluster; "Sleep when the car is off" switch
|
## [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.
|
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).
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
---
|
|
||||||
type: concept
|
|
||||||
tags: [power, sleep, settings, verified]
|
|
||||||
updated: 2026-09-28
|
|
||||||
---
|
|
||||||
|
|
||||||
# Sleep when the car is off
|
|
||||||
|
|
||||||
User request 2026-09-28: both boards sit on permanent 12 V, so they must stop burning power when the CAN bus goes quiet. One switch, **Settings → System → "Sleep when the car is off"** (NVS `sleep_en`, default OFF), rules both controllers: the Main CTRL mirrors it into the CONFIG frame as `CFG_SLEEP_WHEN_SILENT` (bit 7 of `out_enable`, byte layout unchanged, `PACKET_VERSION` stays 2), and the Inst. Cluster caches CONFIG in NVS, so it knows the setting even after the Main CTRL has gone to sleep.
|
|
||||||
|
|
||||||
## Main CTRL (`src/modules/power_manager.cpp`)
|
|
||||||
|
|
||||||
Deep sleep when **all** of: switch on; CAN switched on but the bus quiet for 60 s (an ignition-on car never stops talking, so "quiet" = key off); nobody touched the screen for 60 s (`lv_disp_get_inactive_time`); no update running here or reported by the Inst. Cluster; up for at least 60 s. Sequence: `Tunables::flush()`, backlight off, `CANDriver::stop()` (frees GPIO 16 from TWAI), pull-up on GPIO 16, `esp_sleep_enable_ext0_wakeup(GPIO 16, low)`, `esp_deep_sleep_start()`. Wake = the first CAN frame pulls RX low → full reboot (~3 s to the Driveline); the boot log says `woke up: CAN bus activity`. Nothing else wakes it: with no bus (bench) only the reset button / a power cycle does, and the USB port is gone while asleep. Console: `sleep status | on | off | now`.
|
|
||||||
|
|
||||||
## Inst. Cluster (`src/modules/power_manager.cpp`)
|
|
||||||
|
|
||||||
Deep sleep when the bit is set, no DATA frame on any transport for 60 s, no update job, up ≥ 60 s. Gauges driven low and backlight off first. Two wake sources: **UART RX IO1 low** (the Main CTRL's first frame on the wire) and a **60 s timer**. A timer wake is a *probe boot*: setup skips its serial waits, the panel stays dark, and after 4 s without a frame the board sleeps again; if the Main CTRL is heard (ESP-NOW or wire) brightness is restored and the boot continues normally. This is what wakes a radio-only installation (no wire in the car).
|
|
||||||
|
|
||||||
## Verified 2026-09-28 (bench)
|
|
||||||
|
|
||||||
See the log entry of the day: switch → CONFIG → Inst. Cluster within a CONFIG period; `sleep now` on the Inst. Cluster and its wake.
|
|
||||||
|
|
||||||
## Bench finding 2026-09-28: flickering white edges while asleep
|
|
||||||
|
|
||||||
First deep sleep on the bench: the panel showed a flickering white glow around the edges. In deep sleep the LCD peripheral stops and the 20 RGB lines float; a panel with no pixel clock and floating data lights up if any backlight current flows. Fix in `goToSleep()`: after the backlight is switched off through the CH422G (EXIO2), every RGB line (HSYNC 46, VSYNC 3, DE 5, PCLK 7, D0-15 = 14 38 18 17 10 39 0 45 48 47 21 1 2 42 41 40) is driven low and held (`gpio_hold_en` + `gpio_deep_sleep_hold_en`) with the LVGL lock taken so nothing draws again. Whether the glow is gone is the user's observation to make - if it persists, the backlight enable is not really off in sleep and the expander pin needs a look (or the LED driver has its own enable).
|
|
||||||
|
|
||||||
## Not verified
|
|
||||||
|
|
||||||
- The Main CTRL's own sleep and CAN wake need the car (a quiet bus that later talks). Bench boards have no bus, so they would never wake.
|
|
||||||
- Deep-sleep current of either board (Waveshare boards keep their LDO/USB bridge powered).
|
|
||||||
- Whether the TJA1051's RXD idles high with the transceiver powered but the bus off (expected).
|
|
||||||
|
|
||||||
## Related
|
|
||||||
|
|
||||||
[[ota-updates]] · [[esp32-s3-touch-lcd-5b]] · (sibling wiki: controller-link, patrol-gauge-outputs)
|
|
||||||
Reference in New Issue
Block a user