gps: add GpsDriver, handle the hardware and software switches in the drivers
This commit is contained in:
1 parent
978b6e01be
commit
81afafcb35
28 files changed
+892
-468
No files matched your search
@@ -392,16 +392,16 @@ public:
|
||||
char buf[50];
|
||||
int y = 18;
|
||||
bool gps_state = _task->getGPSState();
|
||||
#ifdef PIN_GPS_SWITCH
|
||||
bool hw_gps_state = digitalRead(PIN_GPS_SWITCH);
|
||||
bool hw_gps_state = nmea != NULL && nmea->isHardwareEnabled();
|
||||
if (nmea != NULL && nmea->hasHardwareEnableState()) {
|
||||
if (gps_state != hw_gps_state) {
|
||||
strcpy(buf, gps_state ? "gps off(hw)" : "gps off(sw)");
|
||||
} else {
|
||||
strcpy(buf, gps_state ? "gps on" : "gps off");
|
||||
}
|
||||
#else
|
||||
} else {
|
||||
strcpy(buf, gps_state ? "gps on" : "gps off");
|
||||
#endif
|
||||
}
|
||||
display.setColor(UIColor::primary_txt);
|
||||
display.drawTextLeftAlign(0, y, buf);
|
||||
if (nmea == NULL) {
|
||||
|
||||
@@ -254,16 +254,16 @@ public:
|
||||
char buf[50];
|
||||
int y = 8;
|
||||
bool gps_state = _task->getGPSState();
|
||||
#ifdef PIN_GPS_SWITCH
|
||||
bool hw_gps_state = digitalRead(PIN_GPS_SWITCH);
|
||||
bool hw_gps_state = nmea != NULL && nmea->isHardwareEnabled();
|
||||
if (nmea != NULL && nmea->hasHardwareEnableState()) {
|
||||
if (gps_state != hw_gps_state) {
|
||||
strcpy(buf, gps_state ? "gps off(hw)" : "gps off(sw)");
|
||||
} else {
|
||||
strcpy(buf, gps_state ? "gps on" : "gps off");
|
||||
}
|
||||
#else
|
||||
} else {
|
||||
strcpy(buf, gps_state ? "gps on" : "gps off");
|
||||
#endif
|
||||
}
|
||||
display.setColor(UIColor::primary_txt);
|
||||
display.drawTextLeftAlign(0, y, buf);
|
||||
if (nmea == NULL) {
|
||||
|
||||
@@ -159,6 +159,9 @@ protected:
|
||||
|
||||
#if ENV_INCLUDE_GPS == 1
|
||||
void applyGpsPrefs() {
|
||||
char period[11];
|
||||
snprintf(period, sizeof(period), "%lu", (unsigned long)_prefs.gps_period);
|
||||
sensors.setSettingValue("gps_period", period);
|
||||
sensors.setSettingValue("gps", _prefs.gps_enabled?"1":"0");
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -168,6 +168,9 @@ protected:
|
||||
|
||||
#if ENV_INCLUDE_GPS == 1
|
||||
void applyGpsPrefs() {
|
||||
char period[11];
|
||||
snprintf(period, sizeof(period), "%lu", (unsigned long)_prefs.gps_period);
|
||||
sensors.setSettingValue("gps_period", period);
|
||||
sensors.setSettingValue("gps", _prefs.gps_enabled?"1":"0");
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -173,6 +173,9 @@ private:
|
||||
|
||||
#if ENV_INCLUDE_GPS == 1
|
||||
void applyGpsPrefs() {
|
||||
char period[11];
|
||||
snprintf(period, sizeof(period), "%lu", (unsigned long)_prefs.gps_period);
|
||||
sensors.setSettingValue("gps_period", period);
|
||||
sensors.setSettingValue("gps", _prefs.gps_enabled?"1":"0");
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user