Mainmenu #28
+2
-3
@@ -72,7 +72,7 @@ async fn main(spawner: Spawner) {
|
||||
peripherals.GPIO12,
|
||||
)));
|
||||
|
||||
setup_wifi(peripherals.WIFI, peripherals.FLASH, &spawner).await;
|
||||
//setup_wifi(peripherals.WIFI, peripherals.FLASH, &spawner).await;
|
||||
|
||||
log::info!("Setup complete, entering main loop");
|
||||
|
||||
@@ -87,8 +87,6 @@ async fn main(spawner: Spawner) {
|
||||
log::error!("NFC SAM configuration failed");
|
||||
}
|
||||
|
||||
log::info!("Setup complete, entering main loop");
|
||||
|
||||
let mut nav_state = NavigationState::new();
|
||||
|
||||
let button_config = InputConfig::default().with_pull(Pull::Up);
|
||||
@@ -101,5 +99,6 @@ async fn main(spawner: Spawner) {
|
||||
ok: Input::new(peripherals.GPIO45, button_config.clone()),
|
||||
};
|
||||
|
||||
log::info!("Setup complete, entering main loop");
|
||||
spawner.spawn(navigation::run(inputs, display).expect("run task failed"));
|
||||
}
|
||||
|
||||
@@ -8,7 +8,9 @@ use embassy_futures::select::select6;
|
||||
pub async fn run(mut inputs: Inputs, display: &'static mut PrimaryLcdDisplay<'static>) {
|
||||
let mut state = MainMenu { selected: 0 };
|
||||
|
||||
log::info!("starting navigation");
|
||||
loop {
|
||||
log::info!("await button press");
|
||||
let selection = select6(
|
||||
inputs.up.wait_for_low(),
|
||||
inputs.down.wait_for_low(),
|
||||
@@ -19,13 +21,32 @@ pub async fn run(mut inputs: Inputs, display: &'static mut PrimaryLcdDisplay<'st
|
||||
)
|
||||
.await;
|
||||
|
||||
log::info!("button pressed");
|
||||
let value = match selection {
|
||||
Either6::First(_) => (state.selected.wrapping_sub(1)) % MAX_SELECTED,
|
||||
Either6::Second(_) => (state.selected.wrapping_add(1)) % MAX_SELECTED,
|
||||
_ => continue, // Either6::Third(_) => ,
|
||||
// Either6::Fourth(_) => (),
|
||||
// Either6::Fifth(_) => (),
|
||||
// Either6::Sixth(_) => (),
|
||||
Either6::First(_) => {
|
||||
log::info!("up pressed");
|
||||
(state.selected.wrapping_sub(1)) % MAX_SELECTED
|
||||
}
|
||||
Either6::Second(_) => {
|
||||
log::info!("down pressed");
|
||||
(state.selected.wrapping_add(1)) % MAX_SELECTED
|
||||
}
|
||||
Either6::Third(_) => {
|
||||
log::info!("left pressed");
|
||||
continue;
|
||||
}
|
||||
Either6::Fourth(_) => {
|
||||
log::info!("right pressed");
|
||||
continue;
|
||||
}
|
||||
Either6::Fifth(_) => {
|
||||
log::info!("ok pressed");
|
||||
continue;
|
||||
}
|
||||
Either6::Sixth(_) => {
|
||||
log::info!("back pressed");
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
||||
state.selected = value;
|
||||
|
||||
Reference in New Issue
Block a user