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

@@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Pixel gifs - Pixel gifs
- Power options - Power options
- Builtin animations - Builtin animations
- In-progress simulators for GA402, GU604 animatrix
- Add `model_override` option to anime config, this is handy for forcing a model for "Unknown" anime, and for simulators
### Changed ### Changed
- Move FX506HC to FX506H in arua DB to catch full series of this range - Move FX506HC to FX506H in arua DB to catch full series of this range
- Move FX506LH to FX506L in arua DB to catch full series of this range - Move FX506LH to FX506L in arua DB to catch full series of this range

View File

@@ -107,6 +107,7 @@ impl AnimeConfigCached {
/// Config for base system actions for the anime display /// Config for base system actions for the anime display
#[derive(Deserialize, Serialize, Debug)] #[derive(Deserialize, Serialize, Debug)]
pub struct AnimeConfig { pub struct AnimeConfig {
pub model_override: Option<AnimeType>,
pub system: Vec<ActionLoader>, pub system: Vec<ActionLoader>,
pub boot: Vec<ActionLoader>, pub boot: Vec<ActionLoader>,
pub wake: Vec<ActionLoader>, pub wake: Vec<ActionLoader>,
@@ -122,6 +123,7 @@ pub struct AnimeConfig {
impl Default for AnimeConfig { impl Default for AnimeConfig {
fn default() -> Self { fn default() -> Self {
AnimeConfig { AnimeConfig {
model_override: None,
system: Vec::new(), system: Vec::new(),
boot: Vec::new(), boot: Vec::new(),
wake: Vec::new(), wake: Vec::new(),

View File

@@ -74,7 +74,12 @@ impl CtrlAnime {
return Err(RogError::Anime(AnimeError::NoDevice)); return Err(RogError::Anime(AnimeError::NoDevice));
}; };
let anime_type = get_anime_type().unwrap_or(AnimeType::GA402); let mut anime_type = get_anime_type()?;
if let AnimeType::Unknown = anime_type {
if let Some(model) = config.model_override {
anime_type = model;
}
}
info!("Device has an AniMe Matrix display: {anime_type:?}"); info!("Device has an AniMe Matrix display: {anime_type:?}");
let mut cache = AnimeConfigCached::default(); let mut cache = AnimeConfigCached::default();

View File

@@ -155,8 +155,8 @@ pub fn get_anime_type() -> Result<AnimeType, AnimeError> {
} else if board_name.contains("GU604V") { } else if board_name.contains("GU604V") {
return Ok(AnimeType::GU604); return Ok(AnimeType::GU604);
} }
log::warn!("AniMe Matrix device found but not yet supported"); log::warn!("AniMe Matrix device found but not yet supported, will default to a GA402 layout");
Ok(AnimeType::Unknown) Ok(AnimeType::GA402)
} }
/// Get the two device initialization packets. These are required for device /// Get the two device initialization packets. These are required for device

View File

@@ -44,7 +44,10 @@ impl HidRaw {
let dev_path = device.devpath().to_string_lossy(); let dev_path = device.devpath().to_string_lossy();
if dev_path.contains("virtual") && dev_path.contains(&id_product.to_uppercase()) { if dev_path.contains("virtual") && dev_path.contains(&id_product.to_uppercase()) {
if let Some(dev_node) = device.devnode() { if let Some(dev_node) = device.devnode() {
info!("Using device at: {:?} for asdfgsadfgh control", dev_node); info!(
"Using device at: {:?} for <TODO: label control> control",
dev_node
);
return Ok(Self(dev_node.to_owned())); return Ok(Self(dev_node.to_owned()));
} }
} }

View File

@@ -1,60 +1,70 @@
use super::Row; use super::Row;
pub const GU604: [Row; 54] = [ pub const GU604: [Row; 64] = [
Row(0x01, 7, 37, 0), Row(0x01, 7, 37, 1),
Row(0x01, 7 + 38, 39, 0), Row(0x01, 7 + 38, 39, 0),
Row(0x01, 7 + 77, 38, 0), Row(0x01, 7 + 77, 38, 1),
Row(0x01, 7 + 115, 39, 0), // 34 len Row(0x01, 7 + 115, 39, 0),
Row(0x01, 7 + 154, 38, 0), Row(0x01, 7 + 154, 38, 1),
Row(0x01, 7 + 192, 39, 0), 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 + 269, 39, 0),
Row(0x01, 7 + 308, 38, 0), Row(0x01, 7 + 308, 38, 1),
Row(0x01, 7 + 346, 39, 0), Row(0x01, 7 + 346, 39, 0),
Row(0x01, 7 + 385, 38, 0), Row(0x01, 7 + 385, 38, 1),
Row(0x01, 7 + 423, 38, 0), Row(0x01, 7 + 423, 38, 1),
Row(0x01, 7 + 461, 37, 1), Row(0x01, 7 + 461, 37, 2),
Row(0x01, 7 + 535, 36, 1), Row(0x01, 7 + 498, 37, 2),
Row(0x01, 7 + 571, 36, 2), Row(0x01, 7 + 535, 36, 3),
Row(0x01, 7 + 607, 21, 2), // needs join 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 + 15, 35, 4),
Row(0x74, 7 + 50, 34, 5), Row(0x74, 7 + 50, 34, 5),
Row(0x74, 7 + 84, 34, 5), Row(0x74, 7 + 84, 34, 5),
Row(0x74, 7 + 118, 33, 6), Row(0x74, 7 + 118, 33, 6),
Row(0x74, 7 + 151, 33, 6), Row(0x74, 7 + 151, 33, 6),
Row(0x74, 7 + 184, 32, 7), Row(0x74, 7 + 184, 32, 7),
Row(0x74, 7 + 216, 32, 7), // Row(0x74, 7 + 216, 32, 7),
Row(0x74, 7 + 248, 31, 9), Row(0x74, 7 + 248, 31, 8),
Row(0x74, 7 + 279, 31, 9), Row(0x74, 7 + 279, 31, 8),
Row(0x74, 7 + 310, 30, 10), Row(0x74, 7 + 310, 30, 9),
Row(0x74, 7 + 340, 30, 9), // WEIRD OFFSET Row(0x74, 7 + 340, 30, 9),
Row(0x74, 7 + 370, 29, 10), Row(0x74, 7 + 370, 29, 10),
Row(0x74, 7 + 399, 29, 10), Row(0x74, 7 + 399, 29, 10),
Row(0x74, 7 + 428, 28, 11), Row(0x74, 7 + 428, 28, 11),
Row(0x74, 7 + 456, 28, 11), Row(0x74, 7 + 456, 28, 11),
Row(0x74, 7 + 484, 27, 12), 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 + 538, 26, 13),
Row(0x74, 7 + 564, 26, 13), Row(0x74, 7 + 564, 26, 13),
Row(0x74, 7 + 590, 25, 14), Row(0x74, 7 + 590, 25, 14),
Row(0x74, 7 + 615, 12, 14), // needs join Row(0x74, 7 + 615, 12, 14), // needs join
// //
Row(0xe7, 7, 13, 13 + 18), // adds to end of previous Row(0xe7, 7, 12, 25), // adds to end of previous
Row(0xe7, 7 + 4, 16, 18), Row(0xe7, 7 + 13, 24, 15),
Row(0xe7, 7 + 20, 16, 18), Row(0xe7, 7 + 37, 24, 15),
Row(0xe7, 7 + 36, 15, 19), Row(0xe7, 7 + 61, 23, 16),
Row(0xe7, 7 + 51, 15, 19), Row(0xe7, 7 + 84, 23, 16),
Row(0xe7, 7 + 66, 14, 20), Row(0xe7, 7 + 107, 22, 17),
Row(0xe7, 7 + 80, 12, 20), // too long? 14 Row(0xe7, 7 + 129, 22, 17),
Row(0xe7, 7 + 94, 13, 21), Row(0xe7, 7 + 151, 21, 18),
Row(0xe7, 7 + 107, 13, 21), Row(0xe7, 7 + 172, 21, 18),
Row(0xe7, 7 + 120, 12, 12), // Actual display end Row(0xe7, 7 + 193, 20, 19),
Row(0xe7, 7 + 132, 12, 22), Row(0xe7, 7 + 213, 20, 19),
Row(0xe7, 7 + 144, 11, 23), Row(0xe7, 7 + 233, 19, 20),
Row(0xe7, 7 + 155, 11, 23), Row(0xe7, 7 + 252, 19, 20),
Row(0xe7, 7 + 166, 10, 24), Row(0xe7, 7 + 271, 18, 21),
Row(0xe7, 7 + 176, 10, 24), Row(0xe7, 7 + 289, 18, 21),
Row(0xe7, 7 + 186, 9, 25), 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 { let led_shape = match model {
Model::GA401 => LedShape { Model::GA401 => LedShape {
vertical: 2, vertical: 2,
horizontal: 3, horizontal: 5,
}, },
Model::GA402 => LedShape { Model::GA402 => LedShape {
vertical: 2, vertical: 2,
@@ -53,7 +53,7 @@ impl AniMatrix {
}, },
Model::GU604 => LedShape { Model::GU604 => LedShape {
vertical: 2, vertical: 2,
horizontal: 3, horizontal: 5,
}, },
}; };

View File

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