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 {
// send to main thread // drop every second message as we always get each fix twice
critical_section::with(|cs| { fix_drop_message = !fix_drop_message;
let gnss_update_ref = GNSS_UPDATE.borrow(cs); if fix_drop_message {
gnss_update_ref.replace(Some(fix)); // send to main thread
}); critical_section::with(|cs| {
let gnss_update_ref = GNSS_UPDATE.borrow(cs);
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
} }