animatrix simulator for ga402

This commit is contained in:
Luke D. Jones
2023-06-24 19:00:25 +12:00
parent 4611c08085
commit d3aababef5
5 changed files with 128 additions and 38 deletions

View File

@@ -1,14 +1,31 @@
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),
pub const GA401: [Row; 27] = [
Row(0x01, 7, 34, 0),
Row(0x01, 7 + 34, 34, 0),
Row(0x01, 7 + 34 * 2, 34, 0),
Row(0x01, 7 + 34 * 3, 34, 0),
Row(0x01, 7 + 34 * 4, 34, 0),
Row(0x01, 7 + 34 * 5, 34, 0),
Row(0x01, 7 + 34 * 6, 34, 0),
Row(0x01, 7 + 34 * 7, 34, 0),
Row(0x01, 7 + 34 * 8, 34, 0),
Row(0x01, 7 + 34 * 9, 34, 0),
Row(0x01, 7 + 34 * 10, 34, 0),
Row(0x01, 7 + 34 * 11, 34, 0),
Row(0x01, 7 + 34 * 12, 34, 0),
Row(0x01, 7 + 34 * 13, 34, 0),
Row(0x01, 7 + 34 * 14, 34, 0),
Row(0x01, 7 + 34 * 15, 34, 0),
Row(0x01, 7 + 34 * 16, 34, 0),
Row(0x74, 7, 34, 0),
Row(0x74, 7 + 34, 34, 0),
Row(0x74, 7 + 34 * 2, 34, 0),
Row(0x74, 7 + 34 * 3, 34, 0),
Row(0x74, 7 + 34 * 4, 34, 0),
Row(0x74, 7 + 34 * 5, 34, 0),
Row(0x74, 7 + 34 * 6, 34, 0),
Row(0x74, 7 + 34 * 7, 34, 0),
Row(0x74, 7 + 34 * 8, 34, 0),
Row(0x74, 7 + 34 * 9, 34, 0),
];

View File

@@ -1,15 +1,68 @@
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),
pub const GA402: [Row; 62] = [
Row(0x01, 7 + 1, 34, 0),
Row(0x01, 7 + 35, 34, 0),
Row(0x01, 7 + 69, 34, 0),
Row(0x01, 7 + 103, 34, 0),
Row(0x01, 7 + 137, 34, 0),
Row(0x01, 7 + 171, 34, 0),
Row(0x01, 7 + 205, 34, 0),
Row(0x01, 7 + 239, 34, 0),
Row(0x01, 7 + 273, 34, 0),
Row(0x01, 7 + 307, 34, 0),
Row(0x01, 7 + 341, 34, 0),
Row(0x01, 7 + 375, 34, 0), // 12
Row(0x01, 7 + 409, 33, 1),
Row(0x01, 7 + 442, 33, 2),
Row(0x01, 7 + 475, 32, 2),
Row(0x01, 7 + 507, 32, 3),
Row(0x01, 7 + 539, 31, 3), //
Row(0x01, 7 + 570, 31, 4),
Row(0x01, 7 + 601, 31, 4), //
//
Row(0x74, 7 + 1, 3, 31), // adds to end of previous
Row(0x74, 7 + 4, 30, 5),
Row(0x74, 7 + 34, 29, 6),
Row(0x74, 7 + 63, 29, 6),
Row(0x74, 7 + 92, 28, 7),
Row(0x74, 7 + 120, 28, 7),
Row(0x74, 7 + 148, 27, 8),
Row(0x74, 7 + 175, 27, 8),
Row(0x74, 7 + 202, 26, 9),
Row(0x74, 7 + 228, 26, 9),
Row(0x74, 7 + 254, 25, 10),
Row(0x74, 7 + 279, 25, 10),
Row(0x74, 7 + 304, 24, 11),
Row(0x74, 7 + 328, 24, 11),
Row(0x74, 7 + 352, 23, 12),
Row(0x74, 7 + 375, 23, 12),
Row(0x74, 7 + 398, 22, 13),
Row(0x74, 7 + 420, 22, 13),
Row(0x74, 7 + 442, 21, 14),
Row(0x74, 7 + 463, 21, 14),
Row(0x74, 7 + 484, 20, 15),
Row(0x74, 7 + 504, 20, 15),
Row(0x74, 7 + 524, 19, 16),
Row(0x74, 7 + 543, 19, 16),
Row(0x74, 7 + 562, 18, 17),
Row(0x74, 7 + 580, 18, 17),
Row(0x74, 7 + 598, 17, 18),
Row(0x74, 7 + 615, 13, 18),
//
Row(0xe7, 7 + 1, 4, 18 + 13), // adds to end of previous
Row(0xe7, 7 + 5, 16, 19),
Row(0xe7, 7 + 37, 15, 20),
Row(0xe7, 7 + 52, 15, 20),
Row(0xe7, 7 + 67, 14, 21),
Row(0xe7, 7 + 81, 14, 21), //
Row(0xe7, 7 + 95, 13, 22),
Row(0xe7, 7 + 108, 13, 22),
Row(0xe7, 7 + 121, 12, 23),
Row(0xe7, 7 + 133, 12, 23),
Row(0xe7, 7 + 145, 11, 24),
Row(0xe7, 7 + 156, 11, 24),
Row(0xe7, 7 + 167, 10, 25),
Row(0xe7, 7 + 177, 10, 25),
Row(0xe7, 7 + 187, 9, 26),
];

