From: Tilman Sauerbeck Date: Tue, 31 Dec 2019 10:28:58 +0000 (+0100) Subject: application: Manage whether or not we have valid GPS fix information. X-Git-Url: http://git.code-monkey.de/?a=commitdiff_plain;h=c14bb6b5cfbfdc40c7e5d981645604811041b640;p=gps-watch.git application: Manage whether or not we have valid GPS fix information. Expire such information after about 1.5s. --- diff --git a/src/application/main.rs b/src/application/main.rs index 74f1999..f1aaafe 100644 --- a/src/application/main.rs +++ b/src/application/main.rs @@ -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| {