got to idle state waiting for key
This commit is contained in:
15
src/main.rs
15
src/main.rs
@@ -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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user