mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Remove around 14 transitive dependencies
This commit is contained in:
@@ -62,7 +62,10 @@ pub async fn start_daemon() -> Result<(), Box<dyn Error>> {
|
||||
laptop.led_endpoint(),
|
||||
laptop.supported_modes().to_owned(),
|
||||
);
|
||||
led_writer.reload_last_builtin(&config).await?;
|
||||
led_writer
|
||||
.reload_last_builtin(&config)
|
||||
.await
|
||||
.unwrap_or_else(|err| warn!("Reload settings: {}", err));
|
||||
|
||||
// Set up the mutexes
|
||||
let config = Arc::new(Mutex::new(config));
|
||||
@@ -107,7 +110,7 @@ pub async fn start_daemon() -> Result<(), Box<dyn Error>> {
|
||||
animatrix_writer
|
||||
.do_command(AnimatrixCommand::WriteImage(image))
|
||||
.await
|
||||
.unwrap_or_else(|err| warn!("{:?}", err));
|
||||
.unwrap_or_else(|err| warn!("{}", err));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -141,7 +144,7 @@ pub async fn start_daemon() -> Result<(), Box<dyn Error>> {
|
||||
laptop
|
||||
.run(&mut rogcore, &config1, bytes, aura_command_sender.clone())
|
||||
.await
|
||||
.unwrap_or_else(|err| warn!("{:?}", err));
|
||||
.unwrap_or_else(|err| warn!("{}", err));
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -192,13 +195,13 @@ pub async fn start_daemon() -> Result<(), Box<dyn Error>> {
|
||||
led_writer
|
||||
.do_command(command, &mut config)
|
||||
.await
|
||||
.unwrap_or_else(|err| warn!("{:?}", err));
|
||||
.unwrap_or_else(|err| warn!("{}", err));
|
||||
}
|
||||
_ => {
|
||||
led_writer
|
||||
.do_command(command, &mut config)
|
||||
.await
|
||||
.unwrap_or_else(|err| warn!("{:?}", err));
|
||||
.unwrap_or_else(|err| warn!("{}", err));
|
||||
connection
|
||||
.send(
|
||||
effect_cancel_signal
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
use std::fmt::Debug;
|
||||
use thiserror::Error;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum RogError {
|
||||
#[error("unable to parse string to fan mode")]
|
||||
ParseFanLevel,
|
||||
#[error("mode not supported")]
|
||||
NotSupported,
|
||||
}
|
||||
|
||||
impl fmt::Display for RogError {
|
||||
// This trait requires `fmt` with this exact signature.
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
RogError::ParseFanLevel => write!(f, "Parse error"),
|
||||
RogError::NotSupported => write!(f, "Not supported"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,11 +8,10 @@ static LED_INIT5: [u8; 6] = [0x5e, 0x05, 0x20, 0x31, 0, 0x08];
|
||||
static LED_APPLY: [u8; 17] = [0x5d, 0xb4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||||
static LED_SET: [u8; 17] = [0x5d, 0xb5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::{config::Config, error::RogError};
|
||||
use log::{error, info, warn};
|
||||
use rog_client::{
|
||||
aura_brightness_bytes, aura_modes::AuraModes, error::AuraError, fancy::KeyColourArray,
|
||||
LED_MSG_LEN,
|
||||
aura_brightness_bytes, aura_modes::AuraModes, fancy::KeyColourArray, LED_MSG_LEN,
|
||||
};
|
||||
use rusb::DeviceHandle;
|
||||
use std::marker::PhantomData;
|
||||
@@ -60,7 +59,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
async fn initialise(&mut self) -> Result<(), AuraError> {
|
||||
async fn initialise(&mut self) -> Result<(), RogError> {
|
||||
if !self.initialised {
|
||||
self.write_bytes(&LED_INIT1).await?;
|
||||
self.write_bytes(LED_INIT2.as_bytes()).await?;
|
||||
@@ -76,14 +75,14 @@ where
|
||||
&mut self,
|
||||
mode: AuraModes,
|
||||
config: &mut Config,
|
||||
) -> Result<(), AuraError> {
|
||||
) -> Result<(), RogError> {
|
||||
self.initialise().await?;
|
||||
self.set_and_save(mode, config).await
|
||||
}
|
||||
|
||||
/// Should only be used if the bytes you are writing are verified correct
|
||||
#[inline]
|
||||
async fn write_bytes(&self, message: &[u8]) -> Result<(), AuraError> {
|
||||
async fn write_bytes(&self, message: &[u8]) -> Result<(), RogError> {
|
||||
match unsafe { self.handle.as_ref() }.write_interrupt(
|
||||
self.led_endpoint,
|
||||
message,
|
||||
@@ -102,7 +101,7 @@ where
|
||||
///
|
||||
/// `aura_effect_init` must be called any effect routine, and called only once.
|
||||
#[inline]
|
||||
async fn write_effect(&mut self, effect: Vec<Vec<u8>>) -> Result<(), AuraError> {
|
||||
async fn write_effect(&mut self, effect: Vec<Vec<u8>>) -> Result<(), RogError> {
|
||||
if self.flip_effect_write {
|
||||
for row in effect.iter().rev() {
|
||||
self.write_bytes(row).await?;
|
||||
@@ -120,11 +119,7 @@ where
|
||||
///
|
||||
/// This needs to be universal so that settings applied by dbus stick
|
||||
#[inline]
|
||||
async fn set_and_save(
|
||||
&mut self,
|
||||
mode: AuraModes,
|
||||
config: &mut Config,
|
||||
) -> Result<(), AuraError> {
|
||||
async fn set_and_save(&mut self, mode: AuraModes, config: &mut Config) -> Result<(), RogError> {
|
||||
match mode {
|
||||
AuraModes::RGB(v) => {
|
||||
if v[0].is_empty() {
|
||||
@@ -162,17 +157,17 @@ where
|
||||
}
|
||||
|
||||
warn!("Attempted to set unsupported mode");
|
||||
Err(AuraError::NotSupported)
|
||||
Err(RogError::NotSupported)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub async fn reload_last_builtin(&mut self, config: &Config) -> Result<(), AuraError> {
|
||||
pub async fn reload_last_builtin(&mut self, config: &Config) -> Result<(), RogError> {
|
||||
self.initialise().await?;
|
||||
// set current mode (if any)
|
||||
if self.supported_modes.len() > 1 {
|
||||
let mode = config
|
||||
.get_led_mode_data(config.current_mode)
|
||||
.ok_or(AuraError::NotSupported)?
|
||||
.ok_or(RogError::NotSupported)?
|
||||
.to_owned();
|
||||
let mode: [u8; LED_MSG_LEN] = mode.into();
|
||||
self.write_bytes(&mode).await?;
|
||||
|
||||
Reference in New Issue
Block a user