Compare commits

..

4 Commits
main ... dev

Author SHA1 Message Date
Dandaedre 5d154486c4 Another Round of depency hell 2024-03-30 15:18:32 +01:00
Dandaedre a936b04436 Adds latest macros 2024-03-26 18:00:41 +01:00
Dandaedre c0d56d86d0 Adds some def lookup 2024-03-25 15:42:44 +01:00
Dandaedre 9c28337d8b Adds todo 2024-03-15 22:02:40 +01:00
7 changed files with 156 additions and 90 deletions

View File

@ -1,102 +1,131 @@
[package] [package]
edition = "2021"
name = "macropad-rs" name = "macropad-rs"
version = "0.1.0" version = "0.1.0"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2021"
authors = ["Dandaedre <max.rigaut@gmail.com>"]
resolver = "2"
[dependencies] [dependencies]
embassy-embedded-hal = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy", features = ["defmt"] }
embassy-sync = { version = "0.5.0", git = "https://github.com/embassy-rs/embassy", features = ["defmt"] }
embassy-executor = { version = "0.5.0", git = "https://github.com/embassy-rs/embassy", features = ["task-arena-size-32768", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] }
embassy-time = { version = "0.3.0", git = "https://github.com/embassy-rs/embassy", features = ["defmt", "defmt-timestamp-uptime"] }
embassy-rp = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy", features = ["defmt", "unstable-pac", "time-driver", "critical-section-impl"] }
embassy-usb = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy", features = ["defmt"] }
embassy-futures = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy" }
cortex-m = { version = "0.7.6", features = ["inline-asm"] }
cortex-m-rt = "0.7.0"
defmt = "0.3" defmt = "0.3"
defmt-rtt = "0.4"
panic-probe = { version = "0.3", features = ["print-defmt"] }
embassy-embedded-hal = { git = "https://github.com/embassy-rs/embassy", features = ["defmt"] }
embassy-sync = {git = "https://github.com/embassy-rs/embassy", features = ["defmt"] }
embassy-executor = {git = "https://github.com/embassy-rs/embassy", features = ["task-arena-size-32768", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] }
embassy-time = {git = "https://github.com/embassy-rs/embassy", features = ["defmt", "defmt-timestamp-uptime"] }
embassy-rp = {git = "https://github.com/embassy-rs/embassy", features = ["defmt", "unstable-pac", "time-driver", "critical-section-impl"] }
embassy-usb = {git = "https://github.com/embassy-rs/embassy", features = ["defmt"] }
embassy-futures = {git = "https://github.com/embassy-rs/embassy" }
cortex-m = {features = ["inline-asm"] }
cortex-m-rt = "0.7.3"
usbd-hid = "*" usbd-hid = "*"
portable-atomic = { version = "1.5", features = ["critical-section"] } portable-atomic = { version = "1.6", features = ["critical-section"] }
defmt-rtt = "0.4.0"
panic-probe = "0.3.1"
[profile.release] [profile.release]
debug = 2 debug = 2
# [package]
# edition = "2021"
# name = "macropad-rs"
# version = "0.1.0"
# license = "MIT OR Apache-2.0"
# [dependencies] # [dependencies]
# embassy-sync = { version = "0.5.0", git = "https://github.com/embassy-rs/embassy", features = ["defmt"] } # embassy-embedded-hal = { git = "https://github.com/embassy-rs/embassy", features = ["defmt"] }
# embassy-executor = { version = "0.5.0", git = "https://github.com/embassy-rs/embassy", features = ["task-arena-size-32768", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } # embassy-sync = {git = "https://github.com/embassy-rs/embassy", features = ["defmt"] }
# embassy-time = { version = "0.3.0", git = "https://github.com/embassy-rs/embassy", features = ["defmt", "defmt-timestamp-uptime"] } # embassy-executor = {git = "https://github.com/embassy-rs/embassy", features = ["task-arena-size-32768", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] }
# embassy-rp = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy", features = ["defmt", "unstable-pac", "time-driver", "critical-section-impl"] } # embassy-time = {git = "https://github.com/embassy-rs/embassy", features = ["defmt", "defmt-timestamp-uptime"] }
# embassy-usb = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy", features = ["defmt"] } # embassy-rp = {git = "https://github.com/embassy-rs/embassy", features = ["defmt", "unstable-pac", "time-driver", "critical-section-impl"] }
# -embassy-net = { version = "0.4.0", git = "https://github.com/embassy-rs/embassy", features = ["defmt", "tcp", "udp", "dhcpv4", "medium-ethernet"] } # embassy-usb = {git = "https://github.com/embassy-rs/embassy", features = ["defmt"] }
# -embassy-net-wiznet = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy", features = ["defmt"] } # embassy-futures = {git = "https://github.com/embassy-rs/embassy" }
# embassy-futures = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy" } # cortex-m = {features = ["inline-asm"] }
# -embassy-usb-logger = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy" } # cortex-m-rt = "0.7.0"
# -cyw43 = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy", features = ["defmt", "firmware-logs"] }
# -cyw43-pio = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy", features = ["defmt", "overclock"] }
# defmt = "0.3" # defmt = "0.3"
# -defmt-rtt = "0.4" # usbd-hid = "*"
# -fixed = "1.23.1"
# -fixed-macro = "1.2"
# -
# -#cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
# -cortex-m = { version = "0.7.6", features = ["inline-asm"] }
# -cortex-m-rt = "0.7.0"
# -panic-probe = { version = "0.3", features = ["print-defmt"] }
# -futures = { version = "0.3.17", default-features = false, features = ["async-await", "cfg-target-has-atomic", "unstable"] }
# -display-interface-spi = "0.4.1"
# -embedded-graphics = "0.7.1"
# -st7789 = "0.6.1"
# -display-interface = "0.4.1"
# -byte-slice-cast = { version = "1.2.0", default-features = false }
# -smart-leds = "0.3.0"
# -heapless = "0.8"
# usbd-hid = "0.6.1"
# -
# -embedded-hal-1 = { package = "embedded-hal", version = "1.0" }
# -embedded-hal-async = "1.0"
# -embedded-hal-bus = { version = "0.1", features = ["async"] }
# -embedded-io-async = { version = "0.6.1", features = ["defmt-03"] }
# -embedded-storage = { version = "0.3" }
# -static_cell = "2"
# portable-atomic = { version = "1.5", features = ["critical-section"] } # portable-atomic = { version = "1.5", features = ["critical-section"] }
# -log = "0.4" # defmt-rtt = "0.4.0"
# -pio-proc = "0.2" # panic-probe = "0.3.1"
# -pio = "0.2.1"
# -rand = { version = "0.8.5", default-features = false }
# -embassy-usb-driver = "0.1.0"
# -enum_dispatch = "0.3.12"
# [profile.release] # [profile.release]
# debug = 2 # debug = 2
# diff --git a/rust-toolchain.toml b/rust-toolchain.toml
# index 048e049..157fcfb 100644
# --- a/rust-toolchain.toml
# +++ b/rust-toolchain.toml
# @@ -1,5 +1,7 @@
# [toolchain]
# -channel = "nightly-2022-10-25"
# +# channel = "nightly-2022-10-25"
# +# channel = "nightly-2023-10-25"
# +channel = "1.77"
# components = [ "rust-src", "rustfmt" ]
# targets = [
# "thumbv7em-none-eabi",
# diff --git a/src/main.rs b/src/main.rs
# index de33a0c..a9989e8 100644
# --- a/src/main.rs
# +++ b/src/main.rs
# @@ -74,7 +74,7 @@ async fn main(_spawner: Spawner) {
# &mut config_descriptor,
# &mut bos_descriptor,
# &mut msos_descriptor,
# - &mut control_buf,
# + // &mut control_buf,
# );
# builder.handler(&mut device_handler);
# # [dependencies]
# # embassy-sync = { version = "0.5.0", git = "https://github.com/embassy-rs/embassy", features = ["defmt"] }
# # embassy-executor = { version = "0.5.0", git = "https://github.com/embassy-rs/embassy", features = ["task-arena-size-32768", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] }
# # embassy-time = { version = "0.3.0", git = "https://github.com/embassy-rs/embassy", features = ["defmt", "defmt-timestamp-uptime"] }
# # embassy-rp = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy", features = ["defmt", "unstable-pac", "time-driver", "critical-section-impl"] }
# # embassy-usb = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy", features = ["defmt"] }
# # -embassy-net = { version = "0.4.0", git = "https://github.com/embassy-rs/embassy", features = ["defmt", "tcp", "udp", "dhcpv4", "medium-ethernet"] }
# # -embassy-net-wiznet = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy", features = ["defmt"] }
# # embassy-futures = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy" }
# # -embassy-usb-logger = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy" }
# # -cyw43 = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy", features = ["defmt", "firmware-logs"] }
# # -cyw43-pio = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy", features = ["defmt", "overclock"] }
# # defmt = "0.3"
# # -defmt-rtt = "0.4"
# # -fixed = "1.23.1"
# # -fixed-macro = "1.2"
# # -
# # -#cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
# # -cortex-m = { version = "0.7.6", features = ["inline-asm"] }
# # -cortex-m-rt = "0.7.0"
# # -panic-probe = { version = "0.3", features = ["print-defmt"] }
# # -futures = { version = "0.3.17", default-features = false, features = ["async-await", "cfg-target-has-atomic", "unstable"] }
# # -display-interface-spi = "0.4.1"
# # -embedded-graphics = "0.7.1"
# # -st7789 = "0.6.1"
# # -display-interface = "0.4.1"
# # -byte-slice-cast = { version = "1.2.0", default-features = false }
# # -smart-leds = "0.3.0"
# # -heapless = "0.8"
# # usbd-hid = "0.6.1"
# # -
# # -embedded-hal-1 = { package = "embedded-hal", version = "1.0" }
# # -embedded-hal-async = "1.0"
# # -embedded-hal-bus = { version = "0.1", features = ["async"] }
# # -embedded-io-async = { version = "0.6.1", features = ["defmt-03"] }
# # -embedded-storage = { version = "0.3" }
# # -static_cell = "2"
# # portable-atomic = { version = "1.5", features = ["critical-section"] }
# # -log = "0.4"
# # -pio-proc = "0.2"
# # -pio = "0.2.1"
# # -rand = { version = "0.8.5", default-features = false }
# # -embassy-usb-driver = "0.1.0"
# # -enum_dispatch = "0.3.12"
# # [profile.release]
# # debug = 2
# # diff --git a/rust-toolchain.toml b/rust-toolchain.toml
# # index 048e049..157fcfb 100644
# # --- a/rust-toolchain.toml
# # +++ b/rust-toolchain.toml
# # @@ -1,5 +1,7 @@
# # [toolchain]
# # -channel = "nightly-2022-10-25"
# # +# channel = "nightly-2022-10-25"
# # +# channel = "nightly-2023-10-25"
# # +channel = "1.77"
# # components = [ "rust-src", "rustfmt" ]
# # targets = [
# # "thumbv7em-none-eabi",
# # diff --git a/src/main.rs b/src/main.rs
# # index de33a0c..a9989e8 100644
# # --- a/src/main.rs
# # +++ b/src/main.rs
# # @@ -74,7 +74,7 @@ async fn main(_spawner: Spawner) {
# # &mut config_descriptor,
# # &mut bos_descriptor,
# # &mut msos_descriptor,
# # - &mut control_buf,
# # + // &mut control_buf,
# # );
# # builder.handler(&mut device_handler);

