mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Init device correctly for LED control
This commit is contained in:
@@ -62,7 +62,7 @@ pub async fn start_daemon() -> Result<(), Box<dyn Error>> {
|
||||
laptop.led_endpoint(),
|
||||
laptop.supported_modes().to_owned(),
|
||||
);
|
||||
led_writer.reload_last_builtin(&mut config).await?;
|
||||
led_writer.reload_last_builtin(&config).await?;
|
||||
|
||||
// Set up the mutexes
|
||||
let config = Arc::new(Mutex::new(config));
|
||||
|
||||
@@ -142,10 +142,7 @@ impl LaptopBase {
|
||||
.unwrap_or_else(|err| warn!("LedBrightDown: {}", err));
|
||||
}
|
||||
FnKeys::AuraNext => {
|
||||
if let Ok(idx) = self
|
||||
.supported_modes
|
||||
.binary_search(&config.current_mode.into())
|
||||
{
|
||||
if let Ok(idx) = self.supported_modes.binary_search(&config.current_mode) {
|
||||
let idx_next = if idx < self.supported_modes.len() - 1 {
|
||||
idx + 1
|
||||
} else {
|
||||
@@ -162,10 +159,7 @@ impl LaptopBase {
|
||||
}
|
||||
}
|
||||
FnKeys::AuraPrevious => {
|
||||
if let Ok(idx) = self
|
||||
.supported_modes
|
||||
.binary_search(&config.current_mode.into())
|
||||
{
|
||||
if let Ok(idx) = self.supported_modes.binary_search(&config.current_mode) {
|
||||
let idx_next = if idx > 0 {
|
||||
idx - 1
|
||||
} else {
|
||||
|
||||
@@ -67,11 +67,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn do_command(
|
||||
&mut self,
|
||||
command: AuraCommand,
|
||||
config: &mut Config,
|
||||
) -> Result<(), AuraError> {
|
||||
async fn initialise(&mut self) -> Result<(), AuraError> {
|
||||
if !self.initialised {
|
||||
self.write_bytes(&LED_INIT1).await?;
|
||||
self.write_bytes(LED_INIT2.as_bytes()).await?;
|
||||
@@ -80,7 +76,15 @@ where
|
||||
self.write_bytes(&LED_INIT5).await?;
|
||||
self.initialised = true;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn do_command(
|
||||
&mut self,
|
||||
command: AuraCommand,
|
||||
config: &mut Config,
|
||||
) -> Result<(), AuraError> {
|
||||
self.initialise().await?;
|
||||
match command {
|
||||
AuraCommand::WriteMode(mode) => self.set_and_save(mode, config).await?,
|
||||
AuraCommand::WriteMultizone(effect) => self.write_multizone(effect).await?,
|
||||
@@ -154,7 +158,7 @@ where
|
||||
return Ok(());
|
||||
}
|
||||
_ => {
|
||||
let mode_num: u8 = u8::from(&mode).into();
|
||||
let mode_num: u8 = u8::from(&mode);
|
||||
if self.supported_modes.contains(&mode_num) {
|
||||
let bytes: [u8; LED_MSG_LEN] = (&mode).into();
|
||||
self.write_bytes(&bytes).await?;
|
||||
@@ -176,7 +180,8 @@ where
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub async fn reload_last_builtin(&self, config: &Config) -> Result<(), AuraError> {
|
||||
pub async fn reload_last_builtin(&mut self, config: &Config) -> Result<(), AuraError> {
|
||||
self.initialise().await?;
|
||||
// set current mode (if any)
|
||||
if self.supported_modes.len() > 1 {
|
||||
let mode = config
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use daemon::daemon::start_daemon;
|
||||
use daemon::rogcore::FanLevel;
|
||||
use env_logger::{Builder, Target};
|
||||
use gumdrop::Options;
|
||||
use log::LevelFilter;
|
||||
use rog_client::{
|
||||
@@ -9,8 +8,9 @@ use rog_client::{
|
||||
core_dbus::AuraDbusWriter,
|
||||
LED_MSG_LEN,
|
||||
};
|
||||
use std::io::Write;
|
||||
|
||||
static VERSION: &str = "0.13.0";
|
||||
static VERSION: &str = "0.13.1";
|
||||
|
||||
#[derive(Debug, Options)]
|
||||
struct CLIStart {
|
||||
@@ -46,11 +46,10 @@ struct LedModeCommand {
|
||||
|
||||
#[tokio::main]
|
||||
pub async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut builder = Builder::new();
|
||||
builder
|
||||
.target(Target::Stdout)
|
||||
.format_module_path(false)
|
||||
.format_timestamp(None)
|
||||
let mut logger = env_logger::Builder::new();
|
||||
logger
|
||||
.target(env_logger::Target::Stdout)
|
||||
.format(|buf, record| writeln!(buf, "{}: {}", record.level(), record.args()))
|
||||
.filter(None, LevelFilter::Info)
|
||||
.init();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user