try to workout buttons
This commit is contained in:
+2
-3
@@ -72,7 +72,7 @@ async fn main(spawner: Spawner) {
|
|||||||
peripherals.GPIO12,
|
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");
|
log::info!("Setup complete, entering main loop");
|
||||||
|
|
||||||
@@ -87,8 +87,6 @@ async fn main(spawner: Spawner) {
|
|||||||
log::error!("NFC SAM configuration failed");
|
log::error!("NFC SAM configuration failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
log::info!("Setup complete, entering main loop");
|
|
||||||
|
|
||||||
let mut nav_state = NavigationState::new();
|
let mut nav_state = NavigationState::new();
|
||||||
|
|
||||||
let button_config = InputConfig::default().with_pull(Pull::Up);
|
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()),
|
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"));
|
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>) {
|
pub async fn run(mut inputs: Inputs, display: &'static mut PrimaryLcdDisplay<'static>) {
|
||||||
let mut state = MainMenu { selected: 0 };
|
let mut state = MainMenu { selected: 0 };
|
||||||
|
|
||||||
|
log::info!("starting navigation");
|
||||||
loop {
|
loop {
|
||||||
|
log::info!("await button press");
|
||||||
let selection = select6(
|
let selection = select6(
|
||||||
inputs.up.wait_for_low(),
|
inputs.up.wait_for_low(),
|
||||||
inputs.down.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;
|
.await;
|
||||||
|
|
||||||
|
log::info!("button pressed");
|
||||||
let value = match selection {
|
let value = match selection {
|
||||||
Either6::First(_) => (state.selected.wrapping_sub(1)) % MAX_SELECTED,
|
Either6::First(_) => {
|
||||||
Either6::Second(_) => (state.selected.wrapping_add(1)) % MAX_SELECTED,
|
log::info!("up pressed");
|
||||||
_ => continue, // Either6::Third(_) => ,
|
(state.selected.wrapping_sub(1)) % MAX_SELECTED
|
||||||
// Either6::Fourth(_) => (),
|
}
|
||||||
// Either6::Fifth(_) => (),
|
Either6::Second(_) => {
|
||||||
// Either6::Sixth(_) => (),
|
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;
|
state.selected = value;
|
||||||
|
|||||||
Reference in New Issue
Block a user