Skip to main content

LayerToggle

Struct LayerToggle 

Source
pub struct LayerToggle<'peripherals> {
    debounce: Duration,
    high_pos: MatrixPos,
    last_level: Option<bool>,
    low_pos: MatrixPos,
    pending_release: Option<MatrixPos>,
    pin: ExtiInput<'peripherals, Async>,
}
Expand description

Input device that toggles layers based on a switch position.

Fields§

§debounce: Duration

Debounce duration applied to input level changes.

§high_pos: MatrixPos

Matrix position activated when the input is at a high logic level.

§last_level: Option<bool>

Last observed logic level of the input pin.

§low_pos: MatrixPos

Matrix position activated when the input is at a low logic level.

§pending_release: Option<MatrixPos>

Matrix position pending release after a level change.

§pin: ExtiInput<'peripherals, Async>

External interrupt input pin used to read the switch state.

Implementations§

Source§

impl<'peripherals> LayerToggle<'peripherals>

Source

fn maybe_emit_for_level(&mut self, new_level: bool) -> Option<KeyboardEvent>

Emit an event if the level has changed.

Source

pub const fn new( pin: ExtiInput<'peripherals, Async>, high_pos: MatrixPos, low_pos: MatrixPos, debounce: Duration, ) -> Self

Create a new layer toggle with a provided debounce duration.

Source

pub const fn new_with_default_debounce( pin: ExtiInput<'peripherals, Async>, high_pos: MatrixPos, low_pos: MatrixPos, ) -> Self

Create a new layer toggle with the default debounce.

Source

const fn pos_for_level(&self, level_high: bool) -> MatrixPos

Select the matrix position for the provided level.

Source

fn queue_tap(&mut self, pos: MatrixPos) -> KeyboardEvent

Queue a tap event for the provided position.

Source

async fn read_keyboard_event(&mut self) -> KeyboardEvent

Read the next layer-toggle KeyboardEvent.

Trait Implementations§

Source§

impl<'peripherals> InputDevice for LayerToggle<'peripherals>

Source§

type Event = KeyboardEvent

The event type produced by this input device
Source§

async fn read_event(&mut self) -> Self::Event

Read the raw input event
Source§

impl<'peripherals> Runnable for LayerToggle<'peripherals>

Source§

async fn run(&mut self) -> !

Auto Trait Implementations§

§

impl<'peripherals> Freeze for LayerToggle<'peripherals>

§

impl<'peripherals> RefUnwindSafe for LayerToggle<'peripherals>

§

impl<'peripherals> Send for LayerToggle<'peripherals>

§

impl<'peripherals> Sync for LayerToggle<'peripherals>

§

impl<'peripherals> Unpin for LayerToggle<'peripherals>

§

impl<'peripherals> UnsafeUnpin for LayerToggle<'peripherals>

§

impl<'peripherals> !UnwindSafe for LayerToggle<'peripherals>

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.