Skip to content

Commit

Permalink
update rumcake revision
Browse files Browse the repository at this point in the history
  • Loading branch information
Univa committed Apr 11, 2024
1 parent f4cde5d commit 7c4331e
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 24 deletions.
2 changes: 1 addition & 1 deletion rumcake-basic-template/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
cortex-m-rt = "0.7.0"
embassy-executor = { git = "https://github.com/embassy-rs/embassy", rev = "b8be126" }

rumcake = { git = "https://github.com/Univa/rumcake", rev = "7128881", features = ["usb", "stm32f303cb", "vial", "underglow", "ws2812-bitbang"] }
rumcake = { git = "https://github.com/Univa/rumcake", rev = "d340eb9", features = ["usb", "stm32f303cb", "vial", "underglow", "ws2812-bitbang"] }

[build-dependencies]
rust-lzma = "0.6.0"
Expand Down
34 changes: 22 additions & 12 deletions rumcake-basic-template/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,21 @@ use rumcake::keyberon;
use rumcake::keyboard;
use rumcake::keyboard::{build_layout, build_standard_matrix, remap_matrix};

#[keyboard(usb, underglow(driver = "ws2812_bitbang"), vial)]
#[keyboard(
usb,
underglow(
id = {{ keyboard-name }}Lighting,
driver_setup_fn = setup_underglow
),
vial
)]
pub struct {{ keyboard-name }};

