Skip to content

Commit

Permalink
Merge pull request #847 from a-f-G-U-C/a-f-G-U-C-ublox-power
Browse files Browse the repository at this point in the history
disable gps powercycle for small gps_update_interval
  • Loading branch information
geeksville authored Sep 1, 2021
2 parents b1b3d9d + f96d8bf commit 8a7a3ec
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/gps/UBloxGPS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
#include "sleep.h"
#include <assert.h>

// if gps_update_interval below this value, do not powercycle the GPS
#define UBLOX_POWEROFF_THRESHOLD 90

extern RadioConfig radioConfig;

UBloxGPS::UBloxGPS() {}

bool UBloxGPS::tryConnect()
Expand Down Expand Up @@ -201,15 +206,20 @@ bool UBloxGPS::whileIdle()
/// Note: ublox doesn't need a wake method, because as soon as we send chars to the GPS it will wake up
void UBloxGPS::sleep()
{
// Tell GPS to power down until we send it characters on serial port (we leave vcc connected)
ublox.powerOff();
// setGPSPower(false);
if (radioConfig.preferences.gps_update_interval > UBLOX_POWEROFF_THRESHOLD) {
// Tell GPS to power down until we send it characters on serial port (we leave vcc connected)
ublox.powerOff();
// setGPSPower(false);
}
}

void UBloxGPS::wake()
{
fixType = 0; // assume we hace no fix yet
if (radioConfig.preferences.gps_update_interval > UBLOX_POWEROFF_THRESHOLD) {
fixType = 0; // assume we have no fix yet
}

// this is idempotent
setGPSPower(true);

// Note: no delay needed because now we leave gps power on always and instead use ublox.powerOff()
Expand Down

0 comments on commit 8a7a3ec

Please sign in to comment.