From 002f0bb08bc122a6c9838db7d97d931cae00b40e Mon Sep 17 00:00:00 2001 From: Jannik Beyerstedt Date: Wed, 17 Jun 2026 23:07:29 +0200 Subject: [PATCH] gnss: Only process every second fix event We always get two "fix" events per second right after each other. So let's drop one of them to not run GLOSA twice for each position update. --- src/main.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 60dd720..f00817f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -267,13 +267,18 @@ async fn gnss_task( ) .await; + let mut fix_drop_message = false; loop { if let Ok(Some(embassy_gps::types::GpsEvent::Fix(fix))) = gps.step().await { - // send to main thread - critical_section::with(|cs| { - let gnss_update_ref = GNSS_UPDATE.borrow(cs); - gnss_update_ref.replace(Some(fix)); - }); + // drop every second message as we always get each fix twice + fix_drop_message = !fix_drop_message; + if fix_drop_message { + // send to main thread + critical_section::with(|cs| { + let gnss_update_ref = GNSS_UPDATE.borrow(cs); + gnss_update_ref.replace(Some(fix)); + }); + } } else { // FSM will recover automatically from errors and ignore other event types }