#[cfg(all(not(doc), not(feature = "host")))]
use crate::button_watch;
#[cfg(all(not(doc), not(feature = "host")))]
button_watch! {
pub ButtonWatchGenerated {
pin: PIN_13,
}
}
#[cfg(doc)]
pub struct ButtonWatchGenerated {
button_watch: super::ButtonWatchRp,
}
#[cfg(doc)]
impl ButtonWatchGenerated {
pub fn new(
pin: impl Into<embassy_rp::Peri<'static, embassy_rp::peripherals::PIN_13>>,
pressed_to: crate::button::PressedTo,
spawner: embassy_executor::Spawner,
) -> crate::Result<&'static mut Self> {
static INSTANCE: static_cell::StaticCell<ButtonWatchGenerated> =
static_cell::StaticCell::new();
let instance = INSTANCE.init(ButtonWatchGenerated {
button_watch: super::ButtonWatchRp {
signal: &embassy_sync::signal::Signal::new(),
state_signal: &embassy_sync::signal::Signal::new(),
is_pressed: &core::sync::atomic::AtomicBool::new(false),
},
});
let _ = (pin, pressed_to, spawner);
Ok(instance)
}
}
#[cfg(doc)]
impl core::ops::Deref for ButtonWatchGenerated {
type Target = super::ButtonWatchRp;
fn deref(&self) -> &Self::Target {
&self.button_watch
}
}
#[cfg(doc)]
impl crate::button::__ButtonMonitor for ButtonWatchGenerated {
fn is_pressed_raw(&self) -> bool {
<super::ButtonWatchRp as crate::button::Button>::is_pressed(&self.button_watch)
}
async fn wait_until_pressed_state(&mut self, pressed: bool) {
<super::ButtonWatchRp as crate::button::__ButtonMonitor>::wait_until_pressed_state(
&mut self.button_watch,
pressed,
)
.await
}
}
#[cfg(doc)]
impl crate::button::Button for ButtonWatchGenerated {
async fn wait_for_press_duration(&mut self) -> crate::button::PressDuration {
<super::ButtonWatchRp as crate::button::Button>::wait_for_press_duration(
&mut self.button_watch,
)
.await
}
}