Skip to content

Commit

Permalink
Add white color for RGB
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Schaefer <[email protected]>
  • Loading branch information
JohnAZoidberg committed Mar 1, 2023
1 parent 9461471 commit 3d6e387
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Options:
--rgb-hue [<RGB_HUE>]
Set RGB hue or get, if no value provided. (0-255)
--rgb-color <RGB_COLOR>
Set RGB color [possible values: red, yellow, green, cyan, blue, purple]
Set RGB color [possible values: red, yellow, green, cyan, blue, purple, white]
--rgb-saturation [<RGB_SATURATION>]
Set RGB saturation or get, if no value provided. (0-255)
--backlight [<BACKLIGHT>]
Expand Down Expand Up @@ -169,6 +169,7 @@ qmk_hid via --rgb-color green
qmk_hid via --rgb-color cyan
qmk_hid via --rgb-color blue
qmk_hid via --rgb-color purple
qmk_hid via --rgb-color white
# Enable a mode that reacts to keypresses
# Note that the effect numbers can be different per keyboard
Expand Down
9 changes: 8 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ enum Color {
Blue,
/// Purple (300°) => 213
Purple,
/// Saturation 0
White,
}

/// Factory
Expand Down Expand Up @@ -388,7 +390,11 @@ fn use_device(args: &ClapCli, api: &HidApi, dev_info: &DeviceInfo) {
println!("Color Hue: {hue}");
println!("Color Saturation: {saturation}");
} else if let Some(color) = &args.rgb_color {
set_rgb_color(&device, Some(color_as_hue(*color)), None).unwrap();
if let Color::White = color {
set_rgb_color(&device, None, Some(0)).unwrap();
} else {
set_rgb_color(&device, Some(color_as_hue(*color)), Some(255)).unwrap();
}
let (hue, saturation) = get_rgb_color(&device).unwrap();
println!("Color Hue: {hue}");
println!("Color Saturation: {saturation}");
Expand Down Expand Up @@ -432,5 +438,6 @@ fn color_as_hue(color: Color) -> u8 {
Color::Cyan => 125,
Color::Blue => 170,
Color::Purple => 213,
Color::White => 0, // Doesn't matter, only hue needs to be 0
}
}

0 comments on commit 3d6e387

Please sign in to comment.