Skip to content

Commit

Permalink
refactor: change variable names making it more clear
Browse files Browse the repository at this point in the history
Signed-off-by: Haobo Gu <[email protected]>
  • Loading branch information
HaoboGu committed Nov 1, 2023
1 parent 4721dad commit 1c295b7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
12 changes: 8 additions & 4 deletions boards/rp2040/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,19 @@ mod app {
info!("Start matrix scanning");
loop {
cx.local.keyboard.keyboard_task().await.unwrap();
cx.shared.usb_device.lock(|d| {
cx.local.keyboard.send_report(d);
cx.shared.usb_device.lock(|usb_device| {
// Send keyboard report
cx.local.keyboard.send_report(usb_device);

// Process via report
cx.local.keyboard.process_via_report(usb_device);
});

// Blink LED
let _ = cx.local.led.toggle();

// Scanning frequency: 1KHZ
Systick::delay(1.millis()).await;
// Scanning frequency: 10KHZ
Systick::delay(100.micros()).await;
}
}

Expand Down
14 changes: 7 additions & 7 deletions boards/stm32h7/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,14 @@ mod app {
info!("Start matrix scanning");
loop {
cx.local.keyboard.keyboard_task().await.unwrap();
cx.shared.usb_device.lock(|d| {
cx.local.keyboard.send_report(d);
// Read via report
// TODO: move it to another thread?
cx.local.keyboard.read_report(d);
cx.shared.usb_device.lock(|usb_device| {
// Send keyboard report
cx.local.keyboard.send_report(usb_device);
// Process via report
cx.local.keyboard.process_via_report(usb_device);
});
// Scanning frequency: 1KHZ
Systick::delay(1.millis()).await;
// Scanning frequency: 10KHZ
Systick::delay(100.micros()).await;
}
}

Expand Down
2 changes: 1 addition & 1 deletion rmk/src/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl<
}

/// Read hid report.
pub fn read_report<B: UsbBus>(&mut self, usb_device: &mut KeyboardUsbDevice<'_, B>) {
pub fn process_via_report<B: UsbBus>(&mut self, usb_device: &mut KeyboardUsbDevice<'_, B>) {
if usb_device.read_via_report(&mut self.via_report) > 0 {
process_via_packet(&mut self.via_report, &mut self.keymap, &mut self.eeprom);

Expand Down

0 comments on commit 1c295b7

Please sign in to comment.