Skip to content

Commit

Permalink
Merge branch 'main' into feat/split_optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
HaoboGu authored Dec 18, 2024
2 parents 536617a + 4d24faf commit 9a75b75
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 38 deletions.
18 changes: 8 additions & 10 deletions rmk/src/direct_pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::ble::nrf::initialize_nrf_ble_keyboard_and_run;
))]
use crate::initialize_usb_keyboard_and_run;

use defmt::{error, info};
use defmt::info;
#[cfg(not(feature = "_esp_ble"))]
use embassy_executor::Spawner;
use embassy_time::Instant;
Expand Down Expand Up @@ -330,15 +330,13 @@ impl<
self.key_states[row_idx][col_idx].toggle_pressed();
let key_state = self.key_states[row_idx][col_idx];

// `try_send` is used here because we don't want to block scanning if the channel is full
let send_re = key_event_channel.try_send(KeyEvent {
row: row_idx as u8,
col: col_idx as u8,
pressed: key_state.pressed,
});
if send_re.is_err() {
error!("Failed to send key event: key event channel full");
}
key_event_channel
.send(KeyEvent {
row: row_idx as u8,
col: col_idx as u8,
pressed: key_state.pressed,
})
.await;
}
_ => (),
}
Expand Down
16 changes: 7 additions & 9 deletions rmk/src/matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,13 @@ impl<
let (row, col, key_state) =
(out_idx, in_idx, self.key_states[out_idx][in_idx]);

// `try_send` is used here because we don't want to block scanning if the channel is full
let send_re = key_event_channel.try_send(KeyEvent {
row: row as u8,
col: col as u8,
pressed: key_state.pressed,
});
if send_re.is_err() {
error!("Failed to send key event: key event channel full");
}
key_event_channel
.send(KeyEvent {
row: row as u8,
col: col as u8,
pressed: key_state.pressed,
})
.await;
}
_ => (),
}
Expand Down
34 changes: 15 additions & 19 deletions rmk/src/split/central.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,15 +378,13 @@ impl<
self.key_states[out_idx][in_idx],
);

// `try_send` is used here because we don't want to block scanning if the channel is full
let send_re = key_event_channel.try_send(KeyEvent {
row,
col,
pressed: key_state.pressed,
});
if send_re.is_err() {
error!("Failed to send key event: key event channel full");
}
key_event_channel
.send(KeyEvent {
row,
col,
pressed: key_state.pressed,
})
.await;
}
_ => (),
}
Expand Down Expand Up @@ -541,8 +539,8 @@ impl<

#[cfg(feature = "async_matrix")]
async fn wait_for_key(&mut self) {
use heapless::Vec;
use embassy_futures::select::select_slice;
use heapless::Vec;
if let Some(start_time) = self.scan_start {
// If no key press over 1ms, stop scanning and wait for interupt
if start_time.elapsed().as_millis() <= 1 {
Expand Down Expand Up @@ -611,15 +609,13 @@ impl<
self.key_states[row_idx][col_idx],
);

// `try_send` is used here because we don't want to block scanning if the channel is full
let send_re = key_event_channel.try_send(KeyEvent {
row,
col,
pressed: key_state.pressed,
});
if send_re.is_err() {
error!("Failed to send key event: key event channel full");
}
key_event_channel
.send(KeyEvent {
row,
col,
pressed: key_state.pressed,
})
.await;
}
_ => (),
}
Expand Down

0 comments on commit 9a75b75

Please sign in to comment.