pub struct ButtonConfig {
pub debounce_ms: Millis,
pub double_click_ms: Millis,
pub hold_ms: Millis,
pub active_level: ActiveLevel,
}Expand description
Button timing and polarity configuration.
Fields§
§debounce_ms: MillisTime the raw pin state must remain unchanged before it is accepted as the stable debounced state.
double_click_ms: MillisMaximum interval between two short releases that still counts as a double click.
hold_ms: MillisTime after which a continuously pressed button reports a hold event.
active_level: ActiveLevelElectrical level that represents the pressed state.
Implementations§
Source§impl ButtonConfig
impl ButtonConfig
Sourcepub const DEFAULT_DEBOUNCE_MS: Millis = 20
pub const DEFAULT_DEBOUNCE_MS: Millis = 20
Default debounce time.
Sourcepub const DEFAULT_DOUBLE_CLICK_MS: Millis = 300
pub const DEFAULT_DOUBLE_CLICK_MS: Millis = 300
Default double-click interval.
Sourcepub const DEFAULT_HOLD_MS: Millis = 800
pub const DEFAULT_HOLD_MS: Millis = 800
Default hold threshold.
Sourcepub const fn active_low() -> Self
pub const fn active_low() -> Self
Creates a configuration for the common pull-up wiring where the pressed state is low.
Sourcepub const fn active_high() -> Self
pub const fn active_high() -> Self
Creates a configuration where the pressed state is high.
Sourcepub const fn with_debounce_ms(self, debounce_ms: Millis) -> Self
pub const fn with_debounce_ms(self, debounce_ms: Millis) -> Self
Returns the configuration with a different debounce time.
Sourcepub const fn with_double_click_ms(self, double_click_ms: Millis) -> Self
pub const fn with_double_click_ms(self, double_click_ms: Millis) -> Self
Returns the configuration with a different double-click interval.
Sourcepub const fn with_hold_ms(self, hold_ms: Millis) -> Self
pub const fn with_hold_ms(self, hold_ms: Millis) -> Self
Returns the configuration with a different hold threshold.
Trait Implementations§
Source§impl Clone for ButtonConfig
impl Clone for ButtonConfig
Source§fn clone(&self) -> ButtonConfig
fn clone(&self) -> ButtonConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for ButtonConfig
Source§impl Debug for ButtonConfig
impl Debug for ButtonConfig
Source§impl Default for ButtonConfig
impl Default for ButtonConfig
impl Eq for ButtonConfig
Source§impl PartialEq for ButtonConfig
impl PartialEq for ButtonConfig
Source§fn eq(&self, other: &ButtonConfig) -> bool
fn eq(&self, other: &ButtonConfig) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ButtonConfig
Auto Trait Implementations§
impl Freeze for ButtonConfig
impl RefUnwindSafe for ButtonConfig
impl Send for ButtonConfig
impl Sync for ButtonConfig
impl Unpin for ButtonConfig
impl UnsafeUnpin for ButtonConfig
impl UnwindSafe for ButtonConfig
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