mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Finalise anime matrix stuff. Many fixes
This commit is contained in:
@@ -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>"]
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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!");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user