View File

@@ -1,14 +1,31 @@
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),
pub const GU604: [Row; 27] = [
Row(0x01, 7, 34, 0),
Row(0x01, 7 + 34, 34, 0),
Row(0x01, 7 + 34 * 2, 34, 0),
Row(0x01, 7 + 34 * 3, 34, 0),
Row(0x01, 7 + 34 * 4, 34, 0),
Row(0x01, 7 + 34 * 5, 34, 0),
Row(0x01, 7 + 34 * 6, 34, 0),
Row(0x01, 7 + 34 * 7, 34, 0),
Row(0x01, 7 + 34 * 8, 34, 0),
Row(0x01, 7 + 34 * 9, 34, 0),
Row(0x01, 7 + 34 * 10, 34, 0),
Row(0x01, 7 + 34 * 11, 34, 0),
Row(0x01, 7 + 34 * 12, 34, 0),
Row(0x01, 7 + 34 * 13, 34, 0),
Row(0x01, 7 + 34 * 14, 34, 0),
Row(0x01, 7 + 34 * 15, 34, 0),
Row(0x01, 7 + 34 * 16, 34, 0),
Row(0x74, 7, 34, 0),
Row(0x74, 7 + 34, 34, 0),
Row(0x74, 7 + 34 * 2, 34, 0),
Row(0x74, 7 + 34 * 3, 34, 0),
Row(0x74, 7 + 34 * 4, 34, 0),
Row(0x74, 7 + 34 * 5, 34, 0),
Row(0x74, 7 + 34 * 6, 34, 0),
Row(0x74, 7 + 34 * 7, 34, 0),
Row(0x74, 7 + 34 * 8, 34, 0),
Row(0x74, 7 + 34 * 9, 34, 0),
];

View File

@@ -23,6 +23,8 @@ pub struct Row(
pub usize,
/// The length to read inclusive
pub usize,
/// Offset to the right by how many LEDs
pub i32,
);
#[derive(Clone, Copy)]
@@ -47,7 +49,7 @@ impl AniMatrix {
},
Model::GA402 => LedShape {
vertical: 2,
horizontal: 3,
horizontal: 5,
},
Model::GU604 => LedShape {
vertical: 2,

View File

@@ -138,7 +138,7 @@ fn main() -> Result<(), Box<dyn Error>> {
let video_subsystem = sdl_context.video().unwrap();
let window = video_subsystem
.window("rust-sdl2 demo", 800, 600)
.window("rust-sdl2 demo", 1000, 800)
.position_centered()
.build()
.unwrap();
@@ -162,11 +162,12 @@ fn main() -> Result<(), Box<dyn Error>> {
if row.0 == index {
let start = row.1;
let end = start + row.2;
for (x_count, b) in dev.buffer[start..end].iter().enumerate() {
for (x_count, b) in dev.buffer[start..=end].iter().enumerate() {
print!("{b},");
canvas.set_draw_color(Color::RGB(*b as u8, *b as u8, *b as u8));
let x = x_count as i32 * w - if y_count % 2 == 0 { 0 } else { w / 2 };
let x =
x_count as i32 * w - if y_count % 2 == 0 { 0 } else { w / 2 } + row.3 * w;
let y = y_count as i32 * h;
canvas
.fill_rect(Rect::new(x, y, w as u32, h as u32))