Weird antenna problem

This commit is contained in:
Dandaedre 2024-02-24 03:33:30 +01:00
parent 440515cf47
commit 9e20b1de76
2 changed files with 76 additions and 68 deletions

View File

@ -19,49 +19,34 @@ use crate::{
layout::{A1, B1, 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, sender: &ChannelType) {
// Big switchcase
let m1 = ActionsTypes::from(Key { key: KeyCode::A });
let void = ActionsTypes::from(NoOp {});
// let m1 = ActionsTypes::from(Key { key: KeyCode::A });
// let void = ActionsTypes::from(NoOp {});
match (
A1.load(Ordering::Relaxed),
B1.load(Ordering::Relaxed),
C1.load(Ordering::Relaxed),
&pressed_key,
) {
(_, _, _, &KeypadKey::A2) => m1.launch(sender), // Use a macro creating this function
// (_, _, _, &KeypadKey::A3) => Key { key: KeyCode::B }.launch(sender),
// (_, _, _, &KeypadKey::A4) => Key { key: KeyCode::C }.launch(sender),
// (_, _, _, &KeypadKey::B2) => Key { key: KeyCode::D }.launch(sender),
// (_, _, _, &KeypadKey::B3) => Key { key: KeyCode::E }.launch(sender),
// (_, _, _, &KeypadKey::B4) => Key { key: KeyCode::F }.launch(sender),
// (_, _, _, &KeypadKey::C2) => Key { key: KeyCode::G }.launch(sender),
// (_, _, _, &KeypadKey::C3) => Key { key: KeyCode::H }.launch(sender),
// (_, _, _, &KeypadKey::C4) => Key { key: KeyCode::I }.launch(sender),
// (_, _, _, _) => Key { key: KeyCode::I }.launch(sender),
(_, _, _, _) => void.launch(sender),
(_, _, _, &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::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::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,
}
.await;
// Return
}
// static MACRO1: ActionsTypes = ActionsTypes::from(Key { key: KeyCode::A });
// static MACRO2: ActionsTypes = ActionsTypes::from(Key { key: KeyCode::B });
// static MACRO3: ActionsTypes = ActionsTypes::from(Key { key: KeyCode::C });
// static MACRO4: ActionsTypes = ActionsTypes::from(Key { key: KeyCode::A });
// static MACRO5: ActionsTypes = ActionsTypes::from(Key { key: KeyCode::B });
// static MACRO6: ActionsTypes = ActionsTypes::from(Key { key: KeyCode::C });
// static MACRO7: ActionsTypes = ActionsTypes::from(Key { key: KeyCode::A });
// static MACRO8: ActionsTypes = ActionsTypes::from(Key { key: KeyCode::B });
// static MACRO9: ActionsTypes = ActionsTypes::from(Key { key: KeyCode::C });
// static VOIDMACRO: ActionsTypes = ActionsTypes::from(NoOp {});
pub(crate) async fn keydispatch_release(released_key: &KeypadKey, sender: &ChannelType) {
let _ = released_key;
// Big switchcase
@ -69,26 +54,26 @@ pub(crate) async fn keydispatch_release(released_key: &KeypadKey, sender: &Chann
// Return
}
#[enum_dispatch]
// #[enum_dispatch]
trait Act {
async fn launch(&self, sender: &ChannelType);
}
#[enum_dispatch(Act)]
enum ActionsTypes {
/// Placeholder no-op action
NoOp,
// /// List of actions to be performed
// Macro,
/// Just one keypress
Key,
// /// Chord modifier, will affect the other key pressed
// Chord,
// /// Will act as a Chord unless just pressed (Then acts as a Macro)
// ChordMacro,
// /// Will act as a Chord unless just pressed (Then acts as a Key)
// ChordKey,
}
// #[enum_dispatch(Act)]
// enum ActionsTypes {
// /// Placeholder no-op action
// NoOp,
// // /// List of actions to be performed
// // Macro,
// /// Just one keypress
// Key,
// // /// Chord modifier, will affect the other key pressed
// // Chord,
// // /// Will act as a Chord unless just pressed (Then acts as a Macro)
// // ChordMacro,
// // /// Will act as a Chord unless just pressed (Then acts as a Key)
// // ChordKey,
// }
struct Key {
key: KeyCode,

View File

@ -1,5 +1,3 @@
#![feature(const_trait_impl)]
#![feature(effects)]
#![no_std]
#![no_main]
mod dispatch;
@ -12,7 +10,7 @@ use core::sync::atomic::{AtomicBool, Ordering};
use defmt::*;
use embassy_executor::Spawner;
use embassy_futures::join::{join, join3};
use embassy_futures::join::{join, join3, join5, join_array};
use embassy_rp::bind_interrupts;
use embassy_rp::peripherals::USB;
use embassy_rp::usb::{Driver, InterruptHandler};
@ -107,27 +105,37 @@ async fn main(_spawner: Spawner) {
}
};
let in_fut = async {
// loop {
await_key(p.PIN_1, layout::KeypadKey::A1, &channel).await;
await_key(p.PIN_2, layout::KeypadKey::A2, &channel).await;
await_key(p.PIN_3, layout::KeypadKey::A3, &channel).await;
await_key(p.PIN_4, layout::KeypadKey::A4, &channel).await;
await_key(p.PIN_5, layout::KeypadKey::B1, &channel).await;
await_key(p.PIN_6, layout::KeypadKey::B2, &channel).await;
await_key(p.PIN_7, layout::KeypadKey::B3, &channel).await;
await_key(p.PIN_8, layout::KeypadKey::B4, &channel).await;
await_key(p.PIN_9, layout::KeypadKey::C1, &channel).await;
await_key(p.PIN_10, layout::KeypadKey::C2, &channel).await;
await_key(p.PIN_11, layout::KeypadKey::C3, &channel).await;
await_key(p.PIN_12, layout::KeypadKey::C4, &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 list_keys = [
// await_key(p.PIN_4, layout::KeypadKey::A4, &channel).await,
// await_key(p.PIN_1, layout::KeypadKey::A1, &channel).await,
// await_key(p.PIN_2, layout::KeypadKey::A2, &channel).await,
// await_key(p.PIN_3, layout::KeypadKey::A3, &channel).await,
// await_key(p.PIN_5, layout::KeypadKey::B1, &channel).await,
// await_key(p.PIN_6, layout::KeypadKey::B2, &channel).await,
// await_key(p.PIN_7, layout::KeypadKey::B3, &channel).await,
// await_key(p.PIN_8, layout::KeypadKey::B4, &channel).await,
// await_key(p.PIN_9, layout::KeypadKey::C1, &channel).await,
// ];
// let in_fut = async {
// await_key(p.PIN_4, layout::KeypadKey::A4, &channel).await;
// await_key(p.PIN_1, layout::KeypadKey::A1, &channel).await;
// await_key(p.PIN_2, layout::KeypadKey::A2, &channel).await;
// await_key(p.PIN_3, layout::KeypadKey::A3, &channel).await;
// await_key(p.PIN_5, layout::KeypadKey::B1, &channel).await;
// await_key(p.PIN_6, layout::KeypadKey::B2, &channel).await;
// await_key(p.PIN_7, layout::KeypadKey::B3, &channel).await;
// await_key(p.PIN_8, layout::KeypadKey::B4, &channel).await;
// await_key(p.PIN_9, layout::KeypadKey::C1, &channel).await;
// await_key(p.PIN_10, layout::KeypadKey::C2, &channel).await;
// await_key(p.PIN_11, layout::KeypadKey::C3, &channel).await;
// await_key(p.PIN_12, layout::KeypadKey::C4, &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 {
reader.run(false, &request_handler).await;
@ -135,7 +143,22 @@ 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, in_fut, out_fut)).await;
// join(usb_fut, join3(senderloop, join_array(list_keys), out_fut)).await;
join(
usb_fut,
join3(
senderloop,
// join5(
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_6, layout::KeypadKey::B2, &channel),
// await_key(p.PIN_7, layout::KeypadKey::B3, &channel),
// ),
out_fut,
),
)
.await;
}
struct MyRequestHandler {}