From 6c5a40a8cecdca73c3eb5723ea53440fb7de304f Mon Sep 17 00:00:00 2001 From: MarekZegare4 Date: Sun, 14 Jun 2026 12:29:33 +0200 Subject: [PATCH] fix(power): power off GPS before SYSTEMOFF to prevent battery drain on shutdown NRF52 GPIO pins retain their last state in SYSTEMOFF. If GPS was active, PIN_GPS_EN stays HIGH and the module keeps drawing ~20mA. gps_enabled is already persisted to flash so applyGpsPrefs() restores the correct state on next boot. Co-Authored-By: Claude Sonnet 4.6 --- examples/companion_radio/ui-new/UITask.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/examples/companion_radio/ui-new/UITask.cpp b/examples/companion_radio/ui-new/UITask.cpp index 3f5de46c..449a152a 100644 --- a/examples/companion_radio/ui-new/UITask.cpp +++ b/examples/companion_radio/ui-new/UITask.cpp @@ -1519,6 +1519,13 @@ void UITask::shutdown(bool restart){ } else { _display->turnOff(); radio_driver.powerOff(); +#ifdef PIN_GPS_EN + // Power off GPS before SYSTEMOFF — GPIO pins retain state in NRF52 SYSTEMOFF, + // so without this the GPS stays powered and drains the battery. + // gps_enabled is already persisted to flash; applyGpsPrefs() restores it on next boot. + pinMode(PIN_GPS_EN, OUTPUT); + digitalWrite(PIN_GPS_EN, LOW); +#endif _board->powerOff(); } }