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:
parent
57a6b7983d
commit
002f0bb08b
1 changed files with 10 additions and 5 deletions
15
src/main.rs
15
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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue