Unsure about the dynamic dispatch.

This commit is contained in:
Dandaedre 2024-02-23 22:48:50 +01:00
parent 18e298d7da
commit 44c6c764a8
3 changed files with 30 additions and 10 deletions

View File

@ -13,14 +13,22 @@
//! let mut dispatch_manager = DispatchManager::new();
//! let macro_action = dispatch_manager.process_keypresses(); // Process captured keypresses and get the corresponding macro action
//! ```
use crate::{keysend::send_keypress, ChannelType};
use crate::{keysend::send_keypress, layout::A1, layout::B1, layout::C1, ChannelType};
use enum_dispatch::enum_dispatch;
use portable_atomic::Ordering;
use crate::{keyboard::KeyCode, layout::KeypadKey};
pub(crate) async fn keydispatch_press(pressed_key: &KeypadKey) {
// Big switchcase
match (
A1.load(Ordering::Relaxed),
B1.load(Ordering::Relaxed),
C1.load(Ordering::Relaxed),
pressed_key,
) {
(_, _, _, _) => (),
}
// Return
}
pub(crate) async fn keydispatch_release(pressed_key: &KeypadKey) {

View File

@ -4,7 +4,19 @@
//!
//! It provides functionality for defining the physical layout of the macropad, mapping keys to specific actions or macros, and managing the layout configuration.
//!
// TODO: Add a macro to generate all this and most of the dispatch
use core::sync::atomic::AtomicBool;
// #[derive(Debug)]
pub(crate) static A1: AtomicBool = AtomicBool::new(false);
pub(crate) static B1: AtomicBool = AtomicBool::new(false);
pub(crate) static C1: AtomicBool = AtomicBool::new(false);
pub(crate) enum MODKEYS {
A1,
B1,
C1,
}
pub(crate) enum KeypadKey {
A1,
A2,

View File

@ -107,14 +107,14 @@ async fn main(_spawner: Spawner) {
};
let in_fut = async {
loop {
await_key(p.PIN_1, layout::KeypadKey::A1, &channel);
// info!("Waiting for HIGH on pin 1");
// pin.wait_for_high().await;
// info!("HIGH DETECTED");
// pin.wait_for_low().await;
// info!("LOW DETECTED");
}
// loop {
await_key(p.PIN_1, layout::KeypadKey::A1, &channel).await;
// info!("Waiting for HIGH on pin 1");
// pin.wait_for_high().await;
// info!("HIGH DETECTED");
// pin.wait_for_low().await;
// info!("LOW DETECTED");
// }
};
let out_fut = async {