Skip to content

Commit

Permalink
chore: update input device example
Browse files Browse the repository at this point in the history
Signed-off-by: Haobo Gu <[email protected]>
  • Loading branch information
HaoboGu committed Dec 25, 2024
1 parent dc6eb25 commit 32236ee
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
2 changes: 2 additions & 0 deletions examples/use_rust/nrf52840_ble/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ embassy-executor = { version = "0.6", features = [
"executor-thread",
"integrated-timers",
] }
embassy-futures = { version = "0.1", features = ["defmt"] }

defmt = "0.3"
defmt-rtt = "0.4"
panic-probe = { version = "0.3", features = ["print-defmt"] }
Expand Down
34 changes: 16 additions & 18 deletions examples/use_rust/nrf52840_ble/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@ use panic_probe as _;
use rmk::{
ble::SOFTWARE_VBUS,
config::{BleBatteryConfig, KeyboardUsbConfig, RmkConfig, StorageConfig, VialConfig},
impl_input_device,
input_device::{
rotary_encoder::{rotary_encoder_task, RotaryEncoder},
InputDevice,
},
run_rmk,
input_device::{rotary_encoder::RotaryEncoder, InputDevice},
run_devices, run_rmk,
};

use vial::{VIAL_KEYBOARD_DEF, VIAL_KEYBOARD_ID};
Expand Down Expand Up @@ -111,18 +107,21 @@ async fn main(spawner: Spawner) {
..Default::default()
};

let encoder = RotaryEncoder {};
spawner.spawn(rotary_encoder_task(encoder)).unwrap();
let my_device = MyDevice {};
spawner.spawn(my_device_task(my_device)).unwrap();
let mut my_device = MyDevice {};
let pin_a = Input::new(AnyPin::from(p.P0_06), embassy_nrf::gpio::Pull::Up);
let pin_b = Input::new(AnyPin::from(p.P0_11), embassy_nrf::gpio::Pull::Up);
let mut encoder = RotaryEncoder::new(pin_a, pin_b);

run_rmk(
input_pins,
output_pins,
driver,
&mut keymap::get_default_keymap(),
keyboard_config,
spawner,
embassy_futures::join::join(
run_rmk(
input_pins,
output_pins,
driver,
&mut keymap::get_default_keymap(),
keyboard_config,
spawner,
),
run_devices!(my_device, encoder),
)
.await;
}
Expand All @@ -136,4 +135,3 @@ impl InputDevice for MyDevice {
}
}
}
impl_input_device!(MyDevice, my_device_task);

0 comments on commit 32236ee

Please sign in to comment.