Finalise anime matrix stuff. Many fixes

This commit is contained in:
Luke
2020-06-02 20:14:32 +12:00
parent e3eccef193
commit 8e98aafddd
12 changed files with 46 additions and 30 deletions

View File

@@ -6,7 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
## [0.9.9] - 2020-23-05 ## [0.10.0] - 2020-23-05
### Changed ### Changed
- Correctly set AMD boost - Correctly set AMD boost
- Add animatrix support for G14 laptops - Add animatrix support for G14 laptops

4
Cargo.lock generated
View File

@@ -673,7 +673,7 @@ checksum = "cabe4fa914dec5870285fa7f71f602645da47c486e68486d2b4ceb4a343e90ac"
[[package]] [[package]]
name = "rog-aura" name = "rog-aura"
version = "0.9.3" version = "0.10.0"
dependencies = [ dependencies = [
"dbus", "dbus",
"gumdrop", "gumdrop",
@@ -684,7 +684,7 @@ dependencies = [
[[package]] [[package]]
name = "rog-daemon" name = "rog-daemon"
version = "0.9.9" version = "0.10.0"
dependencies = [ dependencies = [
"dbus", "dbus",
"dbus-tokio", "dbus-tokio",

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "rog-aura" name = "rog-aura"
version = "0.9.3" version = "0.10.0"
license = "MPL-2.0" license = "MPL-2.0"
readme = "README.md" readme = "README.md"
authors = ["Luke <luke@ljones.dev>"] authors = ["Luke <luke@ljones.dev>"]

View File

@@ -1,18 +1,12 @@
use rog_aura::AnimatrixDbusWriter; use rog_aura::AniMeDbusWriter;
const PANE1_PREFIX: [u8; 7] = [0x5e, 0xc0, 0x02, 0x01, 0x00, 0x73, 0x02];
const PANE2_PREFIX: [u8; 7] = [0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02];
fn main() { fn main() {
let mut writer = AnimatrixDbusWriter::new().unwrap(); let mut writer = AniMeDbusWriter::new().unwrap();
loop { loop {
for brightness in 0..0xFF { for brightness in 0..0xFF {
let mut buffers = [vec![brightness; 640], vec![brightness; 640]]; let mut buffers = [[brightness; 640], [brightness; 640]];
buffers[0][..7].copy_from_slice(&PANE1_PREFIX); writer.write_image(&mut buffers).unwrap();
buffers[0][..7].copy_from_slice(&PANE2_PREFIX);
writer.write_image(&buffers).unwrap();
} }
} }
} }

View File

@@ -23,5 +23,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
} }
writer.write_colour_block(&key_colours)?; writer.write_colour_block(&key_colours)?;
std::thread::sleep(std::time::Duration::from_millis(250));
} }
} }

View File

