Enum button_driver::State
source · pub enum State {
Down(Instant),
Pressed(Instant),
Up(Instant),
Held(Instant),
Released,
Unknown,
}Expand description
Represents current button state.
State machine diagram:
ⓘ
Down => Pressed | Released
Pressed => Held => Up
Up => Released | Down
Held => Released
Released => Down
Unknown => Down | ReleasedVariants§
Down(Instant)
The button has been just pressed, so it is in down position.
Pressed(Instant)
Debounced press.
Up(Instant)
The button has been just released, so it is in up position.
Held(Instant)
The button is being held.
Released
Fully released state, idle.
Unknown
Initial state.
Implementations§
source§impl State
impl State
sourcepub fn is_pressed(&self) -> bool
pub fn is_pressed(&self) -> bool
sourcepub fn is_released(&self) -> bool
pub fn is_released(&self) -> bool
sourcepub fn is_unknown(&self) -> bool
pub fn is_unknown(&self) -> bool
Trait Implementations§
source§impl PartialEq<State> for State
impl PartialEq<State> for State
impl Copy for State
impl Eq for State
impl StructuralEq for State
impl StructuralPartialEq for State
Auto Trait Implementations§
impl RefUnwindSafe for State
impl Send for State
impl Sync for State
impl Unpin for State
impl UnwindSafe for State
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