Crate rmk

Source
Expand description

Logo

A feature-rich Rust keyboard firmware.

👉 Join our Discord server if you have anything to discuss!


中文

§Features

  • Support a wide range of microcontrollers: Powered by embassy, RMK supports a wide range of microcontrollers, such as stm32/nRF/rp2040/esp32
  • Real-time keymap editing: RMK has built-in Vial support, the keymap can be changed on-the-fly. You can even use Vial to edit keymap over BLE directly
  • Advanced keyboard features: Many advanced keyboard features are available by default in RMK, such as layer switch, media control, system control, mouse control, etc
  • Wireless: BLE wireless support with auto-reconnection/multiple devices feature for nRF52 and esp32 microcontrollers, tested on nRF52840, esp32c3 and esp32s3
  • Easy configuration: RMK provides a simple way to build your keyboard: a keyboard.toml is all you need! For experienced Rust user, you can still customize your firmware easily using RMK
  • Low latency and low-power ready: RMK has a typical 2 ms latency in wired mode and 10 ms latency in wireless mode. By enabling async_matrix feature, RMK has very low power consumption, with a 2000mah battery, RMK can provide several months battery life

§User Documentation | API Reference | FAQs | Changelog

§Real World Examples

§rmk-ble-keyboard

§Usage

§Option 1: Initialize from template

You can use rmk-template to initialize your project.

cargo install cargo-generate flip-link
cargo generate --git https://github.com/HaoboGu/rmk-template

Then follow the steps in generated README.md. Check RMK’s User Guide for details.

§Option 2: Try built-in examples

Example can be found at examples. The following is a simple step-to-step instruction for rp2040. For other microcontrollers, the steps should be identical with a debug probe.

§rp2040
  1. Install probe-rs

    curl --proto '=https' --tlsv1.2 -LsSf https://github.com/probe-rs/probe-rs/releases/latest/download/probe-rs-tools-installer.sh | sh
  2. Build the firmware

    cd examples/use_rust/rp2040
    cargo build
  3. Flash using debug probe

    If you have a debug probe connected to your rp2040 board, flashing is quite simple: run the following command to automatically compile and flash RMK firmware to the board:

    cd examples/use_rust/rp2040
    cargo run
  4. (Optional) Flash using USB

    If you don’t have a debug probe, you can use elf2uf2-rs to flash your rp2040 firmware via USB. There are several additional steps you have to do:

    1. Install elf2uf2-rs: cargo install elf2uf2-rs
    2. Update examples/use_rust/rp2040/.cargo/config.toml, use elf2uf2 as the flashing tool
      - runner = "probe-rs run --chip RP2040"
      + runner = "elf2uf2-rs -d"
    3. Connect your rp2040 board holding the BOOTSEL key, ensure that rp’s USB drive appears
    4. Flash
      cd examples/use_rust/rp2040
      cargo run
      Then, you will see logs like if everything goes right:
      Finished release [optimized + debuginfo] target(s) in 0.21s
      Running `elf2uf2-rs -d 'target\thumbv6m-none-eabi\release\rmk-rp2040'`
      Found pico uf2 disk G:\
      Transfering program to pico
      173.00 KB / 173.00 KB [=======================] 100.00 % 193.64 KB/s  

§Roadmap

Current roadmap of RMK can be found here.

§Minimum Supported Rust Version (MSRV)

This crate uses latest stable. Other versions should work, but they’re not tested.

§License

RMK is licensed under either of

at your option.

§Feature flags

  • col2row (enabled by default) — If your PCB diode’s direction is col2row, enable this feature. If it’s row2col, disable this feature.
  • async_matrix — Enable async matrix scan
  • rapid_debouncer — Use rapid debouncer
  • split — Feature for split keyboard
  • _no_usb — Internal feature that indicates no USB is used, this feature will be auto-activated for some chips
  • _no_external_storage — Internal feature that indicates no storage available, or it’s unnecessary to pass storage to the main RMK API

§BLE feature flags

⚠️ Due to the limitation of docs.rs, functions gated by BLE features won’t show in docs.rs. You have to head to examples folder of RMK repo for their usages.

  • nrf52840_ble — Enable feature if you want to use nRF52840 with BLE.
  • nrf52833_ble — Enable feature if you want to use nRF52833 with BLE.
  • nrf52832_ble — Enable feature if you want to use nRF52832 with BLE.
  • nrf52811_ble — Enable feature if you want to use nRF52811 with BLE.
  • nrf52810_ble — Enable feature if you want to use nRF52810 with BLE.
  • esp32c3_ble — Enable feature if you want to use ESP32C3 with BLE.
  • esp32c6_ble — Enable feature if you want to use ESP32C6 with BLE.
  • esp32s3_ble — Enable feature if you want to use ESP32S3 with BLE.

Re-exports§

Modules§

Macros§

  • Create a normal action: KeyAction
  • Create a normal key. For example, k!(A) represents KeyAction::Single(Action::Key(KeyCode::A))
  • Create a layer in keymap
  • Create a layer activate with modifier action
  • Create a layer activate action or tap key(tap/hold)
  • Create a layer activate action. For example, mo!(1) activates layer 1.
  • Create an oneshot layer key in keymap
  • Create a layer toggle action
  • Create a layer activate or tap toggle action
  • Create a normal key with modifier action

Structs§

Functions§