mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Much better use of async throughout
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use daemon::aura::{BuiltInModeByte, Key, KeyColourArray};
|
||||
use daemon::aura::{Key, KeyColourArray};
|
||||
use daemon::daemon::{DBUS_IFACE, DBUS_NAME, DBUS_PATH};
|
||||
use dbus::Error as DbusError;
|
||||
use dbus::{ffidisp::Connection, Message};
|
||||
@@ -6,7 +6,6 @@ use std::{thread, time};
|
||||
|
||||
pub fn dbus_led_builtin_write(bytes: &[u8]) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let bus = Connection::new_system()?;
|
||||
//let proxy = bus.with_proxy(DBUS_IFACE, "/", Duration::from_millis(5000));
|
||||
let msg = Message::new_method_call(DBUS_NAME, DBUS_PATH, DBUS_IFACE, "ledmessage")?
|
||||
.append1(bytes.to_vec());
|
||||
let r = bus.send_with_reply_and_block(msg, 5000)?;
|
||||
@@ -44,8 +43,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
per_key_led.push(key_colours.clone());
|
||||
}
|
||||
|
||||
// It takes each interrupt at least 1ms. 10ms to write complete block. Plus any extra
|
||||
// penalty time such as read waits
|
||||
// It takes each interrupt at least 1ms. 10ms to write complete block.
|
||||
let time = time::Duration::from_millis(10); // aim for 100 per second
|
||||
|
||||
let row = KeyColourArray::get_init_msg();
|
||||
@@ -58,7 +56,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
thread::sleep(time);
|
||||
|
||||
for group in &per_key_led {
|
||||
thread::sleep(time);
|
||||
let group = group.get();
|
||||
let msg = Message::new_method_call(DBUS_NAME, DBUS_PATH, DBUS_IFACE, "ledeffect")?
|
||||
.append1(&group[0].to_vec())
|
||||
@@ -72,6 +69,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.append1(&group[8].to_vec())
|
||||
.append1(&group[9].to_vec());
|
||||
bus.send(msg).unwrap();
|
||||
thread::sleep(time);
|
||||
}
|
||||
let after = std::time::Instant::now();
|
||||
let diff = after.duration_since(now);
|
||||
|
||||
Reference in New Issue
Block a user