-
Notifications
You must be signed in to change notification settings - Fork 18
Add support for RGB command #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f31af68
a718e63
b69985a
054f1b8
9324ad4
0424c81
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ use crate::chromium_ec; | |
use crate::chromium_ec::commands::DeckStateMode; | ||
use crate::chromium_ec::commands::FpLedBrightnessLevel; | ||
use crate::chromium_ec::commands::RebootEcCmd; | ||
use crate::chromium_ec::commands::RgbS; | ||
use crate::chromium_ec::commands::TabletModeOverride; | ||
use crate::chromium_ec::EcResponseStatus; | ||
use crate::chromium_ec::{print_err, EcFlashType}; | ||
|
@@ -166,6 +167,7 @@ pub struct Cli { | |
pub fp_led_level: Option<Option<FpBrightnessArg>>, | ||
pub fp_brightness: Option<Option<u8>>, | ||
pub kblight: Option<Option<u8>>, | ||
pub rgbkbd: Vec<u64>, | ||
pub tablet_mode: Option<TabletModeArg>, | ||
pub console: Option<ConsoleArg>, | ||
pub reboot_ec: Option<RebootEcArg>, | ||
|
@@ -753,6 +755,21 @@ pub fn run_with_args(args: &Cli, _allupdate: bool) -> i32 { | |
} else if let Some(Some(kblight)) = args.kblight { | ||
assert!(kblight <= 100); | ||
ec.set_keyboard_backlight(kblight); | ||
} else if !args.rgbkbd.is_empty() { | ||
if args.rgbkbd.len() < 2 { | ||
println!( | ||
"Must provide at least 2 arguments. Provided only: {}", | ||
args.rgbkbd.len() | ||
); | ||
} else { | ||
let start_key = args.rgbkbd[0] as u8; | ||
let colors = args.rgbkbd[1..].iter().map(|color| RgbS { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bonus points if you figure out how to do the *8 multipliers like i have on the ec console. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. left as an exercise for the reader There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ohh like |
||
r: ((color & 0x00FF0000) >> 16) as u8, | ||
g: ((color & 0x0000FF00) >> 8) as u8, | ||
b: (color & 0x000000FF) as u8, | ||
}); | ||
ec.rgbkbd_set_color(start_key, colors.collect()).unwrap(); | ||
} | ||
} else if let Some(None) = args.kblight { | ||
print!("Keyboard backlight: "); | ||
if let Some(percentage) = print_err(ec.get_keyboard_backlight()) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env python3 | ||
# Example invocation in fish shell | ||
# cargo build && sudo ./target/debug/framework_tool \ | ||
# --driver portio --has-mec false --pd-ports 1 1 --pd-addrs 64 64 \ | ||
# (./rgbkbd.py | string split ' ') | ||
|
||
BRIGHTNESS = 1 | ||
RED = int(0xFF * BRIGHTNESS) << 16 | ||
GREEN = int(0xFF * BRIGHTNESS) << 8 | ||
BLUE = int(0xFF * BRIGHTNESS) | ||
CYAN = GREEN + BLUE | ||
YELLOW = RED + GREEN | ||
PURPLE = BLUE + RED | ||
WHITE = RED + GREEN + BLUE | ||
|
||
grid_4x4 = [ | ||
[ YELLOW, RED, RED, RED, YELLOW ], | ||
[ RED, WHITE, GREEN, WHITE, RED ], | ||
[ RED, GREEN, BLUE, GREEN, RED ], | ||
[ RED, WHITE, GREEN, WHITE, RED ], | ||
[ YELLOW, RED, RED, RED, YELLOW ], | ||
] | ||
|
||
fan_8leds = [[ | ||
# WHITE, CYAN, BLUE, GREEN, PURPLE, RED, YELLOW, WHITE | ||
RED, RED, RED, RED, | ||
GREEN, GREEN, GREEN, GREEN | ||
]] | ||
|
||
# colors = grid_4x4 | ||
colors = fan_8leds | ||
|
||
print('--rgbkbd 0', end='') | ||
for row in colors: | ||
for col in row: | ||
print(' ', end='') | ||
print(col, end='') |
Uh oh!
There was an error while loading. Please reload this page.