0
0
Fork 0

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.
This commit is contained in:
Jannik Beyerstedt 2026-06-17 23:07:29 +02:00
commit 002f0bb08b

View file

@ -267,13 +267,18 @@ async fn gnss_task(
) )
.await; .await;
let mut fix_drop_message = false;
loop { loop {
if let Ok(Some(embassy_gps::types::GpsEvent::Fix(fix))) = gps.step().await { if let Ok(Some(embassy_gps::types::GpsEvent::Fix(fix))) = gps.step().await {
// 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 // send to main thread
critical_section::with(|cs| { critical_section::with(|cs| {
let gnss_update_ref = GNSS_UPDATE.borrow(cs); let gnss_update_ref = GNSS_UPDATE.borrow(cs);
gnss_update_ref.replace(Some(fix)); gnss_update_ref.replace(Some(fix));
}); });
}
} else { } else {
// FSM will recover automatically from errors and ignore other event types // FSM will recover automatically from errors and ignore other event types
} }