gpsread.cpp: slow down spin loop

This commit is contained in:
cyberman54 2022-01-26 22:45:23 +01:00
parent 1ffdbdac3b
commit a0ea78844a

View File

@ -141,40 +141,35 @@ void gps_loop(void *pvParameters) {
while (1) { while (1) {
if (cfg.payloadmask & GPS_DATA) { while (cfg.payloadmask & GPS_DATA) {
#ifdef GPS_SERIAL #ifdef GPS_SERIAL
// feed GPS decoder with serial NMEA data from GPS device // feed GPS decoder with serial NMEA data from GPS device
while (GPS_Serial.available()) { while (GPS_Serial.available())
gps.encode(GPS_Serial.read()); if (gps.encode(GPS_Serial.read()))
yield(); break; // NMEA sentence complete
}
#elif defined GPS_I2C #elif defined GPS_I2C
Wire.requestFrom(GPS_ADDR, 32); // caution: this is a blocking call Wire.requestFrom(GPS_ADDR, 32); // caution: this is a blocking call
while (Wire.available()) { while (Wire.available())
gps.encode(Wire.read()); if (gps.encode(Wire.read()))
delay(2); // 2ms delay according L76 datasheet break; // NMEA sentence complete
yield();
}
#endif #endif
// (only) while device time is not set or unsynched, and we have a valid // (only) while device time is not set or unsynched, and we have a valid
// GPS time, we trigger a device time update to poll time from GPS // GPS time, we call calibrateTime to poll time immeditately from GPS
if ((timeSource == _unsynced || timeSource == _set) && if ((timeSource == _unsynced || timeSource == _set) &&
(gpstime.isUpdated() && gpstime.isValid() && gpstime.age() < 1000)) { (gpstime.isUpdated() && gpstime.isValid() && gpstime.age() < 1000))
calibrateTime(); calibrateTime();
}
} // if // show NMEA data, very noisy, useful only for debugging GPS
// ESP_LOGV(TAG, "GPS NMEA data: passed %u / failed: %u / with fix:
// %u", gps.passedChecksum(), gps.failedChecksum(), gps
// .sentencesWithFix());
// show NMEA data in verbose mode, useful only for debugging GPS, very delay(2);
// noisy ESP_LOGV(TAG, "GPS NMEA data: passed %u / failed: %u / with fix: } // inner while loop
// %u",
// gps.passedChecksum(), gps.failedChecksum(),
// gps.sentencesWithFix());
delay(50); delay(1000);
} // outer while loop
} // end of infinite loop
} // gps_loop() } // gps_loop()