-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove traits used to set up some drivers, add macros to set up seria…
…l drivers this makes the `setup_driver` functions (previously `setup_backlight_driver`, `setup_underglow_driver`, etc.) less restrictive, since you just pass arguments instead of implementing a trait. the traits that were removed from the main `rumcake` library are instead generated by the `keyboard` macro so that you can still configure your drivers using an impl block this also adds a setup_buffered_uarte macro for nrf chips, which can be used for split keyboards.
- Loading branch information
Showing
18 changed files
with
514 additions
and
336 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,19 @@ | ||
use proc_macro2::TokenStream; | ||
use quote::quote; | ||
|
||
pub mod is31fl3731; | ||
pub mod nrf_ble; | ||
pub mod ssd1306; | ||
pub mod ws2812; | ||
|
||
pub fn serial_driver_trait() -> TokenStream { | ||
quote! { | ||
/// A trait that must be implemented to set up the IS31FL3731 driver. | ||
pub(crate) trait SerialDriverSettings { | ||
/// Setup a serial driver that is capable of both reading and writing. | ||
/// | ||
/// It is recommended to use a macro to implement this function. | ||
fn setup_serial() -> impl ::rumcake::embedded_io_async::Write + ::rumcake::embedded_io_async::Read; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use proc_macro2::TokenStream; | ||
use quote::quote; | ||
|
||
pub fn peripheral_driver_trait() -> TokenStream { | ||
quote! { | ||
/// A trait that nRF-based keyboards must implement to use bluetooth to drive peripheral devices in a split keyboard setup. | ||
pub(crate) trait NRFBLEPeripheralDriverSettings { | ||
/// A "Random Static" bluetooth address of the central device that this peripheral will connect to. | ||
const CENTRAL_ADDRESS: [u8; 6]; | ||
} | ||
} | ||
} | ||
|
||
pub fn central_driver_trait() -> TokenStream { | ||
quote! { | ||
/// A trait that nRF-based keyboards must implement to use bluetooth to drive central devices in a split keyboard setup. | ||
pub(crate) trait NRFBLECentralDriverSettings { | ||
/// A list of "Random Static" bluetooth addresses that this central device can connect to. | ||
const PERIPHERAL_ADDRESSES: &'static [[u8; 6]]; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use proc_macro2::TokenStream; | ||
use quote::quote; | ||
|
||
pub fn driver_trait() -> TokenStream { | ||
quote! { | ||
/// A trait that keyboards must implement to set up the SSD1306 driver. | ||
pub(crate) trait Ssd1306I2cDriverSettings { | ||
/// Size of the display. Must be an implementor of [`DisplaySize`]. | ||
type SIZE_TYPE: ::rumcake::drivers::ssd1306::driver::size::DisplaySize; | ||
|
||
/// Size of the display. Must be an implementor of [`DisplaySize`]. | ||
const SIZE: Self::SIZE_TYPE; | ||
|
||
/// Rotation of the SSD1306 display. See [`DisplayRotation`]. | ||
const ROTATION: ::rumcake::drivers::ssd1306::driver::rotation::DisplayRotation = | ||
::rumcake::drivers::ssd1306::driver::rotation::DisplayRotation::Rotate90; | ||
|
||
/// Setup the I2C peripheral to communicate with the SSD1306 display. | ||
/// | ||
/// It is recommended to use [`rumcake::hw::mcu::setup_i2c`] to implement this function. | ||
fn setup_i2c() -> impl ::rumcake::embedded_hal::blocking::i2c::Write<Error = impl core::fmt::Debug>; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.