From 3d6d92ae7d9e2db05b578eb17c5b62245f48ec9a Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Sun, 25 Jun 2023 16:27:09 +1200 Subject: [PATCH] Animatrix: gu604 sim --- CHANGELOG.md | 2 + asusd/src/ctrl_anime/config.rs | 2 + asusd/src/ctrl_anime/mod.rs | 7 ++- rog-anime/src/usb.rs | 4 +- rog-platform/src/hid_raw.rs | 5 +- simulators/src/animatrix/map_gu604.rs | 82 +++++++++++++++------------ simulators/src/animatrix/mod.rs | 4 +- simulators/src/simulator.rs | 38 +++---------- 8 files changed, 71 insertions(+), 73 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a18476f8..4ddfac37 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Pixel gifs - Power options - 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 - 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 diff --git a/asusd/src/ctrl_anime/config.rs b/asusd/src/ctrl_anime/config.rs index 72c77783..a2dcf2a5 100644 --- a/asusd/src/ctrl_anime/config.rs +++ b/asusd/src/ctrl_anime/config.rs @@ -107,6 +107,7 @@ impl AnimeConfigCached { /// Config for base system actions for the anime display #[derive(Deserialize, Serialize, Debug)] pub struct AnimeConfig { + pub model_override: Option, pub system: Vec, pub boot: Vec, pub wake: Vec, @@ -122,6 +123,7 @@ pub struct AnimeConfig { impl Default for AnimeConfig { fn default() -> Self { AnimeConfig { + model_override: None, system: Vec::new(), boot: Vec::new(), wake: Vec::new(), diff --git a/asusd/src/ctrl_anime/mod.rs b/asusd/src/ctrl_anime/mod.rs index dd02f53e..cca0520c 100644 --- a/asusd/src/ctrl_anime/mod.rs +++ b/asusd/src/ctrl_anime/mod.rs @@ -74,7 +74,12 @@ impl CtrlAnime { 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:?}"); let mut cache = AnimeConfigCached::default(); diff --git a/rog-anime/src/usb.rs b/rog-anime/src/usb.rs index 598b903b..1a2f1f22 100644 --- a/rog-anime/src/usb.rs +++ b/rog-anime/src/usb.rs @@ -155,8 +155,8 @@ pub fn get_anime_type() -> Result { } else if board_name.contains("GU604V") { return Ok(AnimeType::GU604); } - log::warn!("AniMe Matrix device found but not yet supported"); - Ok(AnimeType::Unknown) + log::warn!("AniMe Matrix device found but not yet supported, will default to a GA402 layout"); + Ok(AnimeType::GA402) } /// Get the two device initialization packets. These are required for device diff --git a/rog-platform/src/hid_raw.rs b/rog-platform/src/hid_raw.rs index 1ca2bb02..44d8b758 100644 --- a/rog-platform/src/hid_raw.rs +++ b/rog-platform/src/hid_raw.rs @@ -44,7 +44,10 @@ impl HidRaw { let dev_path = device.devpath().to_string_lossy(); if dev_path.contains("virtual") && dev_path.contains(&id_product.to_uppercase()) { if let Some(dev_node) = device.devnode() { - info!("Using device at: {:?} for asdfgsadfgh control", dev_node); + info!( + "Using device at: {:?} for control", + dev_node + ); return Ok(Self(dev_node.to_owned())); } } diff --git a/simulators/src/animatrix/map_gu604.rs b/simulators/src/animatrix/map_gu604.rs index 25dc1b0c..e96b349d 100644 --- a/simulators/src/animatrix/map_gu604.rs +++ b/simulators/src/animatrix/map_gu604.rs @@ -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), ]; diff --git a/simulators/src/animatrix/mod.rs b/simulators/src/animatrix/mod.rs index c5c464d9..e9f529b4 100644 --- a/simulators/src/animatrix/mod.rs +++ b/simulators/src/animatrix/mod.rs @@ -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, }, }; diff --git a/simulators/src/simulator.rs b/simulators/src/simulator.rs index 44527298..b5bc2947 100644 --- a/simulators/src/simulator.rs +++ b/simulators/src/simulator.rs @@ -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, 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> { 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> { 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 {