pub struct ButtHead<I: TimeInstant> { /* private fields */ }Expand description
Button input processor.
Expects clean, debounced input. If your button is subject to mechanical
bounce, debounce the signal before passing it to update().
Implementations§
Source§impl<I: TimeInstant> ButtHead<I>
impl<I: TimeInstant> ButtHead<I>
Sourcepub fn new(config: &'static Config<I::Duration>) -> Self
pub fn new(config: &'static Config<I::Duration>) -> Self
Creates a new ButtHead instance with the given configuration.
Sourcepub fn is_pressed(&self) -> bool
pub fn is_pressed(&self) -> bool
Returns true if the button is currently physically pressed.
Sourcepub fn pressed_duration(&self, now: I) -> Option<I::Duration>
pub fn pressed_duration(&self, now: I) -> Option<I::Duration>
Returns how long the button has been continuously held, or None if it
is not currently pressed.
Sourcepub fn update(&mut self, is_pressed: bool, now: I) -> UpdateResult<I::Duration>
pub fn update(&mut self, is_pressed: bool, now: I) -> UpdateResult<I::Duration>
Advances the state machine.
is_pressed is the raw pin state (before active-low inversion).
now is the current timestamp. Returns the resulting event and the
recommended time for the next call.
Auto Trait Implementations§
impl<I> Freeze for ButtHead<I>where
I: Freeze,
impl<I> RefUnwindSafe for ButtHead<I>
impl<I> Send for ButtHead<I>
impl<I> Sync for ButtHead<I>
impl<I> Unpin for ButtHead<I>where
I: Unpin,
impl<I> UnsafeUnpin for ButtHead<I>where
I: UnsafeUnpin,
impl<I> UnwindSafe for ButtHead<I>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more