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: DurationDebounce duration applied to input level changes.
high_pos: MatrixPosMatrix 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: MatrixPosMatrix 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>
impl<'peripherals> LayerToggle<'peripherals>
Sourcefn maybe_emit_for_level(&mut self, new_level: bool) -> Option<KeyboardEvent>
fn maybe_emit_for_level(&mut self, new_level: bool) -> Option<KeyboardEvent>
Emit an event if the level has changed.
Sourcepub const fn new(
pin: ExtiInput<'peripherals, Async>,
high_pos: MatrixPos,
low_pos: MatrixPos,
debounce: Duration,
) -> Self
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.
Sourcepub const fn new_with_default_debounce(
pin: ExtiInput<'peripherals, Async>,
high_pos: MatrixPos,
low_pos: MatrixPos,
) -> Self
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.
Sourceconst fn pos_for_level(&self, level_high: bool) -> MatrixPos
const fn pos_for_level(&self, level_high: bool) -> MatrixPos
Select the matrix position for the provided level.
Sourcefn queue_tap(&mut self, pos: MatrixPos) -> KeyboardEvent
fn queue_tap(&mut self, pos: MatrixPos) -> KeyboardEvent
Queue a tap event for the provided position.
Sourceasync fn read_keyboard_event(&mut self) -> KeyboardEvent
async fn read_keyboard_event(&mut self) -> KeyboardEvent
Read the next layer-toggle KeyboardEvent.