pass outputs and state to nfc task so that they can show errors on their own

This commit is contained in:
2026-08-30 09:18:53 +00:00
parent 3d36885e11
commit 3c657045ca
5 changed files with 79 additions and 43 deletions
+16 -2
View File
@@ -1,4 +1,9 @@
use crate::peripherals::Peripherals;
use crate::navigation::navigation::display_error;
use crate::{
navigation::{navigation::Mutex, outputs::Outputs, state::NavigationState},
peripherals::Peripherals,
};
use alloc::string::ToString;
use embedded_hal_bus::i2c::AtomicDevice;
use esp_hal::{Blocking, i2c::master::I2c, time::Instant};
@@ -15,7 +20,9 @@ use crate::{
)]
pub async fn nfc_scanner(
mut nfc_driver: NfcPn532Driver<AtomicDevice<'static, I2c<'static, Blocking>>>,
outputs: &'static Mutex<Outputs>,
peripherals: &'static Peripherals,
navigation_state: &'static Mutex<NavigationState>,
) {
loop {
while CARD_DATA.lock().await.is_none() {
@@ -45,7 +52,14 @@ pub async fn nfc_scanner(
{
Ok(()) => {}
Err(error) => {
log::error!("Error storing card in flash: {:?}", error)
log::error!("Error storing card in flash: {:?}", error);
display_error(
error.to_string(),
navigation_state,
outputs,
peripherals,
)
.await;
}
}