diff --git a/embassy/demos/picow/src/main.rs b/embassy/demos/picow/src/main.rs index e83ba6af575bc9e55636dd8fe8ff63225b94e70d..de0c517d22b5c32f920b3b29369004a40d5f7d68 100644 --- a/embassy/demos/picow/src/main.rs +++ b/embassy/demos/picow/src/main.rs @@ -9,6 +9,8 @@ pub use log::{debug, error, info, log, trace, warn}; #[cfg(feature = "defmt")] pub use defmt::{debug, error, info, panic, trace, warn}; +use core::ops::ControlFlow; + use {defmt_rtt as _, panic_probe as _}; use embassy_executor::Spawner; @@ -236,7 +238,7 @@ where menu.input_byte(*c); menu.context.out.flush(chanw).await?; - if menu.context.progress(chanr, chanw).await? { + if let ControlFlow::Break(_) = menu.context.progress(chanr, chanw).await? { break 'io; } } diff --git a/embassy/demos/picow/src/picowmenu.rs b/embassy/demos/picow/src/picowmenu.rs index 203ab92942a72eacf477c9f5ad6e9aec7830c389..8c606160bedc9d46b2e3cfb433387df8a997d807 100644 --- a/embassy/demos/picow/src/picowmenu.rs +++ b/embassy/demos/picow/src/picowmenu.rs @@ -11,7 +11,7 @@ pub use defmt::{debug, error, info, panic, trace, warn}; use core::fmt::{Write as _, Debug, Display}; use core::future::{poll_fn, Future}; -use core::ops::DerefMut; +use core::ops::{DerefMut, ControlFlow}; use core::sync::atomic::Ordering::{Relaxed, SeqCst}; use core::str::FromStr; @@ -92,12 +92,12 @@ impl MenuCtx { true } - // Returns `Ok(true)` to exit the menu + // Returns `Ok(Break)` to exit the menu pub(crate) async fn progress<R, W>( &mut self, mut chanr: &mut R, mut chanw: &mut W, - ) -> Result<bool> + ) -> Result<ControlFlow<()>> where R: AsyncRead<Error = sunset::Error>, W: AsyncWrite<Error = sunset::Error>, @@ -117,7 +117,7 @@ impl MenuCtx { } crate::serial(chanr, chanw, self.state.usb_pipe).await?; // TODO we could return to the menu on serial error? - return Ok(true); + return Ok(ControlFlow::Break(())); } } @@ -136,7 +136,7 @@ impl MenuCtx { } crate::serial(chanr, chanw, self.state.serial1_pipe).await?; // TODO we could return to the menu on serial error? - return Ok(true); + return Ok(ControlFlow::Break(())); } } @@ -153,7 +153,7 @@ impl MenuCtx { } if self.logout { - return Ok(true); + return Ok(ControlFlow::Break(())); } if self.reset { @@ -171,7 +171,7 @@ impl MenuCtx { // write messages from handling self.out.flush(&mut chanw).await?; - Ok(false) + Ok(ControlFlow::Continue(())) } }