Skip to content

Commit

Permalink
Immediately go to sleep if battery is critical (#274)
Browse files Browse the repository at this point in the history
* Immediately go to sleep if battery is critical

* Turn off peripheral power in Battery critical shutdown just to be sure
  • Loading branch information
SZenglein authored Dec 13, 2023
1 parent efc66af commit 461b62b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Battery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,14 @@ void Battery_Init(void) {
Battery_LogStatus();

Log_Println(batteryCriticalMsg, LOGLEVEL_NOTICE);
// turn off peripheral power just to be sure, even if it should not yet have been turned on
Power_PeripheralOff();
// Power down and enter deepsleep
System_RequestSleep();
// Don't call System_RequestSleep() here: If the battery is critial, we want to avoid as much init work as possible
// and also any blinking lights or sounds. The goal is to just stay off.
// Additionally, LPCD will not be enabled. This is intentional to avoid battery drain.
delay(200);
esp_deep_sleep_start();
}
#endif
}
Expand Down

0 comments on commit 461b62b

Please sign in to comment.