// This keyboard's PCB uses a duplex matrix.
// `remap_matrix` creates a `remap` macro that allows us to have a better visual layout for the rest of configuration
// If your keyboard doesn't have a duplex matrix, you can remove this `remap_matrix` macro and remove the `remap!` wrapped around build_layout
remap_matrix! {
{
original: {
[ K00 K01 K02 K03 K04 K05 K06 K07 ]
[ K08 K09 K10 K11 K12 K13 K14 No ]
[ K15 K16 K17 K18 K19 K20 K21 K22 ]
Expand All @@ -34,8 +41,8 @@ remap_matrix! {
[ K53 K54 K55 K56 K57 K58 K59 No ]
[ K60 K61 K62 K63 K64 K65 K66 K67 ]
[ No No No No No K68 K69 No ]
}
{
},
remapped: {
[ K00 K08 K01 K09 K02 K10 K03 K11 K04 K12 K05 K13 K06 K14 K07 K22 ]
[ K15 K23 K16 K24 K17 K25 K18 K26 K19 K27 K20 K28 K21 K29 K37 ]
[ K30 K38 K31 K39 K32 K40 K33 K41 K34 K42 K35 K43 K36 K44 K52 ]
Expand Down Expand Up @@ -73,17 +80,19 @@ impl KeyboardLayout for {{ keyboard-name }} {
// Matrix configuration
use rumcake::keyboard::KeyboardMatrix;
impl KeyboardMatrix for {{ keyboard-name }} {
type Layout = Self;

build_standard_matrix! {
{ PB3 PB4 PA15 PB5 PA0 PA1 PB10 PB11 PA2 PA3 } // Rows
{ PB12 PB2 PB1 PB0 PA7 PA6 PA5 PA4 } // Columns
rows: [ PB3 PB4 PA15 PB5 PA0 PA1 PB10 PB11 PA2 PA3 ], // Rows
cols: [ PB12 PB2 PB1 PB0 PA7 PA6 PA5 PA4 ] // Columns
}
}

// USB configuration
use rumcake::usb::USBKeyboard;
impl USBKeyboard for {{ keyboard-name }} {
const USB_VID: u16 = 0x0000; // TODO: Change this
const USB_PID: u16 = 0x0000; // TODO:: Change this
const USB_PID: u16 = 0x0000; // TODO: Change this
}

// Storage configuration, uncomment after enabling the `storage` feature flag
Expand All @@ -103,12 +112,13 @@ impl VialKeyboard for {{ keyboard-name }} {

// Underglow configuration + driver
// Note: since the `storage` feature flag is not enabled, changes to the underglow config (e.g. brightness, current effect, etc.) will not be saved. If you use `storage`, be sure to update memory.x.
use rumcake::underglow::UnderglowDevice;
impl UnderglowDevice for {{ keyboard-name }} {
struct {{ keyboard-name }}Lighting;
use rumcake::lighting::underglow::{UnderglowDevice, UnderglowDriver};
impl UnderglowDevice for {{ keyboard-name }}Lighting {
const NUM_LEDS: usize = 18; // TODO: Change this
}
use rumcake::drivers::ws2812_bitbang::ws2812_bitbang_pin;
impl WS2812BitbangDriverSettings for {{ keyboard-name }} {
ws2812_bitbang_pin! { PA10 } // TODO: Change this
use rumcake::drivers::ws2812_bitbang::setup_ws2812_bitbang;
async fn setup_underglow() -> impl UnderglowDriver<{{ keyboard-name }}Lighting> {
setup_ws2812_bitbang! { pin: PA10 } // TODO: Change this
}

2 changes: 1 addition & 1 deletion rumcake-split-template/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ cortex-m = { version = "0.7.6" }
cortex-m-rt = "0.7.0"
embassy-executor = { git = "https://github.com/embassy-rs/embassy", rev = "b8be126" }

rumcake = { git = "https://github.com/Univa/rumcake", rev = "7128881", features = ["nrf52840", "drivers", "nrf-ble"] }
rumcake = { git = "https://github.com/Univa/rumcake", rev = "d340eb9", features = ["nrf52840", "drivers", "nrf-ble"] }

[profile.dev]
debug = 2
Expand Down
26 changes: 21 additions & 5 deletions rumcake-split-template/src/left.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ use rumcake::keyberon;
use rumcake::keyboard;
use rumcake::keyboard::{build_layout, build_standard_matrix};

#[keyboard(usb, bluetooth, split_central(driver = "ble"))]
#[keyboard(
usb,
bluetooth,
split_central(
driver_setup_fn = setup_nrf_ble,
driver_type = "nrf-ble"
)
)]
pub struct {{ keyboard-name }}Left;

// Basic keyboard configuration
Expand Down Expand Up @@ -50,9 +57,11 @@ impl KeyboardLayout for {{ keyboard-name }}Left {
// Matrix configuration
use rumcake::keyboard::KeyboardMatrix;
impl KeyboardMatrix for {{ keyboard-name }}Left {
type Layout = Self; // send matrix events from this half's matrix to the layout

build_standard_matrix! {
{ P0_02 P1_13 P1_11 P0_10 } // Rows
{ P0_22 P0_24 P1_00 P0_11 P1_04 P1_06 } // Columns
rows: [ P0_02 P1_13 P1_11 P0_10 ], // Rows
cols: [ P0_22 P0_24 P1_00 P0_11 P1_04 P1_06 ] // Columns
}
}

Expand All @@ -69,8 +78,15 @@ impl BluetoothKeyboard for {{ keyboard-name }}Left {
}

// Split keyboard setup
impl NRFBLECentralDriverSettings for {{ keyboard-name }}Left {
const PERIPHERAL_ADDRESSES: &'static [[u8; 6]] = &[[0x00, 0x00, 0x00, 0x00, 0x00, 0x00]]; // TODO: Change this, must contain the address for the right half.
use rumcake::split::central::{CentralDevice, CentralDeviceDriver};
use rumcake::drivers::nrf_ble::central::setup_nrf_ble_split_central;
impl CentralDevice for {{ keyboard-name }}Left {
type Layout = Self; // send matrix events from peripherals to the implemented layout
}
async fn setup_nrf_ble() -> (impl CentralDeviceDriver, &'static [[u8; 6]]) {
setup_nrf_ble_split_central! {
peripheral_addresses: [[0x00, 0x00, 0x00, 0x00, 0x00, 0x00]], // TODO: Change this, must contain the address for the right half.
}
}

// USB configuration
Expand Down
17 changes: 12 additions & 5 deletions rumcake-split-template/src/right.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use rumcake::keyberon;
use rumcake::keyboard;
use rumcake::keyboard::{build_layout, build_standard_matrix};

#[keyboard(split_peripheral(driver = "ble"))]
#[keyboard(split_peripheral(driver_setup_fn = setup_nrf_ble, driver_type = "nrf-ble"))]
pub struct {{ keyboard-name }}Right;

use rumcake::keyboard::Keyboard;
Expand All @@ -23,9 +23,11 @@ impl Keyboard for {{ keyboard-name }}Right {
// Since this is a peripheral device, this only needs a matrix
use rumcake::keyboard::KeyboardMatrix;
impl KeyboardMatrix for {{ keyboard-name }}Right {
type PeripheralDeviceType = Self; // send matrix events to the central device via the peripheral device's driver

build_standard_matrix! {
{ P0_22 P1_00 P0_11 P1_04 } // Rows
{ P0_09 P0_10 P1_11 P1_13 P1_15 P0_02 } // Columns
rows: [ P0_22 P1_00 P0_11 P1_04 ], // Rows
cols: [ P0_09 P0_10 P1_11 P1_13 P1_15 P0_02 ] // Columns
}

fn remap_to_layout(row: u8, col: u8) -> (u8, u8) {
Expand All @@ -43,6 +45,11 @@ impl BluetoothDevice for {{ keyboard-name }}Right {
}

// Split keyboard setup
impl NRFBLEPeripheralDriverSettings for {{ keyboard-name }}Right {
const CENTRAL_ADDRESS: [u8; 6] = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00]; // TODO: Change this, must match the left half's BLUETOOTH_ADDRESS
use ::rumcake::split::peripheral::{PeripheralDevice, PeripheralDeviceDriver};
use rumcake::drivers::nrf_ble::peripheral::setup_nrf_ble_split_peripheral;
impl PeripheralDevice for {{ keyboard-name }}Right {}
async fn setup_nrf_ble() -> (impl PeripheralDeviceDriver, [u8; 6]) {
setup_nrf_ble_split_central! {
peripheral_addresses: [[0x00, 0x00, 0x00, 0x00, 0x00, 0x00]], // TODO: Change this, must match the left half's BLUETOOTH_ADDRESS
}
}

0 comments on commit 7c4331e

Please sign in to comment.