Skip to content

Commit 6236cd0

Browse files
committed
fix: multiple things
1 parent 01c2550 commit 6236cd0

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/buttons.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::{
2+
stackmat::CURRENT_TIME,
23
state::{current_epoch, deeper_sleep_state, sleep_state, GlobalState, Scene},
34
structs::DelegateResponsePacket,
45
utils::buttons::{Button, ButtonTrigger, ButtonsHandler},
@@ -201,6 +202,10 @@ async fn inspection_start(
201202
return Ok(false);
202203
}
203204

205+
if unsafe { CURRENT_TIME } != 0 {
206+
return Ok(false);
207+
}
208+
204209
if state_val.scene < Scene::Inspection
205210
&& state_val.inspection_start.is_none()
206211
&& state_val.solve_time.is_none()

src/rfid.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::structs::{CardInfoResponsePacket, SolveConfirmPacket};
44
use crate::translations::{get_translation, TranslationKey};
55
use alloc::string::ToString;
66
use anyhow::{anyhow, Result};
7-
use embassy_time::{Duration, Timer};
7+
use embassy_time::{Duration, Instant, Timer};
88
use esp_hal::time::Rate;
99
use esp_hal::{
1010
dma::{DmaRxBuf, DmaTxBuf},
@@ -78,6 +78,7 @@ pub async fn rfid_task(
7878
log::debug!("PCD ver: {:?}", mfrc522.pcd_get_version().await);
7979

8080
let mut rfid_sleep = false;
81+
let mut last_card = (0, Instant::now());
8182
loop {
8283
Timer::after(Duration::from_millis(10)).await;
8384
if sleep_state() != rfid_sleep {
@@ -119,6 +120,11 @@ pub async fn rfid_task(
119120
};
120121
log::info!("Card UID: {card_uid}");
121122

123+
if last_card.0 == card_uid && (Instant::now() - last_card.1).as_millis() < 500 {
124+
continue;
125+
}
126+
last_card = (card_uid, Instant::now());
127+
122128
#[cfg(feature = "qa")]
123129
{
124130
crate::qa::send_qa_resp(crate::qa::QaSignal::Rfid(card_uid));

src/stackmat.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ use alloc::string::ToString;
1010
use embassy_time::{Instant, Timer};
1111
use esp_hal::{gpio::AnyPin, peripherals::UART1, uart::UartRx};
1212

13+
pub static mut CURRENT_TIME: u64 = 0;
14+
1315
#[embassy_executor::task]
1416
pub async fn stackmat_task(
1517
uart: UART1,
@@ -131,6 +133,10 @@ pub async fn stackmat_task(
131133
crate::qa::send_qa_resp(crate::qa::QaSignal::StackmatConnected);
132134
}
133135

136+
unsafe {
137+
CURRENT_TIME = parsed.1;
138+
}
139+
134140
if parsed.0 != last_stackmat_state {
135141
if parsed.0 == StackmatTimerState::Running {
136142
let mut state = global_state.state.lock().await;

0 commit comments

Comments
 (0)