rktk_drivers_common/keyscan/
mod.rs1use embassy_time::Duration;
4use embedded_hal::digital::{InputPin, OutputPin};
5use rktk::config::Hand;
6
7pub mod duplex_matrix;
8pub mod flex_pin;
9pub mod matrix;
10mod pressed;
11pub mod shift_register_matrix;
12
13pub async fn detect_hand_from_matrix<E, O: OutputPin<Error = E>, I: InputPin<Error = E>>(
20 mut output: O,
21 mut input: I,
22 input_delay: Option<Duration>,
23 high_hand: Option<Hand>,
24) -> Result<Hand, E> {
25 let high_hand = high_hand.unwrap_or(Hand::Left);
26
27 output.set_high()?;
28 embassy_time::Timer::after(input_delay.unwrap_or(Duration::from_millis(10))).await;
29 let hand = if input.is_high()? {
30 high_hand
31 } else {
32 high_hand.other()
33 };
34 output.set_low()?;
35
36 Ok(hand)
37}