mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
wip: support for G835L
This commit is contained in:
@@ -146,6 +146,8 @@ impl AnimeDiagonal {
|
||||
match anime_type {
|
||||
AnimeType::GA401 => self.to_ga401_packets(),
|
||||
AnimeType::GU604 => self.to_gu604_packets(),
|
||||
AnimeType::G635L => self.to_g835l_packets(), // TODO: Verify with G635L model
|
||||
AnimeType::G835L => self.to_g835l_packets(),
|
||||
_ => self.to_ga402_packets(),
|
||||
}
|
||||
}
|
||||
@@ -382,47 +384,64 @@ impl AnimeDiagonal {
|
||||
AnimeDataBuffer::from_vec(crate::AnimeType::GA402, buf)
|
||||
}
|
||||
|
||||
// TODO: Implement `to_g635l_packets` and `to_g835l_packets` functions
|
||||
// fn to_g835l_packets(buf: &[u8]) -> Result<AnimeDataBuffer> {
|
||||
// let mut buf = vec![0u8; AnimeType::GU604.data_length()];
|
||||
/// G835L diagonal packing - inverted geometry (rows grow then constant)
|
||||
/// Triangle (rows 0-27): pairs grow from 1→14 LEDs
|
||||
/// Rectangle (rows 28-67): constant 15 LEDs
|
||||
fn to_g835l_packets(&self) -> Result<AnimeDataBuffer> {
|
||||
use log::debug;
|
||||
|
||||
// let mut start_index: usize = 0;
|
||||
let mut buf = vec![0u8; AnimeType::G835L.data_length()];
|
||||
let mut buf_idx = 0usize;
|
||||
|
||||
// fn copy_slice(
|
||||
// buf: &mut [u8],
|
||||
// anime: &AnimeDiagonal,
|
||||
// x: usize,
|
||||
// y: usize,
|
||||
// start_index: &mut usize,
|
||||
// len: usize,
|
||||
// ) {
|
||||
// buf[*start_index..*start_index + len].copy_from_slice(&anime.get_row(x, y, len));
|
||||
// *start_index += len;
|
||||
// }
|
||||
debug!(
|
||||
"G835L packing: image dimensions {}x{}, buffer size {}",
|
||||
self.1.first().map(|r| r.len()).unwrap_or(0),
|
||||
self.1.len(),
|
||||
buf.len()
|
||||
);
|
||||
|
||||
// let b = &mut buf;
|
||||
// let a = &self;
|
||||
// Helper: get row length for G835L
|
||||
fn row_length(row: usize) -> usize {
|
||||
if row < 28 {
|
||||
row / 2 + 1
|
||||
} else {
|
||||
15
|
||||
}
|
||||
}
|
||||
|
||||
// copy_slice(b, a, 40, 0, &mut start_index, 21);
|
||||
// copy_slice(b, a, 41, 0, &mut start_index, 21);
|
||||
// copy_slice(b, a, 42, 0, &mut start_index, 20);
|
||||
// copy_slice(b, a, 43, 0, &mut start_index, 20);
|
||||
// copy_slice(b, a, 44, 0, &mut start_index, 19);
|
||||
// copy_slice(b, a, 45, 0, &mut start_index, 19);
|
||||
// copy_slice(b, a, 46, 0, &mut start_index, 18);
|
||||
// copy_slice(b, a, 47, 0, &mut start_index, 18);
|
||||
// copy_slice(b, a, 48, 0, &mut start_index, 17);
|
||||
// copy_slice(b, a, 49, 0, &mut start_index, 17);
|
||||
// copy_slice(b, a, 50, 0, &mut start_index, 16);
|
||||
// copy_slice(b, a, 51, 0, &mut start_index, 16);
|
||||
// copy_slice(b, a, 52, 0, &mut start_index, 15);
|
||||
// copy_slice(b, a, 53, 0, &mut start_index, 15);
|
||||
// copy_slice(b, a, 54, 0, &mut start_index, 14);
|
||||
// copy_slice(b, a, 55, 0, &mut start_index, 14);
|
||||
// copy_slice(b, a, 56, 0, &mut start_index, 13);
|
||||
// copy_slice(b, a, 57, 0, &mut start_index, 13);
|
||||
// copy_slice(b, a, 58, 0, &mut start_index, 12);
|
||||
// Process all 68 rows
|
||||
for row in 0..68 {
|
||||
let len = row_length(row);
|
||||
|
||||
// AnimeDataBuffer::from_vec(crate::AnimeType::G835L, buf)
|
||||
// }
|
||||
for i in 0..len {
|
||||
// Simple horizontal reading for now - each row pair reads from same image row
|
||||
// Row 0,1 → img row 0; Row 2,3 → img row 1; etc.
|
||||
let img_y = row / 2;
|
||||
let img_x = i;
|
||||
|
||||
// Read from image, clamp to bounds
|
||||
let val = if img_y < self.1.len() && img_x < self.1[img_y].len() {
|
||||
self.1[img_y][img_x]
|
||||
} else {
|
||||
0
|
||||
};
|
||||
|
||||
// Log first LED of each row for debugging
|
||||
if i == 0 {
|
||||
debug!(
|
||||
"Row {}: len={}, first LED at img[{}][{}] = {}",
|
||||
row, len, img_y, img_x, val
|
||||
);
|
||||
}
|
||||
|
||||
if buf_idx < buf.len() {
|
||||
buf[buf_idx] = val;
|
||||
}
|
||||
buf_idx += 1;
|
||||
}
|
||||
}
|
||||
|
||||
debug!("G835L packing complete: {} bytes written", buf_idx);
|
||||
AnimeDataBuffer::from_vec(AnimeType::G835L, buf)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user