application: Manage whether or not we have valid GPS fix information.
authorTilman Sauerbeck <tilman@code-monkey.de>
Tue, 31 Dec 2019 10:28:58 +0000 (11:28 +0100)
committerTilman Sauerbeck <tilman@code-monkey.de>
Mon, 6 Jan 2020 09:45:34 +0000 (10:45 +0100)
Expire such information after about 1.5s.

src/application/main.rs

index 74f199906853468fd5c6ac22fd41f25bc333480d..f1aaafe40b1a5e0bc7273f3231a68f3b331c6eda 100644 (file)
@@ -128,12 +128,22 @@ pub unsafe extern "C" fn _start() -> ! {
 
     let mut gps = gps::Gps::new();
 
+    let mut gps_has_fix = false;
+    let mut gps_has_fix_ticks = 0;
+
     let mut heart_icon_timer = Timer::new(1000);
 
     loop {
         let mut tap = gps::TimeAndPos::new();
 
         while gps.update(&mut tap) {
+            gps_has_fix = true;
+            gps_has_fix_ticks = systick::now();
+        }
+
+        // Did GPS fix information expire?
+        if gps_has_fix && systick::has_timeout_ms(gps_has_fix_ticks, 1500) {
+            gps_has_fix = false;
         }
 
         heart_icon_timer.update(|state| {