Skip to content

Commit 0424c81

Browse files
committed
rgbkbd: Send unlimited number of LEDs with multiple HCs
Signed-off-by: Daniel Schaefer <[email protected]>
1 parent 9324ad4 commit 0424c81

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

framework_lib/src/chromium_ec/mod.rs

+11-9
Original file line numberDiff line numberDiff line change
@@ -923,17 +923,19 @@ impl CrosEc {
923923
}
924924

925925
pub fn rgbkbd_set_color(&self, start_key: u8, colors: Vec<RgbS>) -> EcResult<()> {
926-
let mut request = EcRequestRgbKbdSetColor {
927-
start_key,
928-
length: colors.len() as u8,
929-
color: [(); EC_RGBKBD_MAX_KEY_COUNT].map(|()| Default::default()),
930-
};
926+
for (chunk, colors) in colors.chunks(EC_RGBKBD_MAX_KEY_COUNT).enumerate() {
927+
let mut request = EcRequestRgbKbdSetColor {
928+
start_key: start_key + ((chunk * EC_RGBKBD_MAX_KEY_COUNT) as u8),
929+
length: colors.len() as u8,
930+
color: [(); EC_RGBKBD_MAX_KEY_COUNT].map(|()| Default::default()),
931+
};
931932

932-
for (i, color) in colors.iter().enumerate() {
933-
request.color[i] = *color;
934-
}
933+
for (i, color) in colors.iter().enumerate() {
934+
request.color[i] = *color;
935+
}
935936

936-
let _res = request.send_command(self)?;
937+
let _res = request.send_command(self)?;
938+
}
937939
Ok(())
938940
}
939941
}

framework_lib/src/commandline/clap_std.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
use clap::Parser;
55
use clap_num::maybe_hex;
66

7-
use crate::chromium_ec::commands::EC_RGBKBD_MAX_KEY_COUNT;
87
use crate::chromium_ec::CrosEcDriverType;
98
use crate::commandline::{
109
Cli, ConsoleArg, FpBrightnessArg, HardwareDeviceType, InputDeckModeArg, RebootEcArg,
@@ -154,7 +153,7 @@ struct ClapCli {
154153
/// Set the color of <key> to <RGB>. Multiple colors for adjacent keys can be set at once.
155154
/// <key> <RGB> [<RGB> ...]
156155
/// Example: 0 0xFF000 0x00FF00 0x0000FF
157-
#[clap(num_args = 2..EC_RGBKBD_MAX_KEY_COUNT)]
156+
#[clap(num_args = 2..)]
158157
#[arg(long, value_parser=maybe_hex::<u64>)]
159158
rgbkbd: Vec<u64>,
160159

0 commit comments

Comments
 (0)