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]
## [0.9.9] - 2020-23-05
## [0.10.0] - 2020-23-05
### Changed
- Correctly set AMD boost
- Add animatrix support for G14 laptops

4
Cargo.lock generated
View File

@@ -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",

View File

@@ -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 <luke@ljones.dev>"]

View File

@@ -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();
}
}
}

View File

@@ -23,5 +23,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
}
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};
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<Connection>,
block_time: u64,
stop: Arc<AtomicBool>,
}
impl AnimatrixDbusWriter {
impl AniMeDbusWriter {
#[inline]
pub fn new() -> Result<Self, Box<dyn Error>> {
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<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")?
.append2(image[0].to_vec(), image[1].to_vec());
self.connection.send(msg).unwrap();

View File

@@ -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!");
}

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
* Correctly set AMD boost

View File

@@ -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 <luke@ljones.dev>"]

View File

@@ -23,16 +23,16 @@ pub enum AnimatrixCommand {
//ReloadLast,
}
pub struct AnimatrixWriter {
pub struct AniMeWriter {
handle: DeviceHandle<rusb::GlobalContext>,
initialised: bool,
}
impl AnimatrixWriter {
impl AniMeWriter {
#[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
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,
})

View File

@@ -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<dyn Error>> {
// 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

View File

@@ -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 {