Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feat/input_device
Browse files Browse the repository at this point in the history
Signed-off-by: Haobo Gu <[email protected]>
  • Loading branch information
HaoboGu committed Jan 3, 2025
2 parents f667479 + aacdf02 commit d3768a3
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion rmk/src/ble/esp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use futures::pin_mut;
/// * `output_pins` - output gpio pins
/// * `keyboard_config` - other configurations of the keyboard, check [RmkConfig] struct for details
/// * `spawner` - embassy task spawner, used to spawn nrf_softdevice background task
pub(crate) async fn initialize_esp_ble_keyboard_with_config_and_run<
pub async fn initialize_esp_ble_keyboard_with_config_and_run<
M: MatrixTrait,
Out: OutputPin,
const ROW: usize,
Expand Down
2 changes: 1 addition & 1 deletion rmk/src/ble/nrf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ pub(crate) fn nrf_ble_config(keyboard_name: &str) -> Config {
/// * `keyboard_config` - other configurations of the keyboard, check [RmkConfig] struct for details
/// * `spawner` - embassy task spawner, used to spawn nrf_softdevice background task
/// * `saadc` - nRF's [saadc](https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52832.ps.v1.1%2Fsaadc.html) instance for battery level detection, if you don't need it, pass `None`
pub(crate) async fn initialize_nrf_ble_keyboard_and_run<
pub async fn initialize_nrf_ble_keyboard_and_run<
M: MatrixTrait,
Out: OutputPin,
#[cfg(not(feature = "_no_usb"))] D: Driver<'static>,
Expand Down
2 changes: 1 addition & 1 deletion rmk/src/debounce/default_bouncer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl DebounceCounter {
}

/// Default per-key debouncer. The debouncing algorithm is same as ZMK's [default debouncer](https://github.com/zmkfirmware/zmk/blob/19613128b901723f7b78c136792d72e6ca7cf4fc/app/module/lib/zmk_debounce/debounce.c)
pub(crate) struct DefaultDebouncer<const INPUT_PIN_NUM: usize, const OUTPUT_PIN_NUM: usize> {
pub struct DefaultDebouncer<const INPUT_PIN_NUM: usize, const OUTPUT_PIN_NUM: usize> {
last_ms: u32,
counters: [[DebounceCounter; INPUT_PIN_NUM]; OUTPUT_PIN_NUM],
}
Expand Down
2 changes: 1 addition & 1 deletion rmk/src/debounce/fast_debouncer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use super::{DebounceState, DebouncerTrait, DEBOUNCE_THRESHOLD};

/// Fast per-key debouncer.
/// The debouncing algorithm is similar as QMK's [asym eager defer pk debouncer](https://github.com/qmk/qmk_firmware/blob/2fd56317763e8b3b73f0db7488ef42a70f5b946e/quantum/debounce/asym_eager_defer_pk.c)
pub(crate) struct RapidDebouncer<const INPUT_PIN_NUM: usize, const OUTPUT_PIN_NUM: usize> {
pub struct RapidDebouncer<const INPUT_PIN_NUM: usize, const OUTPUT_PIN_NUM: usize> {
last_ms: Instant,
debouncing: [[bool; INPUT_PIN_NUM]; OUTPUT_PIN_NUM],
}
Expand Down
4 changes: 2 additions & 2 deletions rmk/src/debounce/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub mod fast_debouncer;
/// Default DEBOUNCE_THRESHOLD in ms.
static DEBOUNCE_THRESHOLD: u16 = 10;

pub(crate) trait DebouncerTrait {
pub trait DebouncerTrait {
fn new() -> Self;

/// The `in_idx` `out_idx` can be used as two normal dimensions.
Expand All @@ -20,7 +20,7 @@ pub(crate) trait DebouncerTrait {
}

/// Debounce state
pub(crate) enum DebounceState {
pub enum DebounceState {
Debounced,
InProgress,
Ignored,
Expand Down
6 changes: 3 additions & 3 deletions rmk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub mod action;
#[cfg(feature = "_ble")]
pub mod ble;
pub mod config;
mod debounce;
pub mod debounce;
pub mod direct_pin;
pub mod event;
mod flash;
Expand All @@ -71,7 +71,7 @@ pub mod keycode;
mod keymap;
mod layout_macro;
mod light;
mod matrix;
pub mod matrix;
#[cfg(feature = "split")]
pub mod split;
mod storage;
Expand Down Expand Up @@ -225,7 +225,7 @@ pub async fn run_rmk_with_async_flash<
defmt::panic!("The run_rmk should never return");
}

pub(crate) async fn initialize_usb_keyboard_and_run<
pub async fn initialize_usb_keyboard_and_run<
Out: OutputPin,
D: Driver<'static>,
M: MatrixTrait,
Expand Down
20 changes: 10 additions & 10 deletions rmk/src/matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use {embassy_futures::select::select_slice, embedded_hal_async::digital::Wait, h
///
/// The keyboard matrix is a 2D matrix of keys, the matrix does the scanning and saves the result to each key's `KeyState`.
/// The `KeyState` at position (row, col) can be read by `get_key_state` and updated by `update_key_state`.
pub(crate) trait MatrixTrait {
pub trait MatrixTrait {
// Matrix size
const ROW: usize;
const COL: usize;
Expand Down Expand Up @@ -61,11 +61,11 @@ pub(crate) trait MatrixTrait {

/// KeyState represents the state of a key.
#[derive(Copy, Clone, Debug, Format)]
pub(crate) struct KeyState {
pub struct KeyState {
// True if the key is pressed
pub(crate) pressed: bool,
pub pressed: bool,
// True if the key's state is just changed
// pub(crate) changed: bool,
// pub changed: bool,
}

impl Default for KeyState {
Expand All @@ -75,25 +75,25 @@ impl Default for KeyState {
}

impl KeyState {
pub(crate) fn new() -> Self {
pub fn new() -> Self {
KeyState { pressed: false }
}

pub(crate) fn toggle_pressed(&mut self) {
pub fn toggle_pressed(&mut self) {
self.pressed = !self.pressed;
}

pub(crate) fn is_releasing(&self) -> bool {
pub fn is_releasing(&self) -> bool {
!self.pressed
}

pub(crate) fn is_pressing(&self) -> bool {
pub fn is_pressing(&self) -> bool {
self.pressed
}
}

/// Matrix is the physical pcb layout of the keyboard matrix.
pub(crate) struct Matrix<
pub struct Matrix<
#[cfg(feature = "async_matrix")] In: Wait + InputPin,
#[cfg(not(feature = "async_matrix"))] In: InputPin,
Out: OutputPin,
Expand Down Expand Up @@ -123,7 +123,7 @@ impl<
> Matrix<In, Out, D, INPUT_PIN_NUM, OUTPUT_PIN_NUM>
{
/// Create a matrix from input and output pins.
pub(crate) fn new(
pub fn new(
input_pins: [In; INPUT_PIN_NUM],
output_pins: [Out; OUTPUT_PIN_NUM],
debouncer: D,
Expand Down
2 changes: 1 addition & 1 deletion rmk/src/split/central.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ pub async fn run_peripheral_monitor<
}

/// Split central is connected to host via usb
pub(crate) async fn initialize_usb_split_central_and_run<
pub async fn initialize_usb_split_central_and_run<
M: MatrixTrait,
Out: OutputPin,
D: Driver<'static>,
Expand Down
4 changes: 2 additions & 2 deletions rmk/src/split/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ pub mod central;
/// Common abstraction layer of split driver
pub(crate) mod driver;
#[cfg(feature = "_nrf_ble")]
pub(crate) mod nrf;
pub mod nrf;
pub mod peripheral;
#[cfg(not(feature = "_nrf_ble"))]
pub(crate) mod serial;
pub mod serial;

/// Maximum size of a split message
pub const SPLIT_MESSAGE_MAX_SIZE: usize = SplitMessage::POSTCARD_MAX_SIZE + 4;
Expand Down
2 changes: 1 addition & 1 deletion rmk/src/split/nrf/peripheral.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl<'a> SplitWriter for BleSplitPeripheralDriver<'a> {
/// * `input_pins` - input gpio pins
/// * `output_pins` - output gpio pins
/// * `spawner` - embassy task spawner, used to spawn nrf_softdevice background task
pub(crate) async fn initialize_nrf_ble_split_peripheral_and_run<
pub async fn initialize_nrf_ble_split_peripheral_and_run<
M: MatrixTrait,
const ROW: usize,
const COL: usize,
Expand Down
2 changes: 1 addition & 1 deletion rmk/src/split/serial/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl<S: Read + Write> SplitWriter for SerialSplitDriver<S> {
/// * `input_pins` - input gpio pins
/// * `output_pins` - output gpio pins
/// * `serial` - serial port to send key events to central board
pub(crate) async fn initialize_serial_split_peripheral_and_run<
pub async fn initialize_serial_split_peripheral_and_run<
M: MatrixTrait,
S: Write + Read,
const ROW: usize,
Expand Down

0 comments on commit d3768a3

Please sign in to comment.