1
0
mirror of https://github.com/4yn/slidershim.git synced 2024-11-24 05:50:12 +01:00

tasoller and dasi side leds

This commit is contained in:
4yn 2022-07-24 23:24:36 +08:00
parent 121aeadbd8
commit 9bb2f9da74
2 changed files with 25 additions and 2 deletions

View File

@ -153,7 +153,20 @@ impl HidJob {
buf_chunk[1] = state_chunk[0];
buf_chunk[2] = state_chunk[2];
}
buf.data[96..240].fill(0);
for (buf_chunks, state_chunk) in buf.data[96..240].chunks_mut(24).zip(
lights
.air_left
.chunks(3)
.rev()
.chain(lights.air_right.chunks(3)),
) {
for idx in 0..8 {
buf_chunks[0 + idx * 3] = state_chunk[1];
buf_chunks[1 + idx * 3] = state_chunk[0];
buf_chunks[2 + idx * 3] = state_chunk[2];
}
}
},
),
HardwareSpec::Yuancon => Self::new(
@ -213,12 +226,14 @@ impl HidJob {
WriteType::Interrupt,
|buf, lights| {
buf.len = 62;
let air_color = lights.get_air_middle();
let lights_nibbles: Vec<u8> = lights
.ground
.chunks(3)
.rev()
.flat_map(|x| x.iter().map(|y| *y >> 4))
.chain([0, 0, 0])
.chain([air_color[0] >> 4, air_color[1] >> 4, air_color[2] >> 4])
.collect();
for (buf_chunk, state_chunk) in buf

View File

@ -102,6 +102,14 @@ impl SliderLights {
self.air_right[3 * idx..3 * (idx + 1)].copy_from_slice(color);
}
pub fn get_air_middle(&self) -> [u8; 3] {
return [
((self.air_left[3] as u16 + self.air_right[3] as u16) / 2) as u8,
((self.air_left[4] as u16 + self.air_right[4] as u16) / 2) as u8,
((self.air_left[5] as u16 + self.air_right[5] as u16) / 2) as u8,
];
}
pub fn reset(&mut self) {
self.ground.fill(0);
self.air_left.fill(0);