Files
ESP32-S3-Touch-LCD-5B/src/modules/power_manager.h
T

35 lines
1.2 KiB
C++

/*
* 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