Merge PowerSaving-v17 into keymindCascade

This commit is contained in:
mikecarper committed 2026-09-24 00:56:05 -07:00
commit 107cbc506e
39 files changed
+124 -83

No files matched your search

+1
View File
@@ -149,6 +149,7 @@ public:
// internally bounded operations can use this while retaining their own
// timeout. Boards without an explicit watchdog need no implementation.
virtual void serviceWatchdog() { /* no op */ }
virtual void enterDeepSleep(uint32_t secs) { (void)secs; }
// Called by example setup() functions to signal that boot is complete.
// Boards may override to stop a boot-indicator LED sequence or similar.
// Default no-op: boards that don't care need not implement anything.
+9 -5
View File
@@ -1119,11 +1119,7 @@ bool ESP32Board::otaFromManifest(const char* current_ver, bool dry_run, char rep
}
#endif // WITH_MQTT_BRIDGE
void ESP32Board::powerOff() {
enterDeepSleep(0); // Do not wakeup
}
void ESP32Board::enterDeepSleep(uint32_t secs) {
void ESP32Board::shutdownPeripherals() {
// Power off the display if any
#ifdef DISPLAY_CLASS
display.turnOff();
@@ -1155,6 +1151,14 @@ void ESP32Board::enterDeepSleep(uint32_t secs) {
Serial.flush();
#endif
delay(100);
}
void ESP32Board::powerOff() {
enterDeepSleep(0); // Do not wakeup
}
void ESP32Board::enterDeepSleep(uint32_t secs) {
shutdownPeripherals();
// Clear stale wakeup sources to avoid ghost wakeup
// This is required when Power Management and automatic lightsleep are enabled
+2 -1
View File
@@ -88,8 +88,9 @@ public:
return raw / 4;
}
virtual void shutdownPeripherals();
virtual void powerOff() override;
void enterDeepSleep(uint32_t secs);
virtual void enterDeepSleep(uint32_t secs) override;
uint32_t getIRQGpio() override {
#ifdef P_LORA_DIO_1
+23
View File
@@ -596,6 +596,29 @@ void NRF52Board::powerOff() {
}
}
void NRF52Board::enterDeepSleep(uint32_t secs) {
if (secs == 0) {
powerOff(); // Not wake up
} else {
shutdownPeripherals();
// Clear FPU interrupt flags to avoid insomnia
// see errata 87 for details
// https://docs.nordicsemi.com/bundle/errata_nRF52840_Rev3/page/ERR/nRF52840/Rev3/latest/anomaly_840_87.html
#if (__FPU_USED == 1)
__set_FPSCR(__get_FPSCR() & ~(0x0000009F));
(void)__get_FPSCR();
NVIC_ClearPendingIRQ(FPU_IRQn);
#endif
// Attemp to sleep
vTaskDelay(pdMS_TO_TICKS(secs * 1000));
// Reboot for a fresh recovery
reboot();
}
}
bool NRF52Board::getBootloaderVersion(char* out, size_t max_len) {
if (!out || max_len == 0u) return false;
out[0] = 0;
+1
View File
@@ -68,6 +68,7 @@ public:
bool rebootToUf2Bootloader() override;
virtual void shutdownPeripherals();
virtual void powerOff() override;
virtual void enterDeepSleep(uint32_t secs) override;
virtual bool getBootloaderVersion(char* version, size_t max_len) override;
virtual bool startOTAUpdate(const char *id, char reply[], bool force_ap = false) override;
virtual bool stopOTAUpdate(char reply[]) override;