Animatrix: gu604 sim

This commit is contained in:
Luke D. Jones
2023-06-25 16:27:09 +12:00
parent 55723b7b77
commit 3d6d92ae7d
8 changed files with 71 additions and 73 deletions

View File

@@ -1,60 +1,70 @@
use super::Row;
pub const GU604: [Row; 54] = [
Row(0x01, 7, 37, 0),
pub const GU604: [Row; 64] = [
Row(0x01, 7, 37, 1),
Row(0x01, 7 + 38, 39, 0),
Row(0x01, 7 + 77, 38, 0),
Row(0x01, 7 + 115, 39, 0), // 34 len
Row(0x01, 7 + 154, 38, 0),
Row(0x01, 7 + 77, 38, 1),
Row(0x01, 7 + 115, 39, 0),
Row(0x01, 7 + 154, 38, 1),
Row(0x01, 7 + 192, 39, 0),
Row(0x01, 7 + 231, 38, 0),
Row(0x01, 7 + 231, 38, 1),
Row(0x01, 7 + 269, 39, 0),
Row(0x01, 7 + 308, 38, 0),
Row(0x01, 7 + 308, 38, 1),
Row(0x01, 7 + 346, 39, 0),
Row(0x01, 7 + 385, 38, 0),
Row(0x01, 7 + 423, 38, 0),
Row(0x01, 7 + 461, 37, 1),
Row(0x01, 7 + 535, 36, 1),
Row(0x01, 7 + 571, 36, 2),
Row(0x01, 7 + 607, 21, 2), // needs join
Row(0x01, 7 + 385, 38, 1),
Row(0x01, 7 + 423, 38, 1),
Row(0x01, 7 + 461, 37, 2),
Row(0x01, 7 + 498, 37, 2),
Row(0x01, 7 + 535, 36, 3),
Row(0x01, 7 + 571, 36, 3),
Row(0x01, 7 + 607, 21, 4), // needs join
//
Row(0x74, 7, 14, 28), // adds to end of previous
Row(0x74, 7, 14, 24), // adds to end of previous
Row(0x74, 7 + 15, 35, 4),
Row(0x74, 7 + 50, 34, 5),
Row(0x74, 7 + 84, 34, 5),
Row(0x74, 7 + 118, 33, 6),
Row(0x74, 7 + 151, 33, 6),
Row(0x74, 7 + 184, 32, 7),
Row(0x74, 7 + 216, 32, 7), //
Row(0x74, 7 + 248, 31, 9),
Row(0x74, 7 + 279, 31, 9),
Row(0x74, 7 + 310, 30, 10),
Row(0x74, 7 + 340, 30, 9), // WEIRD OFFSET
Row(0x74, 7 + 216, 32, 7),
Row(0x74, 7 + 248, 31, 8),
Row(0x74, 7 + 279, 31, 8),
Row(0x74, 7 + 310, 30, 9),
Row(0x74, 7 + 340, 30, 9),
Row(0x74, 7 + 370, 29, 10),
Row(0x74, 7 + 399, 29, 10),
Row(0x74, 7 + 428, 28, 11),
Row(0x74, 7 + 456, 28, 11),
Row(0x74, 7 + 484, 27, 12),
Row(0x74, 7 + 512, 27, 12),
Row(0x74, 7 + 511, 27, 12),
Row(0x74, 7 + 538, 26, 13),
Row(0x74, 7 + 564, 26, 13),
Row(0x74, 7 + 590, 25, 14),
Row(0x74, 7 + 615, 12, 14), // needs join
//
Row(0xe7, 7, 13, 13 + 18), // adds to end of previous
Row(0xe7, 7 + 4, 16, 18),
Row(0xe7, 7 + 20, 16, 18),
Row(0xe7, 7 + 36, 15, 19),
Row(0xe7, 7 + 51, 15, 19),
Row(0xe7, 7 + 66, 14, 20),
Row(0xe7, 7 + 80, 12, 20), // too long? 14
Row(0xe7, 7 + 94, 13, 21),
Row(0xe7, 7 + 107, 13, 21),
Row(0xe7, 7 + 120, 12, 12), // Actual display end
Row(0xe7, 7 + 132, 12, 22),
Row(0xe7, 7 + 144, 11, 23),
Row(0xe7, 7 + 155, 11, 23),
Row(0xe7, 7 + 166, 10, 24),
Row(0xe7, 7 + 176, 10, 24),
Row(0xe7, 7 + 186, 9, 25),
Row(0xe7, 7, 12, 25), // adds to end of previous
Row(0xe7, 7 + 13, 24, 15),
Row(0xe7, 7 + 37, 24, 15),
Row(0xe7, 7 + 61, 23, 16),
Row(0xe7, 7 + 84, 23, 16),
Row(0xe7, 7 + 107, 22, 17),
Row(0xe7, 7 + 129, 22, 17),
Row(0xe7, 7 + 151, 21, 18),
Row(0xe7, 7 + 172, 21, 18),
Row(0xe7, 7 + 193, 20, 19),
Row(0xe7, 7 + 213, 20, 19),
Row(0xe7, 7 + 233, 19, 20),
Row(0xe7, 7 + 252, 19, 20),
Row(0xe7, 7 + 271, 18, 21),
Row(0xe7, 7 + 289, 18, 21),
Row(0xe7, 7 + 307, 17, 22),
Row(0xe7, 7 + 324, 17, 22),
Row(0xe7, 7 + 341, 16, 23),
Row(0xe7, 7 + 357, 16, 23),
Row(0xe7, 7 + 373, 15, 24),
Row(0xe7, 7 + 388, 15, 24),
Row(0xe7, 7 + 403, 14, 25),
Row(0xe7, 7 + 417, 14, 25),
Row(0xe7, 7 + 431, 13, 26),
Row(0xe7, 7 + 444, 13, 26),
];

View File

@@ -45,7 +45,7 @@ impl AniMatrix {
let led_shape = match model {
Model::GA401 => LedShape {
vertical: 2,
horizontal: 3,
horizontal: 5,
},
Model::GA402 => LedShape {
vertical: 2,
@@ -53,7 +53,7 @@ impl AniMatrix {
},
Model::GU604 => LedShape {
vertical: 2,
horizontal: 3,
horizontal: 5,
},
};

View File

@@ -1,5 +1,4 @@
use std::error::Error;
use std::time::Instant;
use log::error;
use rog_anime::usb::{PROD_ID, VENDOR_ID};
@@ -16,14 +15,12 @@ use animatrix::*;
pub struct VirtAnimeMatrix {
device: UHIDDevice<std::fs::File>,
buffer: [u8; 640],
time: Instant,
animatrix: AniMatrix,
}
impl VirtAnimeMatrix {
pub fn new(model: Model) -> Self {
VirtAnimeMatrix {
time: Instant::now(),
buffer: [0; 640],
animatrix: AniMatrix::new(model),
device: UHIDDevice::create(CreateParams {
@@ -101,33 +98,12 @@ impl VirtAnimeMatrix {
// }
pub fn read(&mut self) {
if let Ok(event) = self.device.read() {
match event {
// uhid_virt::OutputEvent::Start { dev_flags } => todo!(),
// uhid_virt::OutputEvent::Stop => todo!(),
// uhid_virt::OutputEvent::Open => todo!(),
// uhid_virt::OutputEvent::Close => todo!(),
uhid_virt::OutputEvent::Output { data } => {
for (i, b) in self.buffer.iter_mut().enumerate() {
*b = 0;
if let Some(n) = data.get(i) {
*b = *n;
}
}
let now = Instant::now();
dbg!(now - self.time);
self.time = Instant::now();
if let Ok(uhid_virt::OutputEvent::Output { data }) = self.device.read() {
for (i, b) in self.buffer.iter_mut().enumerate() {
*b = 0;
if let Some(n) = data.get(i) {
*b = *n;
}
uhid_virt::OutputEvent::GetReport {
id,
report_number,
report_type,
} => {
dbg!(id, report_number, report_type);
}
// uhid_virt::OutputEvent::SetReport { id, report_number, report_type, data } =>
// todo!(),
_ => {}
}
}
}
@@ -138,7 +114,7 @@ fn main() -> Result<(), Box<dyn Error>> {
let video_subsystem = sdl_context.video().unwrap();
let window = video_subsystem
.window("rust-sdl2 demo", 1040, 680)
.window("rust-sdl2 demo", 1260, 760)
.position_centered()
.build()
.unwrap();
@@ -163,7 +139,7 @@ fn main() -> Result<(), Box<dyn Error>> {
if row.0 == index {
let start = row.1;
let end = start + row.2;
if row.2 < 8 {
if row.1 < 10 && row.2 < 15 {
if index == 0x74 {
y_offset = 1;
} else if index == 0xe7 {