Rename Controller A/B -> Main CTRL / Inst. Cluster (user); Sleep when the car is off: Settings switch, deep sleep on quiet CAN + idle screen, CAN RX wake, switch mirrored to the cluster; docs
Firmware / build (push) Successful in 7m22s
Firmware / build (push) Successful in 7m22s
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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
|
||||
Reference in New Issue
Block a user