fix(power): soft-sleep the GPS receiver during CPU light-sleep#10439
Open
DatanoiseTV wants to merge 1 commit into
Open
fix(power): soft-sleep the GPS receiver during CPU light-sleep#10439DatanoiseTV wants to merge 1 commit into
DatanoiseTV wants to merge 1 commit into
Conversation
GPS only subscribed to notifyDeepSleep, so during light-sleep the receiver kept drawing ~25 mA on a non-router device — the dominant drain on devices that spend most of their time in LIGHT_SLEEP. Subscribe to notifyLightSleep/notifyLightSleepEnd as well, but use GPS_SOFTSLEEP instead of disable()+enable() since the state machine survives across the short light-sleep window and full power-cycle re-acquisition would cost more than it saves.
8 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces GPS power draw during ESP32 CPU light-sleep by subscribing the GPS module to light-sleep enter/exit notifications and transitioning the receiver into a low-power “soft sleep” state across the light-sleep window (instead of fully disabling/enabling the GPS).
Changes:
- Register/unregister GPS observers for
notifyLightSleepandnotifyLightSleepEndon ESP32. - Add ESP32-only GPS callbacks to soft-sleep the receiver on light-sleep entry and restore it on wake.
- Track the pre-light-sleep GPS power state to decide whether to resume
GPS_ACTIVEafter wake.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/gps/GPS.h |
Adds ESP32-only observer members/state for light-sleep enter/exit handling. |
src/gps/GPS.cpp |
Hooks observers in setup()/destructor and implements prepareLightSleep() / endLightSleep() soft-sleep behavior. |
| { | ||
| preLightSleepState = powerState; | ||
| if (powerState == GPS_ACTIVE) { | ||
| setPowerState(GPS_SOFTSLEEP); |
Comment on lines
+201
to
+205
| #ifdef ARCH_ESP32 | ||
| GPSPowerState preLightSleepState = GPS_OFF; | ||
| CallbackObserver<GPS, void *> notifyLightSleepObserver = CallbackObserver<GPS, void *>(this, &GPS::prepareLightSleep); | ||
| CallbackObserver<GPS, esp_sleep_wakeup_cause_t> notifyLightSleepEndObserver = | ||
| CallbackObserver<GPS, esp_sleep_wakeup_cause_t>(this, &GPS::endLightSleep); |
Collaborator
|
This needs to be reviewed against the main GPS power system. Tying it to CPU sleeping doesn't necessarily make sense. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GPS only subscribed to notifyDeepSleep, so during light-sleep the
receiver kept drawing ~25 mA on a non-router device — the dominant
drain on devices that spend most of their time in LIGHT_SLEEP.
Subscribe to notifyLightSleep/notifyLightSleepEnd as well, but use
GPS_SOFTSLEEP instead of disable()+enable() since the state machine
survives across the short light-sleep window and full power-cycle
re-acquisition would cost more than it saves.
Split out from #10425 — single-concern PR.
Build verification
pio run -e t-deck-tftsucceeds, no new warnings.Attestations
t-deck-tftonly.