Merge pull request #2019 from code8buster/gps-toggle-final

Adds a flag to turn the GPS power rail off entirely on tbeam
This commit is contained in:
Thomas Göttgens
2022-12-17 23:32:20 +01:00
parent 941786669b
commit 220859d0aa
8 changed files with 111 additions and 12 deletions

View File

@@ -29,7 +29,9 @@ Observable<void *> preflightSleep;
/// Called to tell observers we are now entering sleep and you should prepare. Must return 0
/// notifySleep will be called for light or deep sleep, notifyDeepSleep is only called for deep sleep
/// notifyGPSSleep will be called when config.position.gps_enabled is set to 0 or from buttonthread when GPS_POWER_TOGGLE is enabled.
Observable<void *> notifySleep, notifyDeepSleep;
Observable<void *> notifyGPSSleep;
// deep sleep support
RTC_DATA_ATTR int bootCount = 0;
@@ -167,6 +169,36 @@ static void waitEnterSleep()
notifySleep.notifyObservers(NULL);
}
void doGPSpowersave(bool on)
{
#ifdef HAS_PMU
if (on)
{
DEBUG_MSG("Turning GPS back on\n");
gps->forceWake(1);
setGPSPower(1);
}
else
{
DEBUG_MSG("Turning off GPS chip\n");
notifyGPSSleep.notifyObservers(NULL);
setGPSPower(0);
}
#endif
#ifdef PIN_GPS_WAKE
if (on)
{
DEBUG_MSG("Waking GPS");
gps->forceWake(1);
}
else
{
DEBUG_MSG("GPS entering sleep");
notifyGPSSleep.notifyObservers(NULL);
}
#endif
}
void doDeepSleep(uint64_t msecToWake)
{
DEBUG_MSG("Entering deep sleep for %lu seconds\n", msecToWake / 1000);