Abstracted statuses, made display event-driven

This commit is contained in:
Professr
2020-06-27 21:19:49 -07:00
parent 5ea59a1c4d
commit 542b8b26ce
16 changed files with 565 additions and 266 deletions

View File

@@ -116,7 +116,6 @@ The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of s
longitude = ublox.getLongitude(0);
altitude = ublox.getAltitude(0) / 1000; // in mm convert to meters
dop = ublox.getPDOP(0); // PDOP (an accuracy metric) is reported in 10^2 units so we have to scale down when we use it
DEBUG_MSG("new gps pos lat=%f, lon=%f, alt=%d, pdop=%f\n", latitude * 1e-7, longitude * 1e-7, altitude, dop * 1e-2);
// bogus lat lon is reported as 0 or 0 (can be bogus just for one)
// Also: apparently when the GPS is initially reporting lock it can output a bogus latitude > 90 deg!
@@ -129,6 +128,15 @@ The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of s
} else // we didn't get a location update, go back to sleep and hope the characters show up
wantNewLocation = true;
meshtastic::GPSStatus status;
status.hasLock = hasLock();
status.isConnected = isConnected;
status.latitude = latitude;
status.longitude = longitude;
status.altitude = altitude;
status.dop = dop;
newStatus.notifyObservers(status);
// Once we have sent a location once we only poll the GPS rarely, otherwise check back every 1s until we have something over
// the serial
setPeriod(hasValidLocation && !wantNewLocation ? 30 * 1000 : 10 * 1000);