device_envoy_esp/button/button_watch_generated.rs
1// @generated - manually created as documentation example. Do not auto-generate.
2//! Module containing [`ButtonWatchGenerated`], the sample struct type generated by the
3//! [`button_watch!`](crate::button_watch!) macro.
4//!
5//! This file shows what the macro expansion looks like for documentation purposes.
6
7#[cfg(all(not(doc), not(feature = "host"), target_os = "none"))]
8use crate::button_watch;
9
10#[cfg(all(not(doc), not(feature = "host"), target_os = "none", esp_gdma_family))]
11button_watch! {
12 pub ButtonWatchGenerated {
13 pin: GPIO0,
14 }
15}
16
17#[cfg(all(not(doc), not(feature = "host"), target_os = "none", esp_pdma_family))]
18button_watch! {
19 pub ButtonWatchGenerated {
20 pin: GPIO0,
21 }
22}
23
24#[cfg(doc)]
25/// Sample struct type generated by the [`button_watch!`](crate::button_watch!) macro, showing all methods.
26///
27/// This page serves as the definitive reference for what a generated button watch type
28/// provides. For first-time readers, start with the examples in the [`button_watch!`](crate::button_watch!)
29/// macro documentation, then return here for a complete list of available methods.
30pub struct ButtonWatchGenerated;
31
32#[cfg(doc)]
33impl ButtonWatchGenerated {
34 /// Creates a new button monitor and spawns its background task.
35 ///
36 /// # Parameters
37 ///
38 /// - `button_pin`: GPIO pin for the button
39 /// - `pressed_to`: How the button is wired ([`PressedTo::Ground`](crate::button::PressedTo::Ground) or [`PressedTo::Voltage`](crate::button::PressedTo::Voltage))
40 /// - `spawner`: Task spawner for background operations
41 ///
42 /// # Errors
43 ///
44 /// Returns an error if the background task cannot be spawned.
45 ///
46 /// # Example
47 ///
48 /// See the [`button_watch!`](crate::button_watch!) macro for usage.
49 pub async fn new(
50 button_pin: impl Sized,
51 pressed_to: crate::button::PressedTo,
52 spawner: embassy_executor::Spawner,
53 ) -> crate::Result<&'static mut Self> {
54 static INSTANCE: static_cell::StaticCell<ButtonWatchGenerated> =
55 static_cell::StaticCell::new();
56 let instance = INSTANCE.init(ButtonWatchGenerated);
57 let _ = (button_pin, pressed_to, spawner);
58 Ok(instance)
59 }
60}
61
62#[cfg(doc)]
63impl crate::button::__ButtonMonitor for ButtonWatchGenerated {
64 fn is_pressed_raw(&self) -> bool {
65 false
66 }
67
68 async fn wait_until_pressed_state(&mut self, pressed: bool) {
69 let _ = pressed;
70 }
71}
72
73#[cfg(doc)]
74impl crate::button::Button for ButtonWatchGenerated {}