diff --git a/CHANGELOG.md b/CHANGELOG.md index fe0846e..0eeac00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## [0.13.1] - 2020-29-06 +### Fixed +- Properly initialise the device +- Better log formatting + ## [0.13.0] - 2020-29-06 ### Changed - Dbus command `LedWriteBytes` renamed to `SetKeyBacklight` diff --git a/Cargo.lock b/Cargo.lock index 7288785..a2fcbd8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -736,7 +736,7 @@ checksum = "cabe4fa914dec5870285fa7f71f602645da47c486e68486d2b4ceb4a343e90ac" [[package]] name = "rog-client" -version = "0.11.0" +version = "0.13.1" dependencies = [ "dbus", "gumdrop", @@ -750,7 +750,7 @@ dependencies = [ [[package]] name = "rog-daemon" -version = "0.13.0" +version = "0.13.1" dependencies = [ "dbus", "dbus-tokio", diff --git a/debian/changelog b/debian/changelog index f94ecce..6d26d5f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +rog-core (0.13.1) focal; urgency=medium + + * Properly initialise the device + * Better log formatting + + -- Luke Jones Tue, 30 Jun 2020 09:56:52 +1200 + rog-core (0.13.0) focal; urgency=medium - Dbus command `LedWriteBytes` renamed to `SetKeyBacklight` diff --git a/rog-client/Cargo.toml b/rog-client/Cargo.toml index d032a04..1dc9ae5 100644 --- a/rog-client/Cargo.toml +++ b/rog-client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rog-client" -version = "0.11.0" +version = "0.13.1" license = "MPL-2.0" readme = "README.md" authors = ["Luke "] diff --git a/rog-core/Cargo.toml b/rog-core/Cargo.toml index 69a9df0..d74149c 100644 --- a/rog-core/Cargo.toml +++ b/rog-core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rog-daemon" -version = "0.13.0" +version = "0.13.1" license = "MPL-2.0" readme = "README.md" authors = ["Luke "] diff --git a/rog-core/src/daemon.rs b/rog-core/src/daemon.rs index 07e7859..45151c0 100644 --- a/rog-core/src/daemon.rs +++ b/rog-core/src/daemon.rs @@ -62,7 +62,7 @@ pub async fn start_daemon() -> Result<(), Box> { 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)); diff --git a/rog-core/src/laptops.rs b/rog-core/src/laptops.rs index fd76c26..1163edc 100644 --- a/rog-core/src/laptops.rs +++ b/rog-core/src/laptops.rs @@ -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 { diff --git a/rog-core/src/led_control.rs b/rog-core/src/led_control.rs index 2dd1f0b..76807cc 100644 --- a/rog-core/src/led_control.rs +++ b/rog-core/src/led_control.rs @@ -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 diff --git a/rog-core/src/main.rs b/rog-core/src/main.rs index bc805de..8a13bdb 100644 --- a/rog-core/src/main.rs +++ b/rog-core/src/main.rs @@ -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> { - 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();