@@ -8,24 +8,31 @@ use std::sync::{
}; };
use std::{thread, time::Duration}; 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 /// Simplified way to write a effect block
pub struct AnimatrixDbusWriter { pub struct AniMeDbusWriter {
connection: Box<Connection>, connection: Box<Connection>,
block_time: u64, block_time: u64,
stop: Arc<AtomicBool>, stop: Arc<AtomicBool>,
} }
impl AnimatrixDbusWriter { impl AniMeDbusWriter {
#[inline] #[inline]
pub fn new() -> Result<Self, Box<dyn Error>> { pub fn new() -> Result<Self, Box<dyn Error>> {
let connection = Connection::new_system()?; let connection = Connection::new_system()?;
Ok(AnimatrixDbusWriter { Ok(AniMeDbusWriter {
connection: Box::new(connection), connection: Box::new(connection),
block_time: 25, block_time: 25,
stop: Arc::new(AtomicBool::new(false)), 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 /// Write an Animatrix image
/// ///
/// The expected input here is *two* Vectors, 640 bytes in length. The two vectors /// 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 /// Where led brightness is 0..255, low to high
#[inline] #[inline]
pub fn write_image(&mut self, image: &[Vec<u8>; 2]) -> Result<(), Box<dyn Error>> { pub fn write_image(&mut self, image: &mut [[u8; 640]; 2]) -> Result<(), Box<dyn Error>> {
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")? let msg = Message::new_method_call(DBUS_NAME, DBUS_PATH, DBUS_IFACE, "AnimatrixWrite")?
.append2(image[0].to_vec(), image[1].to_vec()); .append2(image[0].to_vec(), image[1].to_vec());
self.connection.send(msg).unwrap(); self.connection.send(msg).unwrap();

View File

@@ -22,7 +22,7 @@ impl AuraDbusWriter {
let connection = Connection::new_system()?; let connection = Connection::new_system()?;
Ok(AuraDbusWriter { Ok(AuraDbusWriter {
connection: Box::new(connection), connection: Box::new(connection),
block_time: 50, block_time: 33333,
stop: Arc::new(AtomicBool::new(false)), 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()) .append3(&group[6].to_vec(), &group[7].to_vec(), &group[8].to_vec())
.append2(&group[9].to_vec(), &group[10].to_vec()); .append2(&group[9].to_vec(), &group[10].to_vec());
self.connection.send(msg).unwrap(); 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) { if self.stop.load(Ordering::Relaxed) {
panic!("Go signal to stop!"); panic!("Go signal to stop!");
} }

7
debian/changelog vendored
View File

@@ -1,3 +1,10 @@
rog-core (0.10.0) focal; urgency=medium
* Correctly set AMD boost
* Add animatrix support for G14 laptops
-- Luke Jones <luke@ljones.dev> Tue, 02 Jun 2020 20:11:53 +1200
rog-core (0.9.9) focal; urgency=medium rog-core (0.9.9) focal; urgency=medium
* Correctly set AMD boost * Correctly set AMD boost

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "rog-daemon" name = "rog-daemon"
version = "0.9.9" version = "0.10.0"
license = "MPL-2.0" license = "MPL-2.0"
readme = "README.md" readme = "README.md"
authors = ["Luke <luke@ljones.dev>"] authors = ["Luke <luke@ljones.dev>"]

View File

@@ -23,16 +23,16 @@ pub enum AnimatrixCommand {
//ReloadLast, //ReloadLast,
} }
pub struct AnimatrixWriter { pub struct AniMeWriter {
handle: DeviceHandle<rusb::GlobalContext>, handle: DeviceHandle<rusb::GlobalContext>,
initialised: bool, initialised: bool,
} }
impl AnimatrixWriter { impl AniMeWriter {
#[inline] #[inline]
pub fn new() -> Result<AnimatrixWriter, Box<dyn Error>> { pub fn new() -> Result<AniMeWriter, Box<dyn Error>> {
// We don't expect this ID to ever change // 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); error!("Could not get device handle: {:?}", err);
err err
})?; })?;
@@ -53,7 +53,7 @@ impl AnimatrixWriter {
err err
})?; })?;
Ok(AnimatrixWriter { Ok(AniMeWriter {
handle: dev_handle, handle: dev_handle,
initialised: false, initialised: false,
}) })

View File

@@ -1,5 +1,5 @@
use crate::{ use crate::{
animatrix_control::{AnimatrixCommand, AnimatrixWriter}, animatrix_control::{AniMeWriter, AnimatrixCommand},
config::Config, config::Config,
laptops::match_laptop, laptops::match_laptop,
led_control::{AuraCommand, LedWriter}, led_control::{AuraCommand, LedWriter},
@@ -69,8 +69,8 @@ pub async fn start_daemon() -> Result<(), Box<dyn Error>> {
// Possible Animatrix // Possible Animatrix
let mut animatrix_writer = None; let mut animatrix_writer = None;
if laptop.support_animatrix() { if laptop.support_animatrix() {
animatrix_writer = Some(AnimatrixWriter::new()?); animatrix_writer = Some(AniMeWriter::new()?);
info!("Device has an AniMatrix display"); info!("Device has an AniMe Matrix display");
} }
// Set up the mutexes // Set up the mutexes

View File

@@ -8,7 +8,7 @@ use rog_aura::{
AuraDbusWriter, LED_MSG_LEN, AuraDbusWriter, LED_MSG_LEN,
}; };
static VERSION: &str = "0.9.9"; static VERSION: &str = "0.10.0";
#[derive(Debug, Options)] #[derive(Debug, Options)]
struct CLIStart { struct CLIStart {