Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Immediately go to sleep if battery is critical #274

Merged
merged 2 commits into from
Dec 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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