Skip to content

Commit adce5fc

Browse files
committed
feat: fix timer stuck issue
1 parent e0af609 commit adce5fc

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/stackmat.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,20 @@ pub async fn stackmat_task(
3939
if (esp_hal::time::Instant::now() - last_read).as_millis() > 500
4040
&& last_state != Some(false)
4141
{
42-
global_state.state.lock().await.stackmat_connected = Some(false);
4342
last_state = Some(false);
4443
display.set_data(&[255; 6]);
44+
45+
let mut state = global_state.state.lock().await;
46+
state.stackmat_connected = Some(false);
47+
48+
// TODO: re-think this and maybe reset whole state?
49+
if state.scene == Scene::Timer {
50+
if state.current_competitor.is_some() {
51+
state.scene = Scene::CompetitorInfo;
52+
} else {
53+
state.scene = Scene::WaitingForCompetitor;
54+
}
55+
}
4556
}
4657

4758
Timer::after_millis(10).await;
@@ -86,7 +97,11 @@ pub async fn stackmat_task(
8697
let n = {
8798
let n = uart.read_buffered(&mut read_buf);
8899
let Ok(n) = n else {
89-
log::error!("uart: read_bytes err");
100+
#[cfg(not(feature = "release_build"))]
101+
{
102+
log::error!("uart: read_bytes err {:?}", n.expect_err(""));
103+
}
104+
90105
continue;
91106
};
92107

0 commit comments

Comments
 (0)