### Run ESP32-S3 BLE Example Source: https://github.com/haobogu/rmk/blob/main/examples/use_config/esp32s3_ble/README.md Navigate to the example directory and run the example using cargo. ```bash cd examples/use_config/esp32s3_ble cargo +esp run --release ``` -------------------------------- ### Run ESP32-C3 BLE Example Source: https://github.com/haobogu/rmk/blob/main/examples/use_config/esp32c3_ble/README.md Navigate to the example directory and run the example using cargo run. Ensure you have the Rust toolchain and espflash installed. ```bash cd examples/use_config/esp32c3_ble cargo run --release ``` -------------------------------- ### Navigate to Example Directory Source: https://github.com/haobogu/rmk/blob/main/examples/use_config/nrf52832_ble/README.md Change to the example's directory before proceeding. ```shell cd examples/use_config/nrf52832_ble ``` -------------------------------- ### Navigate to Example Directory Source: https://github.com/haobogu/rmk/blob/main/examples/use_rust/nrf52832_ble/README.md Change to the example's directory before proceeding. ```shell cd examples/use_rust/nrf52832_ble ``` -------------------------------- ### Run ESP32-C6 BLE Example Source: https://github.com/haobogu/rmk/blob/main/examples/use_config/esp32c6_ble/README.md Navigate to the example directory and run the BLE example using cargo. This command builds and flashes the code to the ESP32-C6. ```bash cd examples/use_config/esp32c6_ble cargo run --release ``` -------------------------------- ### Navigate to Example Directory Source: https://github.com/haobogu/rmk/blob/main/examples/use_rust/nrf54lm20_ble/README.md Change the current directory to the nRF54LM20A BLE example. ```shell cd examples/use_rust/nrf54lm20_ble ``` -------------------------------- ### Run ESP32-S3 BLE Example Source: https://github.com/haobogu/rmk/blob/main/examples/use_rust/esp32s3_ble/README.md Navigate to the example directory and run the BLE example using cargo. Ensure you are using the esp toolchain. ```bash cd examples/use_rust/esp32s3_ble cargo +esp run --release ``` -------------------------------- ### Run ESP32-C3 BLE Example Source: https://github.com/haobogu/rmk/blob/main/examples/use_rust/esp32c3_ble/README.md Navigate to the example directory and run the BLE example using cargo run. Ensure you have the release profile enabled for optimization. ```bash cd examples/use_rust/esp32c3_ble cargo run --release ``` -------------------------------- ### Rust Storage Configuration Example Source: https://github.com/haobogu/rmk/blob/main/docs/docs/main/docs/configuration/storage.mdx Example of configuring storage settings in Rust using `StorageConfig` and `RmkConfig`. Allows setting a custom start address and the number of sectors. ```rust let storage_config = StorageConfig { start_addr: 0x70000, // Custom start address num_sectors: 2, // Number of sectors ..Default::default() }; let rmk_config = RmkConfig { storage_config, ..Default::default() }; ``` -------------------------------- ### Navigate to Example Directory Source: https://github.com/haobogu/rmk/blob/main/examples/use_rust/nrf54l15_ble/README.md Change the current directory to the nRF54L15 BLE example folder. ```shell cd examples/use_rust/nrf54l15_ble ``` -------------------------------- ### Run ESP32-C6 BLE Example Source: https://github.com/haobogu/rmk/blob/main/examples/use_rust/esp32c6_ble/README.md Navigate to the example directory and run the example using cargo run. This command compiles and flashes the code to the ESP32-C6. ```bash cd examples/use_rust/esp32c6_ble cargo run --release ``` -------------------------------- ### Compile, Flash, and Run RMK Example Source: https://github.com/haobogu/rmk/blob/main/examples/use_config/nrf52840_ble/README.md Navigate to the example directory and then compile, flash, and run the RMK example on your nRF52840 board using cargo run. ```shell cd examples/use_config/nrf52840_ble ``` ```shell cargo run --release ``` -------------------------------- ### Compile, Flash, and Run Example Source: https://github.com/haobogu/rmk/blob/main/examples/use_config/nrf52832_ble/README.md Use `cargo run` to compile the firmware, flash it to the board, and execute the example. Ensure a debug probe is connected. ```shell cargo run --release ``` -------------------------------- ### Build Example for nRF52840 BLE Source: https://github.com/haobogu/rmk/blob/main/CLAUDE.md Builds a specific example for the nRF52840 microcontroller with BLE support in release mode. Navigate to the example directory before running. ```bash cd examples/use_config/nrf52840_ble cargo build --release ``` -------------------------------- ### Compile, Flash, and Run Example Firmware Source: https://github.com/haobogu/rmk/blob/main/examples/use_rust/nrf52840_ble_split_dongle/README.md After setting up `memory.x`, use these commands to compile, flash, and run the central or peripheral firmware for the nRF52840 BLE split example. ```shell # Run central firmware car go run --release --bin central # Run peripheral firmware car go run --release --bin peripheral ``` -------------------------------- ### RMK Project Initialization Example Source: https://github.com/haobogu/rmk/blob/main/docs/docs/main/docs/user_guide/create_firmware/local_compilation.mdx An example of the interactive prompts and output when creating a new RMK keyboard project using 'rmkit init'. Demonstrates selecting project details like name, type, and microcontroller. ```shell $ rmkit init > Project Name: rmk-keyboard > Choose your keyboard type? split > Choose your microcontroller nrf52840 ⇣ Download project template for nrf52840_split... ✅ Project created, path: rmk-keyboard ``` -------------------------------- ### Install Build and Flashing Tools Source: https://github.com/haobogu/rmk/blob/main/docs/docs/main/docs/user_guide/create_firmware/local_compilation.mdx Installs essential tools like 'flip-link' for stack overflow protection and 'cargo-make' for UF2 generation. Includes instructions for 'probe-rs' for flashing and debugging. ```bash # Install flip-link cargo install flip-link cargo-make # Install probe-rs using scripts # Linux, macOS curl --proto '=https' --tlsv1.2 -LsSf https://github.com/probe-rs/probe-rs/releases/latest/download/probe-rs-tools-installer.sh | sh # Windows irm https://github.com/probe-rs/probe-rs/releases/latest/download/probe-rs-tools-installer.ps1 | iex ``` -------------------------------- ### Install espflash Source: https://github.com/haobogu/rmk/blob/main/examples/use_config/esp32s3_ble/README.md Install the espflash toolchain using cargo. ```bash cargo install cargo-espflash espflash ``` -------------------------------- ### Install RMK Tool and Dependencies Source: https://github.com/haobogu/rmk/blob/main/README.md Installs the rmkit CLI tool and flip-link for flashing. Includes an alternative installation command for Windows users experiencing issues. ```shell cargo install rmkit flip-link # If you encounter installation issues on Windows, try this alternative command: # powershell -ExecutionPolicy ByPass -c "irm https://github.com/haobogu/rmkit/releases/download/v0.0.20/rmkit-installer.ps1 | iex" rmkit init ``` -------------------------------- ### Flash and Run Central Example Source: https://github.com/haobogu/rmk/blob/main/examples/use_rust/nrf52840_ble_split/README.md Navigate to the example directory and use `cargo run` to compile, flash, and run the central firmware on the nrf52840 board. ```shell # Run central firmware cargo run --release --bin central ``` -------------------------------- ### Flash and Run Peripheral Example Source: https://github.com/haobogu/rmk/blob/main/examples/use_rust/nrf52840_ble_split/README.md Navigate to the example directory and use `cargo run` to compile, flash, and run the peripheral firmware on the nrf52840 board. ```shell # Run peripheral firmware cargo run --release --bin peripheral ``` -------------------------------- ### Flash and Run Example with Debugging Probe Source: https://github.com/haobogu/rmk/blob/main/examples/use_config/nrf52840_ble_split/README.md After setting up the `memory.x` file, use `cargo run --release` to flash and run the RMK firmware. Navigate to the example directory and then execute the appropriate command for central or peripheral firmware. ```shell # Enter example folder cd examples/use_config/nrf52840_ble_split # Run central firmware car go run --release --bin central # Run peripheral firmware car go run --release --bin peripheral ``` -------------------------------- ### Install cargo-make Source: https://github.com/haobogu/rmk/blob/main/examples/use_config/nrf52840_ble/README.md Install the cargo-make tool, which is used to generate .uf2 firmware for RMK. ```shell cargo install --force cargo-make ``` -------------------------------- ### RMK Configuration Example Source: https://github.com/haobogu/rmk/blob/main/docs/docs/main/docs/configuration/rmk_config.md Example TOML configuration for RMK, illustrating various parameters and their settings. ```toml [rmk] # Mouse key interval (ms) - controls mouse movement speed mouse_key_interval = 20 # Mouse wheel interval (ms) - controls scrolling speed mouse_wheel_interval = 80 # Maximum number of combos keyboard can store combo_max_num = 8 # Maximum number of keys pressed simultaneously in a combo combo_max_length = 4 # Maximum number of forks for conditional key actions fork_max_num = 8 # Maximum number of morse keys keyboard can store (max 256) morse_max_num = 8 # Maximum number of patterns a morse key can handle (default: 8, min: 4, max 65536) max_patterns_per_key = 8 # Macro space size in bytes for storing sequences. The maximum number of Macros depends on the size of each sequence: All sequences combined need to fit into macro_space_size, the number of macro sequences doesn't matter. macro_space_size = 256 # Default debounce time in ms debounce_time = 20 # Report channel size report_channel_size = 16 # Vial channel size vial_channel_size = 4 # Flash channel size flash_channel_size = 4 # The number of the split peripherals split_peripherals_num = 0 # The number of available BLE profiles ble_profiles_num = 3 # BLE Split Central sleep timeout in seconds (0 = disabled) split_central_sleep_timeout_seconds = 0 ``` -------------------------------- ### Compile, Flash, and Run Example Firmware Source: https://github.com/haobogu/rmk/blob/main/examples/use_config/nrf52840_ble_split_direct_pin/README.md Navigate to the example directory and use `cargo run` to compile, flash, and execute the central or peripheral firmware on your nRF52840 board. This assumes your `memory.x` is correctly configured. ```shell cd examples/use_config/nrf52840_ble_split_direct_pin ``` ```shell # Run central firmware cargo run --release --bin central ``` ```shell # Run peripheral firmware cargo run --release --bin peripheral ``` -------------------------------- ### Compile, Flash, and Run Example Firmware Source: https://github.com/haobogu/rmk/blob/main/examples/use_config/nrf52840_ble_split_dongle/README.md Navigate to the example directory and use `cargo run` to compile, flash, and run the central, peripheral, or peripheral2 firmware on the nrf52840 board. ```shell cd examples/use_rust/nrf52840_ble_split ``` ```shell # Run central firmware cargo run --release --bin central ``` ```shell # Run peripheral firmware cargo run --release --bin peripheral ``` ```shell # Run peripheral2 firmware cargo run --release --bin peripheral2 ``` -------------------------------- ### Install espsegs Source: https://github.com/haobogu/rmk/blob/main/examples/use_config/esp32s3_ble/README.md Install the espsegs tool for analyzing binary segments. ```bash cargo install --git https://github.com/bjoernQ/espsegs ``` -------------------------------- ### Example espflash Output Log Source: https://github.com/haobogu/rmk/blob/main/examples/use_config/esp32c6_ble/README.md This is an example log output from the espflash tool after successfully flashing the ESP32-C6 with the BLE example. It shows the compilation, flashing process, and device information. ```shell cargo run --release Compiling ... ... ... Finished `release` profile [optimized + debuginfo] target(s) in 11.70s Running `espflash flash --monitor --port /dev/cu.usbmodem211401 target/riscv32imac-unknown-none-elf/release/rmk-esp32c6` [2025-04-10T10:01:23Z INFO ] Serial port: '/dev/cu.usbmodem211401' [2025-04-10T10:01:23Z INFO ] Connecting... [2025-04-10T10:01:23Z INFO ] Using flash stub Chip type: esp32c6 (revision v0.1) Crystal frequency: 40 MHz Flash size: 4MB Features: WiFi 6, BT 5 MAC address: 40:4c:ca:5b:c7:dc App/part. size: 768,944/4,128,768 bytes, 18.62% [2025-04-10T10:01:23Z INFO ] Segment at address '0x0' has not changed, skipping write [2025-04-10T10:01:23Z INFO ] Segment at address '0x8000' has not changed, skipping write [00:00:06] [========================================] 411/411 0x10000 [2025-04-10T10:01:31Z INFO ] Flashing has completed! ``` -------------------------------- ### Compile RMK Example Source: https://github.com/haobogu/rmk/blob/main/examples/use_config/stm32f1/README.md Use this command to compile the RMK example for STM32F1 with features disabled. ```bash cargo +nightly build --release ``` -------------------------------- ### Compile, Flash, and Run RMK Example Source: https://github.com/haobogu/rmk/blob/main/examples/use_rust/nrf52840_ble/README.md Compile, flash, and run the RMK BLE example on your nRF52840 board using `cargo run`. This command assumes your `memory.x` is correctly configured. ```shell cd examples/use_rust/nrf52840_ble car go run --release ``` -------------------------------- ### Install probe-rs Source: https://github.com/haobogu/rmk/blob/main/README.md Installs the probe-rs toolchain for debugging and flashing embedded devices. ```shell curl --proto '=https' --tlsv1.2 -LsSf https://github.com/probe-rs/probe-rs/releases/latest/download/probe-rs-tools-installer.sh | sh ``` -------------------------------- ### Install elf2uf2-rs Source: https://github.com/haobogu/rmk/blob/main/README.md Installs the elf2uf2-rs tool for flashing firmware via USB. ```shell cargo install elf2uf2-rs ``` -------------------------------- ### Install rmkit Tool Source: https://github.com/haobogu/rmk/blob/main/docs/docs/main/docs/user_guide/create_firmware/local_compilation.mdx Installs the 'rmkit' command-line tool, which simplifies RMK project creation. A Windows-specific PowerShell alternative is also provided. ```shell cargo install rmkit # If you have problems installing rmkit on Windows, try the following command to install it: # powershell -ExecutionPolicy ByPass -c "irm https://github.com/haobogu/rmkit/releases/download/v0.0.13/rmkit-installer.ps1 | iex" ``` -------------------------------- ### Install cargo-binutils for Hex/Bin Firmware Source: https://github.com/haobogu/rmk/blob/main/docs/docs/main/docs/getting_started/faq.md Install `cargo-binutils` and the `llvm-tools` component to enable the generation of .bin and .hex firmware files. This is necessary for certain deployment scenarios. ```bash cargo install cargo-binutils rustup component add llvm-tools ``` -------------------------------- ### Macro Text Output Example Source: https://github.com/haobogu/rmk/blob/main/docs/docs/main/docs/configuration/behavior.md A simple macro configuration that outputs the text "Hello". ```toml # Outputs "Hello" [[behavior.macro.macros]] operations = [ { operation = "text", text = "Hello" } ] ``` -------------------------------- ### Check RMK Example Size Source: https://github.com/haobogu/rmk/blob/main/examples/use_config/stm32f1/README.md Use this command to check the binary size of the compiled RMK example. ```bash cargo +nightly size --release ``` -------------------------------- ### Install espsegs Source: https://github.com/haobogu/rmk/blob/main/examples/use_rust/esp32c6_ble/README.md Install the espsegs tool for analyzing binary segments. This is an optional tool for debugging. ```bash # Install it first cargo install --git https://github.com/bjoernQ/espsegs ``` -------------------------------- ### BLE Split Keyboard Configuration Example Source: https://github.com/haobogu/rmk/blob/main/docs/docs/main/docs/configuration/split_keyboard.md Example TOML configuration for a split keyboard using BLE connection. Defines central and peripheral components with their matrix configurations and offsets. ```toml [split] # split connection type connection = "ble" # Split central [split.central] # Central's matrix definition and offsets rows = 2 cols = 2 row_offset = 0 col_offset = 0 # Central's ble addr will be automatically generated. You can override it if you want. # ble_addr = [0x18, 0xe2, 0x21, 0x80, 0xc0, 0xc7] # Central's matrix [split.central.matrix] matrix_type = "normal" row_pins = ["P0_12", "P0_13"] col_pins = ["P0_14", "P0_15"] # Note there're TWO brackets, since the peripheral is a list # Peripheral 0 [[split.peripheral]] rows = 2 cols = 1 row_offset = 2 col_offset = 2 # Peripheral's ble addr will be automatically generated. You can override it if you want. # ble_addr = [0x7e, 0xfe, 0x73, 0x9e, 0x11, 0xe3] # Peripheral 0's matrix definition [split.peripheral.matrix] matrix_type = "normal" row_pins = ["P1_11", "P1_10"] col_pins = ["P0_30"] # Peripheral 1 [[split.peripheral]] # Matrix definition rows = 2 cols = 1 row_offset = 2 col_offset = 2 # Peripheral's ble addr will be automatically generated. You can override it if you want. # ble_addr = [0x7e, 0xfe, 0x71, 0x91, 0x11, 0xe3] # Peripheral 1's matrix definition [split.peripheral.matrix] matrix_type = "normal" row_pins = ["P1_11", "P1_10"] col_pins = ["P0_30"] ``` -------------------------------- ### Transparent Key Example Source: https://github.com/haobogu/rmk/blob/main/docs/docs/main/docs/configuration/layout.md Defines a transparent key using '_' or '__'. Multiple underscores are allowed. ```toml # Example: Transparent key _ ``` ```toml # Example: Transparent key with multiple underscores __ ``` -------------------------------- ### Combo Key Configuration Example Source: https://github.com/haobogu/rmk/blob/main/docs/docs/main/docs/configuration/behavior.md Defines combo keys with timeouts, prior idle time, and specific actions for simultaneous key presses. ```toml [behavior.combo] timeout = "150ms" prior_idle_time = "130ms" # optional, prevents accidental triggers during fast typing combos = [ # Press J and K keys simultaneously to output Escape key { actions = ["J", "K"], output = "Escape" }, # Press F and D keys simultaneously to output Tab key, but only valid on layer 0 { actions = ["F", "D"], output = "Tab", layer = 0 }, # Three-key combo, press A, S, and D keys to switch to layer 2 { actions = ["A", "S", "D"], output = "TO(2)" } ] ``` -------------------------------- ### Install cargo-make for UF2 Firmware Source: https://github.com/haobogu/rmk/blob/main/docs/docs/main/docs/getting_started/faq.md Install `cargo-make` globally to manage build tasks, including the automatic generation of UF2 firmware files. This command ensures you have the latest version. ```bash # Install cargo-make cargo install --force cargo-make ``` -------------------------------- ### Keycode with Modifiers Example Source: https://github.com/haobogu/rmk/blob/main/docs/docs/main/docs/configuration/layout.md Shows how to bind a key with active modifiers using the 'WM' function. Modifiers can be chained together. ```toml # Example: Keypress with Left Shift and Right GUI modifier WM(key, LShift | RGui) ``` -------------------------------- ### Macro Example Source: https://github.com/haobogu/rmk/blob/main/docs/docs/main/docs/configuration/behavior.md Defines a macro that types 'Hello' with a 1-second delay after the first letter. This is useful for automating sequences of key presses and delays. ```toml [[behavior.macro.macros]] operations = [ { operation = "down", keycode = "LShift" }, { operation = "tap", keycode = "H" }, { operation = "up", keycode = "LShift" }, { operation = "delay", duration = "1s" }, { operation = "tap", keycode = "E" }, { operation = "tap", keycode = "L" }, { operation = "tap", keycode = "L" }, { operation = "tap", keycode = "O" }, ] ``` -------------------------------- ### One-Shot Layer Action Example Source: https://github.com/haobogu/rmk/blob/main/docs/docs/main/docs/configuration/layout.md Activates a layer for a single keypress using 'OSL(n)', where 'n' is the layer number. ```toml # Example: Activate layer 4 for one shot OSL(4) ``` -------------------------------- ### Numpad Matrix Map Example Source: https://github.com/haobogu/rmk/blob/main/docs/docs/main/docs/configuration/layout.md Illustrates a TOML matrix map configuration for a numpad layout, showing row and column coordinates. ```toml # simple numpad example: # ┌───┬───┬───┬───┐ # │NUM│ / │ * │ - │ <-- row 0, col 0..4 # ├───┼───┼───┼───┤ # │ 7 │ 8 │ 9 │ │ # ├───┼───┼───┤ + │ # │ 4 │ 5 │ 6 │ │ # ├───┴───┼───┼───┤ # │ 1 │ 2 │ 3 │ E │ # ├───┴───┼───┤ N │ # │ 0 │ . │ T │ # └───────┴───┴───┘ [layout] rows = 5 cols = 4 layers = 3 matrix_map = """ (0,0) (0,1) (0,2) (0,3) (1,0) (1,1) (1,2) (1,3) (2,0) (2,1) (2,2) (3,0) (3,1) (3,2) (3,3) (4,0) (4,1) """ ``` -------------------------------- ### ESP32-S3 BLE Example Output Log Source: https://github.com/haobogu/rmk/blob/main/examples/use_config/esp32s3_ble/README.md Example log output when the ESP32-S3 BLE example runs successfully. ```shell cargo run --release Compiling ... ... ... Finished `release` profile [optimized + debuginfo] target(s) in 11.70s Running `espflash flash --monitor --port /dev/cu.usbmodem211401 target/xtensa-esp32s3-none-elf/release/rmk-esp32s3` [2025-04-10T10:01:23Z INFO ] Serial port: '/dev/cu.usbmodem211401' [2025-04-10T10:01:23Z INFO ] Connecting... [2025-04-10T10:01:23Z INFO ] Using flash stub Chip type: esp32s3 (revision v0.1) Crystal frequency: 40 MHz Flash size: 4MB Features: WiFi 6, BT 5 MAC address: 40:4c:ca:5b:c7:dc App/part. size: 768,944/4,128,768 bytes, 18.62% [2025-04-10T10:01:23Z INFO ] Segment at address '0x0' has not changed, skipping write [2025-04-10T10:01:23Z INFO ] Segment at address '0x8000' has not changed, skipping write [00:00:06] [========================================] 411/411 0x10000 [2025-04-10T10:01:31Z INFO ] Flashing has completed! ``` -------------------------------- ### Basic Fork Configuration Examples Source: https://github.com/haobogu/rmk/blob/main/docs/docs/main/docs/configuration/behavior.md Demonstrates various fork configurations including simple replacements, conditional outputs based on modifiers, and handling of special keys. ```toml [behavior.fork] forks = [ # Shift + '.' output ':' key { trigger = "Dot", negative_output = "Dot", positive_output = "WM(Semicolon, LShift)", match_any = "LShift|RShift" }, # Shift + ',' output ';' key but only if no Alt is pressed { trigger = "Comma", negative_output = "Comma", positive_output = "Semicolon", match_any = "LShift|RShift", match_none = "LAlt|RAlt" }, # left bracket outputs by default '{', with shifts pressed outputs '[' { trigger = "LeftBracket", negative_output = "WM(LeftBracket, LShift)", positive_output = "LeftBracket", match_any = "LShift|RShift" }, # Flip the effect of shift on 'x'/'X' { trigger = "X", negative_output = "WM(X, LShift)", positive_output = "X", match_any = "LShift|RShift" }, # F24 usually outputs 'a', except when Left Shift or Ctrl pressed, in that case triggers a macro { trigger = "F24", negative_output = "A", positive_output = "Macro1", match_any = "LShift|LCtrl" }, # Swap Z and Y keys if MouseBtn1 is pressed (on the keyboard) (Note that these must not be bindable to avoid infinite fork loops!) { trigger = "Y", negative_output = "Y", positive_output = "Z", match_any = "MouseBtn1", bindable = false }, { trigger = "Z", negative_output = "Z", positive_output = "Y", match_any = "MouseBtn1", bindable = false }, # Shift + Backspace output Delete key (inside a layer tap/hold) { trigger = "LT(2, Backspace)", negative_output = "LT(2, Backspace)", positive_output = "LT(2, Delete)", match_any = "LShift|RShift" }, # Ctrl + play/pause will send next track. MediaPlayPause -> MediaNextTrack # Ctrl + Shift + play/pause will send previous track. MediaPlayPause -> MediaPrevTrack # Alt + play/pause will send volume up. MediaPlayPause -> AudioVolUp # Alt + Shift + play/pause will send volume down. MediaPlayPause -> AudioVolDown # Ctrl + Alt + play/pause will send brightness up. MediaPlayPause -> BrightnessUp # Ctrl + Alt + Shift + play/pause will send brightness down. MediaPlayPause -> BrightnessDown # ( Note that the trigger and immediate trigger keys of the fork chain could be 'virtual keys', # which will never output, like F23, but here multiple overrides demonstrated.) { trigger = "MediaPlayPause", negative_output = "MediaPlayPause", positive_output = "MediaNextTrack", match_any = "LCtrl|RCtrl", bindable = true }, { trigger = "MediaNextTrack", negative_output = "MediaNextTrack", positive_output = "BrightnessUp", match_any = "LAlt|RAlt", bindable = true }, { trigger = "BrightnessUp", negative_output = "BrightnessUp", positive_output = "BrightnessDown", match_any = "LShift|RShift", bindable = false }, { trigger = "MediaNextTrack", negative_output = "MediaNextTrack", positive_output = "MediaPrevTrack", match_any = "LShift|RShift", match_none = "LAlt|RAlt", bindable = false} ] ``` -------------------------------- ### ESP32-C3 BLE Example Output Source: https://github.com/haobogu/rmk/blob/main/examples/use_config/esp32c3_ble/README.md Example output logs when the ESP32-C3 BLE example is successfully compiled and flashed. This includes compilation progress and flashing status. ```shell cargo run --release Compiling ... ... ... Finished `release` profile [optimized + debuginfo] target(s) in 11.70s Running `espflash flash --monitor --port /dev/cu.usbmodem211401 target/riscv32imc-unknown-none-elf/release/rmk-esp32c3` [2025-04-10T10:01:23Z INFO ] Serial port: '/dev/cu.usbmodem211401' [2025-04-10T10:01:23Z INFO ] Connecting... [2025-04-10T10:01:23Z INFO ] Using flash stub Chip type: esp32c3 (revision v0.1) Crystal frequency: 40 MHz Flash size: 4MB Features: WiFi 6, BT 5 MAC address: 40:4c:ca:5b:c7:dc App/part. size: 768,944/4,128,768 bytes, 18.62% [2025-04-10T10:01:23Z INFO ] Segment at address '0x0' has not changed, skipping write [2025-04-10T10:01:23Z INFO ] Segment at address '0x8000' has not changed, skipping write [00:00:06] [========================================] 411/411 0x10000 [2025-04-10T10:01:31Z INFO ] Flashing has completed! ``` -------------------------------- ### Example Event Configurations Source: https://github.com/haobogu/rmk/blob/main/docs/docs/main/docs/configuration/event.md Demonstrates how to adjust event channel parameters for different use cases, such as increasing buffer size for fast typing, adding subscribers for monitoring, or reducing subscribers to save memory. ```toml [event] # Increase key event buffer for fast typing keyboard.channel_size = 16 # Add more subscribers for multiple displays monitoring layer changes layer_change.subs = 8 # Reduce subscribers to save memory on constrained devices battery_status.subs = 2 led_indicator.subs = 2 # Configure multiple parameters for one event peripheral_battery.channel_size = 4 peripheral_battery.subs = 4 ``` -------------------------------- ### Example Layer Configuration Source: https://github.com/haobogu/rmk/blob/main/docs/docs/main/docs/configuration/layout.md Defines a keyboard layer named 'mouse_navigation' with custom key bindings, including layer switching, mouse actions, and aliases. ```toml [[layer]] name = "mouse_navigation" #optional name for the layer keys = """ TO(base_layer) @my_cut @my_copy @my_paste MouseBtn1 MouseUp MouseBtn2 MouseWheelUp MouseLeft MouseBtn4 MouseRight MouseWheelLeft MouseDown MouseWheelRight MouseWheelDown MouseBtn1 MouseBtn2 """ ``` -------------------------------- ### Build and Flash Split Keyboard Example Source: https://github.com/haobogu/rmk/blob/main/examples/use_config/esp32_ble_split/README.md Commands to build and flash the central (ESP32C6) and peripheral (ESP32C3) components of the split keyboard. Use `cargo run-central` and `cargo run-peripheral` for flashing, or `cargo build-central` and `cargo build-peripheral` to only build. ```bash cd examples/use_config/esp32c3_ble_split # Build and flash central (ESP32C6) cargo run-central # Build and flash peripheral (ESP32C3) cargo run-peripheral # Just build (without flashing) cargo build-central cargo build-peripheral ``` -------------------------------- ### Initialize DisplayProcessor with SH1106/oled-async Source: https://github.com/haobogu/rmk/blob/main/docs/docs/main/docs/features/display.md Initialize the display using the oled-async crate for SH1106 driver. Requires specific imports for the builder, display type, rotation, and interface. ```rust use oled_async::Builder; use oled_async::displays::sh1106::Sh1106_128_64; use oled_async::displayrotation::DisplayRotation; use display_interface_i2c::I2CInterface; use rmk::display::DisplayProcessor; let interface = I2CInterface::new(i2c, 0x3C, 0x40); let display = Builder::new(Sh1106_128_64 {}) .with_rotation(DisplayRotation::Rotate0) .connect(interface) .into(); let mut oled = DisplayProcessor::new(display); ``` -------------------------------- ### Install and Use espsegs for Binary Analysis Source: https://github.com/haobogu/rmk/blob/main/examples/use_config/esp32_ble_split/README.md Installs the espsegs tool for analyzing binary segments. Use it to inspect the central (ESP32C6) and peripheral (ESP32C3) binaries. ```bash # Install it first cargo install --git https://github.com/bjoernQ/espsegs # Check central binary (ESP32C6) espsegs target/riscv32imac-unknown-none-elf/release/central --chip esp32c6 # Check peripheral binary (ESP32C3) espsegs target/riscv32imc-unknown-none-elf/release/peripheral --chip esp32c3 ``` -------------------------------- ### Fork Configuration Example Source: https://github.com/haobogu/rmk/blob/main/docs/docs/main/docs/configuration/behavior.md This snippet demonstrates the structure for defining fork configurations. It specifies trigger conditions, negative and positive outputs, and matching rules for key combinations. Note that 'bindable' indicates if the fork can be directly bound. ```lua [ { trigger = "MediaPlayPause", negative_output = "MediaPlayPause", positive_output = "AudioVolUp", match_any = "LAlt|RAlt", match_none = "LCtrl|RCtrl", bindable = true }, { trigger = "AudioVolUp", negative_output = "AudioVolUp", positive_output = "AudioVolDown", match_any = "LShift|RShift", match_none = "LCtrl|RCtrl", bindable = false } ] ``` -------------------------------- ### Single-event Device Example: Charging State Reader Source: https://github.com/haobogu/rmk/blob/main/docs/docs/main/docs/features/input_device.md An example of a single-event input device that reads charging state from a GPIO pin. It requires a `read_charging_state_event` method that returns `ChargingStateEvent`. ```rust use rmk_macro::input_device; #[input_device(publish = ChargingStateEvent)] pub struct ChargingStateReader { state_input: I, low_active: bool, current_charging_state: bool, } impl ChargingStateReader { pub fn new(state_input: I, low_active: bool) -> Self { Self { state_input, low_active, current_charging_state: false, } } // This method is required by #[input_device(publish = ChargingStateEvent)] async fn read_charging_state_event(&mut self) -> ChargingStateEvent { loop { embassy_time::Timer::after_secs(5).await; let charging = if self.low_active { self.state_input.is_low().unwrap_or(false) } else { self.state_input.is_high().unwrap_or(false) }; if charging != self.current_charging_state { self.current_charging_state = charging; return ChargingStateEvent { charging }; } } } } ``` -------------------------------- ### BLE Split Peripheral Setup Source: https://github.com/haobogu/rmk/blob/main/docs/docs/main/docs/configuration/split_keyboard.md Configure a BLE split peripheral. Uses a normal matrix and runs the split peripheral manager with central address and stack information. ```rust let mut matrix = Matrix::<_, _, _, 4, 7, true>::new(row_pins, col_pins, debouncer); run_rmk_split_peripheral(central_addr, &stack); ``` -------------------------------- ### Multi-event Device Example: NrfAdc Source: https://github.com/haobogu/rmk/blob/main/docs/docs/main/docs/features/input_device.md An example of a multi-event input device using a wrapper enum (`NrfAdcEvent`) to publish different event types. The `read_nrf_adc_event` method returns the appropriate enum variant. ```rust use rmk_macro::{Event, input_device}; // Define a wrapper enum for multiple event types #[derive(Event, Clone, Debug)] pub enum NrfAdcEvent { Pointing(PointingEvent), Battery(BatteryAdcEvent), } #[input_device(publish = NrfAdcEvent)] pub struct NrfAdc<'a, const PIN_NUM: usize, const EVENT_NUM: usize> { saadc: Saadc<'a, PIN_NUM>, // ... other fields } impl<'a, const PIN_NUM: usize, const EVENT_NUM: usize> NrfAdc<'a, PIN_NUM, EVENT_NUM> { // Returns the wrapper enum async fn read_nrf_adc_event(&mut self) -> NrfAdcEvent { // Read ADC and return the appropriate variant NrfAdcEvent::Battery(BatteryAdcEvent(adc_value)) } } ``` -------------------------------- ### Building Firmware for UF2 Source: https://github.com/haobogu/rmk/blob/main/docs/docs/main/docs/user_guide/flash_firmware.mdx Command to build the firmware for the UF2 bootloader in release mode. ```shell cargo make uf2 --release ``` -------------------------------- ### Troubleshoot 'Unable to find libclang' Error on Windows Source: https://github.com/haobogu/rmk/blob/main/docs/docs/main/docs/getting_started/faq.md This error occurs when LLVM (Clang) is not installed or not found by the system. Follow the provided link to install LLVM and ensure its path is correctly set. ```text error: failed to run custom build command for `nrf-mpsl-sys v0.1.1 (https://github.com/alexmoon/nrf-sdc.git?rev=7be9b853e15ca0404d65c623d1ec5795fd96c204#7be9b853)` Caused by: process didn't exit successfully: `C:\Users\User\Documents\rmk\target\release\build\nrf-mpsl-sys-7601ddd28810dbeb\build-script-build` (exit code: 101) --- stderr thread 'main' panicked at C:\Users\User\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\bindgen-0.70.1\lib.rs:622:27: Unable to find libclang: "couldn't find any valid shared libraries matching: ['clang.dll', 'libclang.dll'], set the `LIBCLANG_PATH` environment variable to a path where one of these files can be found (invalid: [])" note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace warning: build failed, waiting for other jobs to finish... error: failed to run custom build command for `nrf-sdc-sys v0.1.0 (https://github.com/alexmoon/nrf-sdc.git?rev=7be9b853e15ca0404d65c623d1ec5795fd96c204#7be9b853)` Caused by: process didn't exit successfully: `C:\Users\User\Documents\rmk\target\release\build\nrf-sdc-sys-47ab10b68780c6ba\build-script-build` (exit code: 101) --- stderr thread 'main' panicked at C:\Users\User\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\bindgen-0.70.1\lib.rs:622:27: Unable to find libclang: "couldn't find any valid shared libraries matching: ['clang.dll', 'libclang.dll'], set the `LIBCLANG_PATH` environment variable to a path where one of these files can be found (invalid: [])" note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ``` -------------------------------- ### No-Key Action Example Source: https://github.com/haobogu/rmk/blob/main/docs/docs/main/docs/configuration/layout.md Specifies a key that performs no action using 'No'. ```toml # Example: Key with no action No ``` -------------------------------- ### Shifted Key Example Source: https://github.com/haobogu/rmk/blob/main/docs/docs/main/docs/configuration/layout.md Creates a shifted version of a key using 'SHIFTED(key)'. ```toml # Example: Shifted '1' key SHIFTED(1) ``` -------------------------------- ### Custom Matrix Implementation Example Source: https://github.com/haobogu/rmk/blob/main/docs/docs/main/docs/features/matrix.md Demonstrates how to implement a custom matrix by defining a struct and implementing the `MatrixTrait`. This allows for integration of external I/O expanders or specialized scanning algorithms. ```rust struct YourOwnMatrix {} impl MatrixTrait for YourOwnMatrix { // Implement the `MatrixTrait` } let my_matrix = YourOwnMatrix::new(); // Create the matrix struct // .. Other initialization // Run the main process join3( run_all!(my_matrix), keyboard.run(), run_rmk(&keymap, driver, &mut storage, rmk_config), ) .await; ``` -------------------------------- ### Running Multiple Input Devices Concurrently Source: https://github.com/haobogu/rmk/blob/main/docs/docs/main/docs/features/input_device.md Use the `run_all!` macro to run multiple input devices and other runnables concurrently. This example shows creating and running a matrix, encoder, ADC device, and a battery processor. ```rust use rmk::run_all; // Create your devices and processors let mut matrix = Matrix::new(row_pins, col_pins, debouncer); let mut encoder = RotaryEncoder::new(pin_a, pin_b, 0); let mut adc_device = NrfAdc::new(saadc, event_types, interval, None); let mut batt_proc = BatteryProcessor::new(2000, 2806); // Run them concurrently using join and run_all! join( run_all!(matrix, encoder, adc_device, batt_proc), run_rmk(&keymap, driver, &stack, &mut storage, rmk_config), ).await; ``` -------------------------------- ### Install RMK CLI Tool Source: https://github.com/haobogu/rmk/blob/main/docs/docs/main/docs/migration/v06_v07.md Update the RMK command-line interface tool to the latest version. ```shell cargo install rmkit --force ``` -------------------------------- ### Basic Behavior Configuration Source: https://github.com/haobogu/rmk/blob/main/docs/docs/main/docs/configuration/behavior.md Sets up tri-layer behavior with specific upper, lower, and adjust layers, and configures a one-shot timeout. ```toml [behavior] tri_layer = { upper = 1, lower = 2, adjust = 3, } one_shot = { timeout = "1s", } one_shot_modifiers = { activate_on_keypress = false, } ``` -------------------------------- ### Keyboard Macro Example Source: https://github.com/haobogu/rmk/blob/main/docs/docs/main/docs/configuration/layout.md Assigns a keyboard macro using 'Macro(n)', where 'n' is the macro identifier. ```toml # Example: Keyboard macro 1 Macro(1) ``` -------------------------------- ### One-Shot Modifier Action Example Source: https://github.com/haobogu/rmk/blob/main/docs/docs/main/docs/configuration/layout.md Applies a modifier for a single keypress using 'OSM(modifier)'. Modifiers can be chained. ```toml # Example: Apply Right Alt modifier for one shot OSM(RAlt) ```