11 releases

0.2.8 Jun 18, 2023
0.2.7 Jun 3, 2023
0.2.6 May 18, 2023
0.2.4 Apr 25, 2023
0.1.2 Oct 28, 2021

#595 in Hardware support

Download history 4/week @ 2024-02-19 8/week @ 2024-02-26 5/week @ 2024-03-11 48/week @ 2024-04-01

53 downloads per month

MIT license

51KB
1K SLoC

CherryRGB

Library to interact with Cherry RGB keyboards.


lib.rs:

Library to interact with Cherry RGB keyboards

Usage

Find usb keyboard and initialize it

use cherryrgb::{self, CherryKeyboard};

// Optionally, filter for product id if you have more than one cherry device.
let devices = cherryrgb::find_devices(Some(0x00dd)).unwrap();
let (vendor_id, product_id) = devices.first().unwrap().to_owned();
let keyboard = CherryKeyboard::new(vendor_id, product_id).unwrap();

keyboard.fetch_device_state().unwrap();

Set LED animation

use cherryrgb::rgb::RGB8;

// Create color: green
let color = RGB8::new(0, 0xff, 0);
let use_rainbow_colors: bool = false;

keyboard.set_led_animation(
    cherryrgb::LightingMode::Rain,
    cherryrgb::Brightness::Full,
    cherryrgb::Speed::Slow,
    color,
    use_rainbow_colors,
)
.unwrap();

Set custom LED color for individual key(s)

use cherryrgb::rgb::RGB8;

// Reset all colors first
keyboard.reset_custom_colors().unwrap();

// Create color: green
let color = RGB8::new(0, 0xff, 0);

// Create keys struct and set key with index 42 to desired color
let mut keys = cherryrgb::CustomKeyLeds::new();
keys.set_led(42, color).unwrap();

// Send packets to keyboard
keyboard.set_custom_colors(keys).unwrap();

Dependencies

~3.5–5MB
~95K SLoC