Skip to main content

ShiftRegMatrix

Struct ShiftRegMatrix 

Source
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: ScanPos

The matrix position to resume scanning from on the next scan pass.

§col_settle_delay: Duration

Time to wait after selecting a column before reading row inputs.

Implementations§

Source§

impl<'peripherals, const ROW: usize, const COL: usize> ShiftRegMatrix<'peripherals, ROW, COL>

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<'peripherals, const ROW: usize, const COL: usize> InputDevice for ShiftRegMatrix<'peripherals, ROW, COL>

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, const ROW: usize, const COL: usize> Runnable for ShiftRegMatrix<'peripherals, ROW, COL>

Source§

async fn run(&mut self) -> !

Auto Trait Implementations§

§

impl<'peripherals, const ROW: usize, const COL: usize> Freeze for ShiftRegMatrix<'peripherals, ROW, COL>

§

impl<'peripherals, const ROW: usize, const COL: usize> RefUnwindSafe for ShiftRegMatrix<'peripherals, ROW, COL>

§

impl<'peripherals, const ROW: usize, const COL: usize> Send for ShiftRegMatrix<'peripherals, ROW, COL>

§

impl<'peripherals, const ROW: usize, const COL: usize> Sync for ShiftRegMatrix<'peripherals, ROW, COL>

§

impl<'peripherals, const ROW: usize, const COL: usize> Unpin for ShiftRegMatrix<'peripherals, ROW, COL>

§

impl<'peripherals, const ROW: usize, const COL: usize> UnsafeUnpin for ShiftRegMatrix<'peripherals, ROW, COL>

§

impl<'peripherals, const ROW: usize, const COL: usize> !UnwindSafe for ShiftRegMatrix<'peripherals, ROW, COL>

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.