Added GPS PowerSaving v2 for some boards
This commit is contained in:
1 parent
b049177b81
commit
a27e78e4da
5 files changed
+121
-44
No files matched your search
@@ -45,12 +45,14 @@ mesh::LocalIdentity radio_new_identity() {
|
||||
void HWTSensorManager::start_gps() {
|
||||
if (!gps_active) {
|
||||
_location->begin(); // Claims periph_power via RefCountedDigitalPin
|
||||
gps_active = true;
|
||||
|
||||
if (_location->isPowerSavingEnabled()) {
|
||||
gps_wake = true; // gps_active is true
|
||||
gps_wake = true; // gps_active is unchanged (true for GPS sleep, false for GPS off)
|
||||
_location->syncTime(); // Clear GPS data and force sync time
|
||||
_location->setNextSleep(); // Next time to off
|
||||
} else {
|
||||
gps_active = true;
|
||||
gps_wake = true;
|
||||
}
|
||||
|
||||
Serial1.println("$CFGSYS,h35155*68"); // Configure GPS for all constellations
|
||||
@@ -89,24 +91,28 @@ void HWTSensorManager::loop() {
|
||||
static long next_gps_update = 0;
|
||||
|
||||
// PowerSaving
|
||||
if (_location->isPowerSavingEnabled()) {
|
||||
if (gps_wake && ((int32_t)(millis() - _location->getNextSleep()) >= 0 ||
|
||||
!_location->waitingTimeSync())) { // Time to off or GPS set
|
||||
if (_location->isPowerSavingEnabled() && gps_active) {
|
||||
// Handle change in PowerSaving mode
|
||||
_location->updatePowerSavingSettings(gps_wake);
|
||||
|
||||
if (gps_wake) {
|
||||
// GPS is awake: check whether it should sleep
|
||||
if ((int32_t)(millis() - _location->getNextSleep()) >= 0) {
|
||||
POWERSAVING_DEBUG_PRINTLN("GPS wake timeout. Enter sleep");
|
||||
stop_gps();
|
||||
} else if (!_location->waitingTimeSync()) {
|
||||
POWERSAVING_DEBUG_PRINTLN("GPS set. Enter sleep early");
|
||||
stop_gps();
|
||||
}
|
||||
} else {
|
||||
// GPS is asleep: check whether it should wake
|
||||
if ((int32_t)(millis() - _location->getNextWake()) >= 0) {
|
||||
POWERSAVING_DEBUG_PRINTLN("GPS sleep timeout. Wakeup.");
|
||||
start_gps();
|
||||
} else if (_location->waitingTimeSync()) {
|
||||
POWERSAVING_DEBUG_PRINTLN("CLI gps sync. Wakeup");
|
||||
start_gps();
|
||||
}
|
||||
|
||||
stop_gps();
|
||||
} else if (!gps_wake && ((int32_t)(millis() - _location->getNextWake()) >= 0)) { // Time to on
|
||||
POWERSAVING_DEBUG_PRINTLN("GPS sleep timeout. Wakeup.");
|
||||
|
||||
start_gps();
|
||||
} else if (!gps_wake && _location->waitingTimeSync()) { // On for "gps sync"
|
||||
POWERSAVING_DEBUG_PRINTLN("CLI gps sync. Wakeup");
|
||||
|
||||
start_gps();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,8 +151,10 @@ const char* HWTSensorManager::getSettingValue(int i) const {
|
||||
bool HWTSensorManager::setSettingValue(const char* name, const char* value) {
|
||||
if (strcmp(name, "gps") == 0) {
|
||||
if (strcmp(value, "0") == 0) {
|
||||
gps_active = false; // Disabled by CLI or App
|
||||
stop_gps();
|
||||
} else {
|
||||
gps_active = true; // Enabled by CLI or App
|
||||
start_gps();
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in new issue
Block a user