Backlighting
Backlighting can be used to provide lighting from underneath your keycaps, typically via an LED
inside or underneath the individual switches. rumcake
supports different types of backlighting
depending on LED type, and whether LEDs are individually addressable.
Setup
Required Cargo features
You must enable the following rumcake
features:
- Exactly one of:
simple-backlight
(single color backlighting, all LEDs have the same brightness)simple-backlight-matrix
(single color backlighting, each LED in the matrix is individually addressable)rgb-backlight-matrix
(RGB backlighting, each LED in the matrix is individually addressable)
- Feature flag for one of the available backlight drivers that you would like to use
storage
(optional, if you want to save your backlight settings)
Some drivers may not be able to support all backlight types.
Required code
To set up backlighting, you must create a new type to implement traits on.
Then, you can add <backlight_type>(id = <type>, driver_setup_fn = <setup_fn>)
to your #[keyboard]
macro
invocation. Your new type must implement the appropriate traits depending on the type of lighting you’re using:
simple_backlight
:SimpleBacklightDevice
simple_backlight_matrix
:SimpleBacklightMatrixDevice
rgb_backlight_matrix
:RGBBacklightMatrixDevice
The driver_setup_fn
must be an async function that has no parameters, and returns a type that implements the appropriate
driver trait:
simple_backlight
:SimpleBacklightDriver<T>
simple_backlight_matrix
:SimpleBacklightMatrixDriver<T>
rgb_backlight_matrix
:RGBBacklightMatrixDriver<T>
If you’re implementing a backlight matrix (either the simple-backlight-matrix
or rgb-backlight-matrix
), your keyboard must also implement the BacklightMatrixDevice
trait:
Lastly, you must set up the driver. To do this, you need to complete your driver_setup_fn
by constructing the driver.
You can check the API reference for your chosen driver for a set up
function or macro to make this process easier.
Depending on the driver, you may also need to implement the appropriate trait that corresponds to your chosen driver. Check the list of available backlight drivers for this information.
For example, with is31fl3731
, you must implement IS31FL3731BacklightDriver
, and you can use the setup_is31fl3731!
macro to set up the driver:
Keycodes
Depending on the backlight type you chose, you can use certain version of the BacklightCommand
enum in your keyberon
layout:
In your keyberon
layout, you can use {Custom(SimpleBacklight(<command>))}
,
{Custom(SimpleBacklightMatrix(<command>))}
, {Custom(RGBBacklightMatrix(<command>))}
,
depending on what type of backlight system you are using.
Additionally, you must choose the backlight system that the keycodes will correspond to by
implementing one of the associated types SimpleBacklightDeviceType
, SimpleBacklightMatrixDeviceType
,
RGBBacklightDeviceType
.
Example of usage:
To-do List
- RGB Backlight animations
Available Drivers
Name | Feature Flag | Required Traits |
---|---|---|
IS31FL3731 | is31fl3731 | IS31FL3731BacklightDriver |
WS2812 Bitbang | ws2812_bitbang | WS2812BitbangBacklightDriver |