From 4d7316c074f07d02bdbdff1a98f0966bafda62e4 Mon Sep 17 00:00:00 2001 From: Tilman Sauerbeck Date: Sun, 19 Jan 2020 12:16:48 +0100 Subject: [PATCH] application: Show distance travelled while recording. --- src/application/main.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/application/main.rs b/src/application/main.rs index a8101f7..ac87977 100644 --- a/src/application/main.rs +++ b/src/application/main.rs @@ -229,14 +229,21 @@ pub unsafe extern "C" fn _start() -> ! { let mut prev_tap = gps::TimeAndPos::new(); + let mut total_distance_cm = 0; + loop { let mut tap = gps::TimeAndPos::new(); let mut show_time = false; + let mut show_distance = false; let old_gps_has_fix = gps_has_fix; while gps.update(&mut tap, uart0_try_read) { if is_recording { logger.log(&prev_tap, &tap); + + total_distance_cm += tap.distance_cm(&prev_tap) as u32; + + show_distance = true; } prev_tap = tap; @@ -276,7 +283,16 @@ pub unsafe extern "C" fn _start() -> ! { }); } - if show_time { + if show_distance { + let mut distance_m_s = [b' '; 8]; + + common::fmt::fmt_u32(&mut distance_m_s, total_distance_cm / 100); + + screen.clear(); + screen.draw_text(&distance_m_s); + + display.draw(&screen); + } else if show_time { if let Some(tm) = Time::from_unix_time(prev_tap.unix_time) { let mut time_s = [b' '; 8]; tm.fmt_time(&mut time_s); @@ -313,6 +329,8 @@ pub unsafe extern "C" fn _start() -> ! { } else { logger.stop_recording(&prev_tap); } + + total_distance_cm = 0; } } -- 2.30.2