pub struct ShiftRegMatrix<'peripherals, const ROW: usize, const COL: usize> {
cols: Hc595Cols<'peripherals>,
debouncer: DefaultDebouncer<ROW, COL>,
key_state: KeyGrid<ROW, COL>,
rows: [ExtiInput<'peripherals, Async>; ROW],
scan_pos: ScanPos,
col_settle_delay: Duration,
}Expand description
Keyboard matrix scanner driven by a 74HC595 shift register for column selection and GPIO EXTI inputs for row sensing.
Fields§
§cols: Hc595Cols<'peripherals>Shift register column driver.
debouncer: DefaultDebouncer<ROW, COL>Debouncer for filtering spurious key state transitions.
key_state: KeyGrid<ROW, COL>Shadow of the current debounced key state for all positions.
rows: [ExtiInput<'peripherals, Async>; ROW]Row input pins with interrupt support for key sensing.
scan_pos: ScanPosThe matrix position to resume scanning from on the next scan pass.
col_settle_delay: DurationTime to wait after selecting a column before reading row inputs.
Implementations§
Source§impl<'peripherals, const ROW: usize, const COL: usize> ShiftRegMatrix<'peripherals, ROW, COL>
impl<'peripherals, const ROW: usize, const COL: usize> ShiftRegMatrix<'peripherals, ROW, COL>
Sourcepub fn new(
rows: [ExtiInput<'peripherals, Async>; ROW],
cols: Hc595Cols<'peripherals>,
config: ShiftRegMatrixConfig,
) -> Self
pub fn new( rows: [ExtiInput<'peripherals, Async>; ROW], cols: Hc595Cols<'peripherals>, config: ShiftRegMatrixConfig, ) -> Self
Creates a new ShiftRegMatrix scanner instance.
Deselects all columns on construction to ensure a clean initial state.
Sourceasync fn read_keyboard_event(&mut self) -> KeyboardEvent
async fn read_keyboard_event(&mut self) -> KeyboardEvent
Waits until the next debounced [KeyboardEvent] is available and
returns it.
Repeatedly scans the matrix until a key state change is detected.
Sourceasync fn scan_until_event(&mut self) -> Option<KeyboardEvent>
async fn scan_until_event(&mut self) -> Option<KeyboardEvent>
Performs one scan pass over the matrix and returns the first debounced
[KeyboardEvent] detected, or [None] if no change occurred.
Scanning resumes from the last recorded ScanPos to avoid missing
events when a previous scan was interrupted early. Resets ScanPos
to the origin after a full pass with no event.