disable scanner when running motors

This commit is contained in:
Andy Killorin 2024-12-05 13:44:23 -05:00
parent 7df4e4e28f
commit d508e3bca6
Signed by: ank
GPG key ID: 23F9463ECB67FE8C
2 changed files with 15 additions and 2 deletions

View file

@ -1,4 +1,6 @@
use core::sync::atomic::AtomicBool;
use embassy_rp::gpio::Input;
use embassy_rp::multicore::spawn_core1;
use embassy_rp::multicore::Stack;
@ -14,6 +16,9 @@ use super::BIT;
use super::READ_CARD;
/// disable scanner when doing emf heavy operations
pub static LOCKOUT: AtomicBool = AtomicBool::new(false);
#[embassy_executor::task]
pub(crate) async fn data_extractor() -> ! {
let mut last_bit = 0;
@ -26,7 +31,12 @@ pub(crate) async fn data_extractor() -> ! {
if bit == last_bit {
if card !=0 {
info!("read a card: {card:#16x}");
if LOCKOUT.load(core::sync::atomic::Ordering::Relaxed) {
info!("scanner disabled");
} else {
CHANNEL.send(card).await;
}
}
critical_section::with(|cs| {
READ_CARD.replace(cs, 0);

View file

@ -4,6 +4,8 @@ use embassy_rp::pwm;
use embassy_time::Timer;
use rand::RngCore;
use crate::scanner::LOCKOUT;
use super::WAGS;
use embassy_rp::pwm::Pwm;
@ -30,6 +32,7 @@ pub(crate) async fn wiggle_manager(pwm: PWM_SLICE5, head: PIN_26, tail: PIN_27)
wags = WAGS.load(core::sync::atomic::Ordering::SeqCst);
if wags != 0 {
WAGS.store(0, core::sync::atomic::Ordering::SeqCst);
LOCKOUT.store(true, core::sync::atomic::Ordering::SeqCst);
break;
}
@ -37,7 +40,7 @@ pub(crate) async fn wiggle_manager(pwm: PWM_SLICE5, head: PIN_26, tail: PIN_27)
pwm.set_config(&c);
Timer::after_millis(50).await;
LOCKOUT.store(false, core::sync::atomic::Ordering::SeqCst);
}
let positions = [6200,4800,6248,4700, 5500];