do not enter light-sleep when GPS is in GPS_ACTIVE state

This commit is contained in:
m1nl 2025-07-02 22:26:19 +02:00
parent fb4418b952
commit 4223701d0e
2 changed files with 13 additions and 1 deletions

View File

@ -805,13 +805,15 @@ bool GPS::setup()
} }
notifyDeepSleepObserver.observe(&notifyDeepSleep); notifyDeepSleepObserver.observe(&notifyDeepSleep);
preflightSleepObserver.observe(&preflightSleep);
return true; return true;
} }
GPS::~GPS() GPS::~GPS()
{ {
// we really should unregister our sleep observer // we really should unregister our sleep observers
preflightSleepObserver.unobserve(&preflightSleep);
notifyDeepSleepObserver.unobserve(&notifyDeepSleep); notifyDeepSleepObserver.unobserve(&notifyDeepSleep);
} }
@ -1171,6 +1173,12 @@ int GPS::prepareDeepSleep(void *unused)
return 0; return 0;
} }
// Prevents entering light-sleep when GPS is in active state
int GPS::preflightSleepCb(void *unused)
{
return (powerState == GPS_ACTIVE);
}
static const char *PROBE_MESSAGE = "Trying %s (%s)..."; static const char *PROBE_MESSAGE = "Trying %s (%s)...";
static const char *DETECTED_MESSAGE = "%s detected"; static const char *DETECTED_MESSAGE = "%s detected";

View File

@ -186,6 +186,7 @@ class GPS : private concurrency::OSThread
uint8_t numSatellites = 0; uint8_t numSatellites = 0;
CallbackObserver<GPS, void *> notifyDeepSleepObserver = CallbackObserver<GPS, void *>(this, &GPS::prepareDeepSleep); CallbackObserver<GPS, void *> notifyDeepSleepObserver = CallbackObserver<GPS, void *>(this, &GPS::prepareDeepSleep);
CallbackObserver<GPS, void *> preflightSleepObserver = CallbackObserver<GPS, void *>(this, &GPS::preflightSleepCb);
/** If !NULL we will use this serial port to construct our GPS */ /** If !NULL we will use this serial port to construct our GPS */
#if defined(ARCH_RP2040) #if defined(ARCH_RP2040)
@ -213,6 +214,9 @@ class GPS : private concurrency::OSThread
/// always returns 0 to indicate okay to sleep /// always returns 0 to indicate okay to sleep
int prepareDeepSleep(void *unused); int prepareDeepSleep(void *unused);
// Prevents entering light-sleep when GPS is in active state
int preflightSleepCb(void *unused);
/** Set power with EN pin, if relevant /** Set power with EN pin, if relevant
*/ */
void writePinEN(bool on); void writePinEN(bool on);