From 42a2675a078ebfab98aae92845010dcc83a56514 Mon Sep 17 00:00:00 2001 From: Luke Date: Thu, 23 Apr 2020 21:09:16 +1200 Subject: [PATCH] Make nicer fanlevel log entry --- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 2 -- src/core.rs | 43 +++++++++++++++++++++++++++++++++++++++++-- src/main.rs | 2 +- 5 files changed, 44 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a9765ee3..c1843975 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -397,7 +397,7 @@ checksum = "cabe4fa914dec5870285fa7f71f602645da47c486e68486d2b4ceb4a343e90ac" [[package]] name = "rog-daemon" -version = "0.5.0" +version = "0.6.1" dependencies = [ "aho-corasick", "dbus", diff --git a/Cargo.toml b/Cargo.toml index cba36ae8..48639eff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rog-daemon" -version = "0.6.0" +version = "0.6.1" authors = ["Luke "] edition = "2018" diff --git a/README.md b/README.md index d55c1a2e..159c64ef 100644 --- a/README.md +++ b/README.md @@ -50,8 +50,6 @@ rog-core --help Currently the last used brightness and builtin mode will be saved when set, and loaded when the daemon is started. The effect here is the last settings used are the ones loaded on boot. The daemon also saves the settings per mode as the keyboard does not do this itself - this means cycling through modes with the Aura keys will use the settings that were used via CLI. -Currently if no options are supplied for the CLI mode selection then a default is used, and this will overwrite the saved setting. I will fix this at a later date. - ## Implemented - [X] Setting/modifying built-in LED modes diff --git a/src/core.rs b/src/core.rs index 0183c3d5..78519331 100644 --- a/src/core.rs +++ b/src/core.rs @@ -358,7 +358,8 @@ impl RogCore { let mut buf = String::new(); if let Ok(_) = file.read_to_string(&mut buf) { let mut n = u8::from_str_radix(&buf.trim_end(), 10)?; - info!("Current fan mode: {:?}", &n); + let level: &str = FanLevel::from(n).into(); + info!("Current fan mode: {}", level); if n < 2 { n += 1; @@ -366,7 +367,8 @@ impl RogCore { n = 0; } - info!("Fan mode stepped to: {:?}", &n); + let level: &str = FanLevel::from(n).into(); + info!("Fan mode stepped to: {}", level); file.write(format!("{:?}\n", n).as_bytes())?; self.config.fan_mode = n; self.config.write(); @@ -455,3 +457,40 @@ impl FromStr for LedBrightness { } } } + +enum FanLevel { + Normal, + Boost, + Silent, +} + +impl From for FanLevel { + fn from(n: u8) -> Self { + match n { + 0 => FanLevel::Normal, + 1 => FanLevel::Boost, + 2 => FanLevel::Silent, + _ => FanLevel::Normal, + } + } +} + +impl From for u8 { + fn from(n: FanLevel) -> Self { + match n { + FanLevel::Normal => 0, + FanLevel::Boost => 1, + FanLevel::Silent => 2, + } + } +} + +impl From for &str { + fn from(n: FanLevel) -> Self { + match n { + FanLevel::Normal => "Normal", + FanLevel::Boost => "Boosted", + FanLevel::Silent => "Silent", + } + } +} diff --git a/src/main.rs b/src/main.rs index dbba98d0..44bf9e0e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,7 +10,7 @@ use env_logger::{Builder, Target}; use gumdrop::Options; use log::LevelFilter; -static VERSION: &'static str = "0.6.0"; +static VERSION: &'static str = "0.6.1"; #[derive(Debug, Options)] struct CLIStart {