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
This commit is contained in:
@@ -809,6 +809,9 @@ void MyMesh::begin(bool has_display) {
|
|||||||
|
|
||||||
#if ENV_INCLUDE_GPS == 1
|
#if ENV_INCLUDE_GPS == 1
|
||||||
sensors.setSettingValue("gps", _prefs.gps_enabled ? "1" : "0");
|
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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -521,6 +521,15 @@ bool EnvironmentSensorManager::setSettingValue(const char* name, const char* val
|
|||||||
}
|
}
|
||||||
return true;
|
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
|
#endif
|
||||||
return false; // not supported
|
return false; // not supported
|
||||||
}
|
}
|
||||||
@@ -708,7 +717,7 @@ void EnvironmentSensorManager::loop() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
next_gps_update = millis() + 1000;
|
next_gps_update = millis() + gps_update_interval_ms;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ protected:
|
|||||||
|
|
||||||
bool gps_detected = false;
|
bool gps_detected = false;
|
||||||
bool gps_active = false;
|
bool gps_active = false;
|
||||||
|
uint32_t gps_update_interval_ms = 1000; // Default 1 second
|
||||||
|
|
||||||
#if ENV_INCLUDE_GPS
|
#if ENV_INCLUDE_GPS
|
||||||
LocationProvider* _location;
|
LocationProvider* _location;
|
||||||
|
|||||||
Reference in New Issue
Block a user