diff --git a/src/dispatch.rs b/src/dispatch.rs index f0f3c66..9a7e4da 100644 --- a/src/dispatch.rs +++ b/src/dispatch.rs @@ -33,16 +33,19 @@ pub(crate) async fn keydispatch_press(pressed_key: &KeypadKey, sender: &ChannelT C1.load(Ordering::Relaxed), &pressed_key, ) { + (_, _, _, &KeypadKey::A1) => Key { key: KeyCode::A }.launch(sender).await, (_, _, _, &KeypadKey::A2) => Key { key: KeyCode::B }.launch(sender).await, (_, _, _, &KeypadKey::A3) => Key { key: KeyCode::C }.launch(sender).await, (_, _, _, &KeypadKey::A4) => Key { key: KeyCode::D }.launch(sender).await, + (_, _, _, &KeypadKey::B1) => Key { key: KeyCode::E }.launch(sender).await, (_, _, _, &KeypadKey::B2) => Key { key: KeyCode::F }.launch(sender).await, (_, _, _, &KeypadKey::B3) => Key { key: KeyCode::G }.launch(sender).await, (_, _, _, &KeypadKey::B4) => Key { key: KeyCode::H }.launch(sender).await, + (_, _, _, &KeypadKey::C1) => Key { key: KeyCode::I }.launch(sender).await, (_, _, _, &KeypadKey::C2) => Key { key: KeyCode::J }.launch(sender).await, (_, _, _, &KeypadKey::C3) => Key { key: KeyCode::K }.launch(sender).await, (_, _, _, &KeypadKey::C4) => Key { key: KeyCode::L }.launch(sender).await, - (_, _, _, _) => Key { key: KeyCode::Z }.launch(sender).await, + // (_, _, _, _) => Key { key: KeyCode::Z }.launch(sender).await, } // Return } diff --git a/src/keypress.rs b/src/keypress.rs index d36f8f8..9cc08da 100644 --- a/src/keypress.rs +++ b/src/keypress.rs @@ -16,10 +16,7 @@ //! keypress_manager.capture_keypress('A'); // Captures a keypress event for the letter 'A' //! ``` -use embassy_rp::{ - gpio::{Input, Pin, Pull}, - Peripherals, -}; +use embassy_rp::gpio::{AnyPin, Input, Pull}; use embassy_time::Timer; use crate::{ @@ -28,32 +25,8 @@ use crate::{ ChannelType, DEBOUNCE_TIMER, }; // pub(crate) static KEYMASK: AtomicU32 = AtomicU32::new(0); -pub(crate) async fn init_key(p: &Peripherals, corresponding_key: KeypadKey, sender: &ChannelType) { - match corresponding_key { - KeypadKey::A1 => { - await_key(p.PIN_1, KeypadKey::A1, sender); - } - KeypadKey::A2 => todo!(), - KeypadKey::A3 => todo!(), - KeypadKey::A4 => todo!(), - KeypadKey::B1 => todo!(), - KeypadKey::B2 => todo!(), - KeypadKey::B3 => todo!(), - KeypadKey::B4 => todo!(), - KeypadKey::C1 => todo!(), - KeypadKey::C2 => todo!(), - KeypadKey::C3 => todo!(), - KeypadKey::C4 => todo!(), - } -} -pub(crate) async fn await_key( - pin: PINTYPE, - corresponding_key: KeypadKey, - sender: &ChannelType, -) where - PINTYPE: Pin, -{ +pub(crate) async fn await_key(pin: AnyPin, corresponding_key: KeypadKey, sender: &ChannelType) { // Set up the signal pin that will be used to trigger the keyboard. let mut signal_pin = Input::new(pin, Pull::None); diff --git a/src/main.rs b/src/main.rs index 960c4be..5a6859c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,7 +10,7 @@ use core::sync::atomic::{AtomicBool, Ordering}; use defmt::*; use embassy_executor::Spawner; -use embassy_futures::join::{join, join3, join4, join5, join_array}; +use embassy_futures::join::{join, join3, join_array}; use embassy_rp::bind_interrupts; use embassy_rp::peripherals::USB; use embassy_rp::usb::{Driver, InterruptHandler}; @@ -107,18 +107,18 @@ async fn main(_spawner: Spawner) { }; let in_fut = [ - await_key(p.PIN_4, layout::KeypadKey::A4, &channel), - await_key(p.PIN_1, layout::KeypadKey::A1, &channel), - await_key(p.PIN_2, layout::KeypadKey::A2, &channel), - await_key(p.PIN_3, layout::KeypadKey::A3, &channel), - await_key(p.PIN_5, layout::KeypadKey::B1, &channel), - await_key(p.PIN_6, layout::KeypadKey::B2, &channel), - await_key(p.PIN_7, layout::KeypadKey::B3, &channel), - await_key(p.PIN_8, layout::KeypadKey::B4, &channel), - await_key(p.PIN_9, layout::KeypadKey::C1, &channel), - await_key(p.PIN_10, layout::KeypadKey::C2, &channel), - await_key(p.PIN_11, layout::KeypadKey::C3, &channel), - await_key(p.PIN_12, layout::KeypadKey::C4, &channel), + await_key(p.PIN_1.into(), layout::KeypadKey::A1, &channel), + await_key(p.PIN_2.into(), layout::KeypadKey::A2, &channel), + await_key(p.PIN_3.into(), layout::KeypadKey::A3, &channel), + await_key(p.PIN_4.into(), layout::KeypadKey::A4, &channel), + await_key(p.PIN_5.into(), layout::KeypadKey::B1, &channel), + await_key(p.PIN_6.into(), layout::KeypadKey::B2, &channel), + await_key(p.PIN_7.into(), layout::KeypadKey::B3, &channel), + await_key(p.PIN_8.into(), layout::KeypadKey::B4, &channel), + await_key(p.PIN_11.into(), layout::KeypadKey::C1, &channel), + await_key(p.PIN_12.into(), layout::KeypadKey::C2, &channel), + await_key(p.PIN_10.into(), layout::KeypadKey::C3, &channel), + await_key(p.PIN_9.into(), layout::KeypadKey::C4, &channel), ]; let out_fut = async { @@ -128,21 +128,7 @@ async fn main(_spawner: Spawner) { // Run everything concurrently. // If we had made everything `'static` above instead, we could do this using separate tasks instead. // join(usb_fut, join3(senderloop, join_array(list_keys), out_fut)).await; - join( - usb_fut, - join3( - senderloop, - join4( - await_key(p.PIN_2, layout::KeypadKey::A2, &channel), - await_key(p.PIN_3, layout::KeypadKey::A3, &channel), - await_key(p.PIN_4, layout::KeypadKey::A4, &channel), - await_key(p.PIN_1, layout::KeypadKey::B2, &channel), - // await_key(p.PIN_7, layout::KeypadKey::B3, &channel), - ), - out_fut, - ), - ) - .await; + join(usb_fut, join3(senderloop, join_array(in_fut), out_fut)).await; } struct MyRequestHandler {}