Browse Source

add configurable GPS update interval

Make GPS update interval configurable via settings instead of using hardcoded 1 second value. The interval is persisted from preferences and can be adjusted at runtime through the sensor manager settings interface
pull/1156/head
csrutil 6 months ago
parent
commit
88fb173297
  1. 3
      examples/companion_radio/MyMesh.cpp
  2. 11
      src/helpers/sensors/EnvironmentSensorManager.cpp
  3. 1
      src/helpers/sensors/EnvironmentSensorManager.h

3
examples/companion_radio/MyMesh.cpp

@ -809,6 +809,9 @@ void MyMesh::begin(bool has_display) {
#if ENV_INCLUDE_GPS == 1
sensors.setSettingValue("gps", _prefs.gps_enabled ? "1" : "0");
char interval_str[12]; // Max: 24 hours = 86400 seconds (5 digits + null)
sprintf(interval_str, "%u", _prefs.gps_interval);
sensors.setSettingValue("gps_interval", interval_str);
#endif
}

11
src/helpers/sensors/EnvironmentSensorManager.cpp

@ -521,6 +521,15 @@ bool EnvironmentSensorManager::setSettingValue(const char* name, const char* val
}
return true;
}
if (strcmp(name, "gps_interval") == 0) {
uint32_t interval_seconds = atoi(value);
if (interval_seconds > 0) {
gps_update_interval_ms = interval_seconds * 1000;
} else {
gps_update_interval_ms = 1000; // Default to 1 second if 0
}
return true;
}
#endif
return false; // not supported
}
@ -708,7 +717,7 @@ void EnvironmentSensorManager::loop() {
}
#endif
}
next_gps_update = millis() + 1000;
next_gps_update = millis() + gps_update_interval_ms;
}
#endif
}

1
src/helpers/sensors/EnvironmentSensorManager.h

@ -25,6 +25,7 @@ protected:
bool gps_detected = false;
bool gps_active = false;
uint32_t gps_update_interval_ms = 1000; // Default 1 second
#if ENV_INCLUDE_GPS
LocationProvider* _location;

Loading…
Cancel
Save