Add the missing dirs, dumbarse

This commit is contained in:
Luke D. Jones
2023-06-24 13:15:11 +12:00
parent 0a008a653a
commit 4611c08085
31 changed files with 4954 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
use super::Row;
pub const GA401: [Row; 10] = [
Row(0x01, 7, 34),
Row(0x01, 7 + 34, 34),
Row(0x01, 7 + 34 * 2, 34),
Row(0x01, 7 + 34 * 3, 34),
Row(0x01, 7 + 34 * 4, 34),
Row(0x01, 7 + 34 * 5, 34),
Row(0x01, 7 + 34 * 6, 34),
Row(0x01, 7 + 34 * 7, 34),
Row(0x01, 7 + 34 * 8, 34),
Row(0x01, 7 + 34 * 9, 34),
];

View File

@@ -0,0 +1,15 @@
use super::Row;
pub const GA402: [Row; 11] = [
Row(0x01, 7, 34),
Row(0x01, 7 + 34, 34),
Row(0x01, 7 + 34 * 2, 34),
Row(0x01, 7 + 34 * 3, 34),
Row(0x01, 7 + 34 * 4, 34),
Row(0x01, 7 + 34 * 5, 34),
Row(0x01, 7 + 34 * 6, 34),
Row(0x01, 7 + 34 * 7, 34),
Row(0x01, 7 + 34 * 8, 34),
Row(0x01, 7 + 34 * 9, 34),
Row(0x01, 7 + 34 * 10, 34),
];

View File

@@ -0,0 +1,14 @@
use super::Row;
pub const GU604: [Row; 10] = [
Row(0x01, 7, 34),
Row(0x01, 7 + 34, 34),
Row(0x01, 7 + 34 * 2, 34),
Row(0x01, 7 + 34 * 3, 34),
Row(0x01, 7 + 34 * 4, 34),
Row(0x01, 7 + 34 * 5, 34),
Row(0x01, 7 + 34 * 6, 34),
Row(0x01, 7 + 34 * 7, 34),
Row(0x01, 7 + 34 * 8, 34),
Row(0x01, 7 + 34 * 9, 34),
];

View File

@@ -0,0 +1,75 @@
use self::map_ga401::GA401;
use self::map_ga402::GA402;
use self::map_gu604::GU604;
mod map_ga401;
mod map_ga402;
mod map_gu604;
pub enum Model {
GA401,
GA402,
GU604,
}
#[derive(Clone, Copy)]
pub struct Row(
/// The USB packet index, this is mapped to the 4th byte (idx = 3) and is
/// one of (in order of packets): 1. `0x01`
/// 2. `0x74`
/// 3. `0xe7`
pub u8,
/// Starting index in that packet
pub usize,
/// The length to read inclusive
pub usize,
);
#[derive(Clone, Copy)]
pub struct LedShape {
/// Vertical offset from center for the top/bottom points
pub vertical: i32,
/// Horizontal offset from center for the top/bottom points
pub horizontal: i32,
}
pub struct AniMatrix {
rows: Vec<Row>,
led_shape: LedShape,
}
impl AniMatrix {
pub fn new(model: Model) -> Self {
let led_shape = match model {
Model::GA401 => LedShape {
vertical: 2,
horizontal: 3,
},
Model::GA402 => LedShape {
vertical: 2,
horizontal: 3,
},
Model::GU604 => LedShape {
vertical: 2,
horizontal: 3,
},
};
// Do a hard mapping of each (derived from wireshardk captures)
let rows = match model {
Model::GA401 => GA401.to_vec(),
Model::GA402 => GA402.to_vec(),
Model::GU604 => GU604.to_vec(),
};
Self { rows, led_shape }
}
pub fn rows(&self) -> &[Row] {
&self.rows
}
pub fn led_shape(&self) -> LedShape {
self.led_shape
}
}