Struct esp32_simple::button::Button
source · pub struct Button<'a, T, MODE, TR>where
T: InputPin,
MODE: InputMode,
TR: Trigger,{ /* private fields */ }Expand description
Represents a button with a notifier and a GPIO pin.
§Type Parameters
'a- Lifetime of the button.T- Type of the GPIO pin.MODE- Input mode of the GPIO pin.TR- The trigger type implementing theTriggertrait.
Implementations§
source§impl<'a, T, MODE, TR> Button<'a, T, MODE, TR>where
T: InputPin,
MODE: InputMode,
TR: Trigger,
impl<'a, T, MODE, TR> Button<'a, T, MODE, TR>where
T: InputPin,
MODE: InputMode,
TR: Trigger,
sourcepub fn new(
notifier: Notifier<TR>,
trigger: &'static TR,
pin: PinDriver<'a, T, MODE>,
state: Arc<Mutex<State>>,
) -> Result<Self>
pub fn new( notifier: Notifier<TR>, trigger: &'static TR, pin: PinDriver<'a, T, MODE>, state: Arc<Mutex<State>>, ) -> Result<Self>
Creates a new Button instance.
§Arguments
notifier- A notifier to send button press events.trigger- The trigger to emit when the button is pressed.pin- A GPIO pin driver.state- Shared state of the button.
§Returns
A new Button instance.
§Errors
Returns an error if the button cannot be initialized.