Browse Source

move GPS preference initialization to UITask

pull/1156/head
csrutil 6 months ago
parent
commit
39503ad0b4
  1. 10
      examples/companion_radio/main.cpp
  2. 13
      examples/companion_radio/ui-new/UITask.cpp

10
examples/companion_radio/main.cpp

@ -216,16 +216,6 @@ void setup() {
sensors.begin();
#if ENV_INCLUDE_GPS == 1
// Apply GPS preferences after sensors.begin() so gps_detected is set
sensors.setSettingValue("gps", the_mesh.getNodePrefs()->gps_enabled ? "1" : "0");
if (the_mesh.getNodePrefs()->gps_interval > 0) {
char interval_str[12];
sprintf(interval_str, "%u", the_mesh.getNodePrefs()->gps_interval);
sensors.setSettingValue("gps_interval", interval_str);
}
#endif
#ifdef DISPLAY_CLASS
ui_task.begin(disp, &sensors, the_mesh.getNodePrefs()); // still want to pass this in as dependency, as prefs might be moved
#endif

13
examples/companion_radio/ui-new/UITask.cpp

@ -537,6 +537,19 @@ void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* no
#endif
_node_prefs = node_prefs;
#if ENV_INCLUDE_GPS == 1
// Apply GPS preferences from stored prefs
if (_sensors != NULL && _node_prefs != NULL) {
_sensors->setSettingValue("gps", _node_prefs->gps_enabled ? "1" : "0");
if (_node_prefs->gps_interval > 0) {
char interval_str[12]; // Max: 24 hours = 86400 seconds (5 digits + null)
sprintf(interval_str, "%u", _node_prefs->gps_interval);
_sensors->setSettingValue("gps_interval", interval_str);
}
}
#endif
if (_display != NULL) {
_display->turnOn();
}

Loading…
Cancel
Save