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 <noreply@anthropic.com>
This commit is contained in:
MarekZegare4
2026-06-14 12:29:33 +02:00
parent 2c847c996f
commit 6c5a40a8ce

View File

@@ -1519,6 +1519,13 @@ void UITask::shutdown(bool restart){
} else { } else {
_display->turnOff(); _display->turnOff();
radio_driver.powerOff(); 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(); _board->powerOff();
} }
} }