View File

@ -1,3 +1,12 @@
# macropad-rs # macropad-rs
Macropad prototype using embassy-rs Macropad prototype using embassy-rs
# TODO
[ ] Have layouts as features
[ ] Finish all layouts
[ ] Have seed/rng has a feature
[ ] Implement seed/rng
[ ] Add delays in macros
[ ] Better macro implementation
[ ] Have a way to write macros without recompiling

View File

@ -1,7 +1,5 @@
[toolchain] [toolchain]
# channel = "nightly-2022-10-25" channel = "nightly"
# channel = "nightly-2023-10-25"
channel = "1.77"
components = [ "rust-src", "rustfmt" ] components = [ "rust-src", "rustfmt" ]
targets = [ targets = [
"thumbv7em-none-eabi", "thumbv7em-none-eabi",

View File

@ -46,6 +46,14 @@ pub(crate) async fn keydispatch_press(pressed_key: &KeypadKey, sender: &ChannelT
(false, false, true, &KeypadKey::B3) => mk!(M_BIGDOWN), (false, false, true, &KeypadKey::B3) => mk!(M_BIGDOWN),
(false, false, true, &KeypadKey::B2) => mk!(M_BIGLEFT), (false, false, true, &KeypadKey::B2) => mk!(M_BIGLEFT),
(false, false, true, &KeypadKey::B4) => mk!(M_BIGRIGHT), (false, false, true, &KeypadKey::B4) => mk!(M_BIGRIGHT),
(false, false, false, &KeypadKey::A2) => mk!(M_PREV_PAR),
(false, false, false, &KeypadKey::A4) => mk!(M_NEXT_PAR),
(false, false, true, &KeypadKey::A2) => mk!(M_PREV_FN),
(false, false, true, &KeypadKey::A4) => mk!(M_NEXT_FN),
(false, false, false, &KeypadKey::C2) => mk!(M_PREV_DEF),
(false, false, false, &KeypadKey::C4) => mk!(M_NEXT_DEF),
(false, false, true, &KeypadKey::C2) => mk!(M_PREV_DIAG),
(false, false, true, &KeypadKey::C4) => mk!(M_NEXT_DIAG),
(_, _, _, _) => (), (_, _, _, _) => (),
} }
// Return // Return

View File

@ -34,6 +34,16 @@ pub const M_UP: KBMacro = KBM!(k);
pub const M_DOWN: KBMacro = KBM!(j); pub const M_DOWN: KBMacro = KBM!(j);
pub const M_LEFT: KBMacro = KBM!(h); pub const M_LEFT: KBMacro = KBM!(h);
pub const M_RIGHT: KBMacro = KBM!(l); pub const M_RIGHT: KBMacro = KBM!(l);
pub const M_PREV_FN: KBMacro = KBM!(lbrak, f);
pub const M_NEXT_FN: KBMacro = KBM!(rbrak, f);
pub const M_PREV_DEF: KBMacro = KBM!(lbrak, d);
pub const M_NEXT_DEF: KBMacro = KBM!(rbrak, d);
pub const M_PREV_PAR: KBMacro = KBM!(lbrak, p);
pub const M_NEXT_PAR: KBMacro = KBM!(rbrak, p);
pub const M_PREV_DIAG: KBMacro = KBM!(lbrak, D);
pub const M_NEXT_DIAG: KBMacro = KBM!(rbrak, D);
// pub const M_NO: KBMacro = KBM!(no); // pub const M_NO: KBMacro = KBM!(no);
// pub const M_BTE: KBMacro = KBM!(b, i, t, e); // pub const M_BTE: KBMacro = KBM!(b, i, t, e);
// pub const M_BLLY: KBMacro = KBM!(b, i, l, no, l, y); // pub const M_BLLY: KBMacro = KBM!(b, i, l, no, l, y);

View File

@ -13,6 +13,7 @@
//! keysend_manager.send_keypress('A'); // Simulate sending a keypress event for the letter 'A' //! keysend_manager.send_keypress('A'); // Simulate sending a keypress event for the letter 'A'
//! ``` //! ```
use embassy_time::Timer;
use usbd_hid::descriptor::KeyboardReport; use usbd_hid::descriptor::KeyboardReport;
use crate::{kb_macro::KBMacro, keyboard::KeyCode, ChannelType}; use crate::{kb_macro::KBMacro, keyboard::KeyCode, ChannelType};
@ -34,3 +35,10 @@ pub(crate) async fn send_macro(kb_mkro: KBMacro<'_>, sender: &ChannelType) {
sender.send(*kbr).await; sender.send(*kbr).await;
} }
} }
pub(crate) async fn send_timing_macro(kb_mkro: KBMacro<'_>, sender: &ChannelType) {
for kbr in kb_mkro.keys.iter() {
Timer::after_millis(50).await;
sender.send(*kbr).await;
}
}

View File

@ -151,6 +151,8 @@ pub(crate) const fn translate(symbol: &Layout) -> KeyboardReport {
Layout::pow => todo!(), Layout::pow => todo!(),
Layout::star => todo!(), Layout::star => todo!(),
Layout::no => KR!(0,0,0,0,0,0;0), Layout::no => KR!(0,0,0,0,0,0;0),
Layout::lbrak => KR!(KeyCode::Kb5,0,0,0,0,0;64),
Layout::rbrak => KR!(KeyCode::Minus,0,0,0,0,0;64),
} }
} }
@ -235,4 +237,6 @@ pub(crate) enum Layout {
pow, pow,
star, star,
no, no,
lbrak,
rbrak,
} }