From 8e98aafdddec9d40f2e6fd337ddfd8757698fc32 Mon Sep 17 00:00:00 2001 From: Luke Date: Tue, 2 Jun 2020 20:14:32 +1200 Subject: [PATCH] Finalise anime matrix stuff. Many fixes --- CHANGELOG.md | 2 +- Cargo.lock | 4 ++-- aura/Cargo.toml | 2 +- aura/examples/animatrix.rs | 14 ++++---------- aura/examples/comet.rs | 1 + aura/src/animatrix_dbus.rs | 22 ++++++++++++++++++---- aura/src/aura_dbus.rs | 4 ++-- debian/changelog | 7 +++++++ rog-core/Cargo.toml | 2 +- rog-core/src/animatrix_control.rs | 10 +++++----- rog-core/src/daemon.rs | 6 +++--- rog-core/src/main.rs | 2 +- 12 files changed, 46 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b7377f1..5402a3fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -## [0.9.9] - 2020-23-05 +## [0.10.0] - 2020-23-05 ### Changed - Correctly set AMD boost - Add animatrix support for G14 laptops diff --git a/Cargo.lock b/Cargo.lock index 1a6ea2a5..31989d87 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -673,7 +673,7 @@ checksum = "cabe4fa914dec5870285fa7f71f602645da47c486e68486d2b4ceb4a343e90ac" [[package]] name = "rog-aura" -version = "0.9.3" +version = "0.10.0" dependencies = [ "dbus", "gumdrop", @@ -684,7 +684,7 @@ dependencies = [ [[package]] name = "rog-daemon" -version = "0.9.9" +version = "0.10.0" dependencies = [ "dbus", "dbus-tokio", diff --git a/aura/Cargo.toml b/aura/Cargo.toml index e125992b..95f418e8 100644 --- a/aura/Cargo.toml +++ b/aura/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rog-aura" -version = "0.9.3" +version = "0.10.0" license = "MPL-2.0" readme = "README.md" authors = ["Luke "] diff --git a/aura/examples/animatrix.rs b/aura/examples/animatrix.rs index 4d82a491..d242cb68 100644 --- a/aura/examples/animatrix.rs +++ b/aura/examples/animatrix.rs @@ -1,18 +1,12 @@ -use rog_aura::AnimatrixDbusWriter; - -const PANE1_PREFIX: [u8; 7] = [0x5e, 0xc0, 0x02, 0x01, 0x00, 0x73, 0x02]; -const PANE2_PREFIX: [u8; 7] = [0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02]; +use rog_aura::AniMeDbusWriter; fn main() { - let mut writer = AnimatrixDbusWriter::new().unwrap(); + let mut writer = AniMeDbusWriter::new().unwrap(); loop { for brightness in 0..0xFF { - let mut buffers = [vec![brightness; 640], vec![brightness; 640]]; - buffers[0][..7].copy_from_slice(&PANE1_PREFIX); - buffers[0][..7].copy_from_slice(&PANE2_PREFIX); - - writer.write_image(&buffers).unwrap(); + let mut buffers = [[brightness; 640], [brightness; 640]]; + writer.write_image(&mut buffers).unwrap(); } } } diff --git a/aura/examples/comet.rs b/aura/examples/comet.rs index 55542436..09d1c4ed 100644 --- a/aura/examples/comet.rs +++ b/aura/examples/comet.rs @@ -23,5 +23,6 @@ fn main() -> Result<(), Box> { } writer.write_colour_block(&key_colours)?; + std::thread::sleep(std::time::Duration::from_millis(250)); } } diff --git a/aura/src/animatrix_dbus.rs b/aura/src/animatrix_dbus.rs index 850a2c57..baae815b 100644 --- a/aura/src/animatrix_dbus.rs +++ b/aura/src/animatrix_dbus.rs @@ -8,24 +8,31 @@ use std::sync::{ }; use std::{thread, time::Duration}; +pub const ANIME_PANE1_PREFIX: [u8; 7] = [0x5e, 0xc0, 0x02, 0x01, 0x00, 0x73, 0x02]; +pub const ANIME_PANE2_PREFIX: [u8; 7] = [0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02]; + /// Simplified way to write a effect block -pub struct AnimatrixDbusWriter { +pub struct AniMeDbusWriter { connection: Box, block_time: u64, stop: Arc, } -impl AnimatrixDbusWriter { +impl AniMeDbusWriter { #[inline] pub fn new() -> Result> { let connection = Connection::new_system()?; - Ok(AnimatrixDbusWriter { + Ok(AniMeDbusWriter { connection: Box::new(connection), block_time: 25, stop: Arc::new(AtomicBool::new(false)), }) } + pub fn write_image_to_buf(_buf: &mut [[u8; 640]; 2], _image_data: &[u8]) { + unimplemented!("Image format is in progress of being worked out") + } + /// Write an Animatrix image /// /// The expected input here is *two* Vectors, 640 bytes in length. The two vectors @@ -42,7 +49,14 @@ impl AnimatrixDbusWriter { /// /// Where led brightness is 0..255, low to high #[inline] - pub fn write_image(&mut self, image: &[Vec; 2]) -> Result<(), Box> { + pub fn write_image(&mut self, image: &mut [[u8; 640]; 2]) -> Result<(), Box> { + if image[0][0] != ANIME_PANE1_PREFIX[0] && image[0][6] != ANIME_PANE1_PREFIX[6] { + image[0][..7].copy_from_slice(&ANIME_PANE1_PREFIX); + } + if image[1][0] != ANIME_PANE2_PREFIX[0] && image[1][6] != ANIME_PANE2_PREFIX[6] { + image[1][..7].copy_from_slice(&ANIME_PANE2_PREFIX); + } + let msg = Message::new_method_call(DBUS_NAME, DBUS_PATH, DBUS_IFACE, "AnimatrixWrite")? .append2(image[0].to_vec(), image[1].to_vec()); self.connection.send(msg).unwrap(); diff --git a/aura/src/aura_dbus.rs b/aura/src/aura_dbus.rs index a5cd3ac9..e3c8bbb0 100644 --- a/aura/src/aura_dbus.rs +++ b/aura/src/aura_dbus.rs @@ -22,7 +22,7 @@ impl AuraDbusWriter { let connection = Connection::new_system()?; Ok(AuraDbusWriter { connection: Box::new(connection), - block_time: 50, + block_time: 33333, stop: Arc::new(AtomicBool::new(false)), }) } @@ -68,7 +68,7 @@ impl AuraDbusWriter { .append3(&group[6].to_vec(), &group[7].to_vec(), &group[8].to_vec()) .append2(&group[9].to_vec(), &group[10].to_vec()); self.connection.send(msg).unwrap(); - thread::sleep(Duration::from_millis(self.block_time)); + thread::sleep(Duration::from_micros(self.block_time)); if self.stop.load(Ordering::Relaxed) { panic!("Go signal to stop!"); } diff --git a/debian/changelog b/debian/changelog index 55996caf..c06bd5a8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +rog-core (0.10.0) focal; urgency=medium + + * Correctly set AMD boost + * Add animatrix support for G14 laptops + + -- Luke Jones Tue, 02 Jun 2020 20:11:53 +1200 + rog-core (0.9.9) focal; urgency=medium * Correctly set AMD boost diff --git a/rog-core/Cargo.toml b/rog-core/Cargo.toml index bc24bb36..8fe6eff3 100644 --- a/rog-core/Cargo.toml +++ b/rog-core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rog-daemon" -version = "0.9.9" +version = "0.10.0" license = "MPL-2.0" readme = "README.md" authors = ["Luke "] diff --git a/rog-core/src/animatrix_control.rs b/rog-core/src/animatrix_control.rs index 70bc27df..e734e5dc 100644 --- a/rog-core/src/animatrix_control.rs +++ b/rog-core/src/animatrix_control.rs @@ -23,16 +23,16 @@ pub enum AnimatrixCommand { //ReloadLast, } -pub struct AnimatrixWriter { +pub struct AniMeWriter { handle: DeviceHandle, initialised: bool, } -impl AnimatrixWriter { +impl AniMeWriter { #[inline] - pub fn new() -> Result> { + pub fn new() -> Result> { // We don't expect this ID to ever change - let mut dev_handle = AnimatrixWriter::get_device(0x0b05, 0x193b).map_err(|err| { + let mut dev_handle = AniMeWriter::get_device(0x0b05, 0x193b).map_err(|err| { error!("Could not get device handle: {:?}", err); err })?; @@ -53,7 +53,7 @@ impl AnimatrixWriter { err })?; - Ok(AnimatrixWriter { + Ok(AniMeWriter { handle: dev_handle, initialised: false, }) diff --git a/rog-core/src/daemon.rs b/rog-core/src/daemon.rs index cee20330..d6eb2670 100644 --- a/rog-core/src/daemon.rs +++ b/rog-core/src/daemon.rs @@ -1,5 +1,5 @@ use crate::{ - animatrix_control::{AnimatrixCommand, AnimatrixWriter}, + animatrix_control::{AniMeWriter, AnimatrixCommand}, config::Config, laptops::match_laptop, led_control::{AuraCommand, LedWriter}, @@ -69,8 +69,8 @@ pub async fn start_daemon() -> Result<(), Box> { // Possible Animatrix let mut animatrix_writer = None; if laptop.support_animatrix() { - animatrix_writer = Some(AnimatrixWriter::new()?); - info!("Device has an AniMatrix display"); + animatrix_writer = Some(AniMeWriter::new()?); + info!("Device has an AniMe Matrix display"); } // Set up the mutexes diff --git a/rog-core/src/main.rs b/rog-core/src/main.rs index 4b03192b..d0ac088a 100644 --- a/rog-core/src/main.rs +++ b/rog-core/src/main.rs @@ -8,7 +8,7 @@ use rog_aura::{ AuraDbusWriter, LED_MSG_LEN, }; -static VERSION: &str = "0.9.9"; +static VERSION: &str = "0.10.0"; #[derive(Debug, Options)] struct CLIStart {