got to idle state waiting for key

This commit is contained in:
2025-07-18 20:31:23 +01:00
parent cba331b939
commit d6a4b0fe22

View File

@@ -8,7 +8,10 @@ mod keyboard;
mod panic; mod panic;
mod timer; mod timer;
use avr_device::interrupt::{CriticalSection, Mutex}; use avr_device::{
asm::sleep,
interrupt::{CriticalSection, Mutex},
};
use calc_math::{ use calc_math::{
calc::{StackCalc, StackCalcError}, calc::{StackCalc, StackCalcError},
Decimal, Decimal,
@@ -544,6 +547,7 @@ fn main() -> ! {
}); });
if let TransientState::Done = state.transient { if let TransientState::Done = state.transient {
// No transient state - handle key or wait for key
if let Some(key) = key { if let Some(key) = key {
ufmt::uwriteln!( ufmt::uwriteln!(
&mut serial, &mut serial,
@@ -578,9 +582,14 @@ fn main() -> ! {
for (i, dec) in calc.iter().enumerate() { for (i, dec) in calc.iter().enumerate() {
ufmt::uwriteln!(&mut serial, "[{}] {}", i, dec).ok(); ufmt::uwriteln!(&mut serial, "[{}] {}", i, dec).ok();
} }
} else {
// Wait for key
sleep(); // Enter idle mode; wake up on interrupt
} }
} else { } else {
state.transient.on_frame(key) // In transient state - handle animation
arduino_hal::delay_ms(10);
state.transient.on_frame(key);
} }
match &state.transient { match &state.transient {
@@ -603,7 +612,5 @@ fn main() -> ! {
io_loop.update_display(&display); io_loop.update_display(&display);
}); });
}); });
arduino_hal::delay_ms(10);
} }
} }