Make nicer fanlevel log entry

This commit is contained in:
Luke
2020-04-23 21:09:16 +12:00
parent 588c71d9ae
commit 42a2675a07
5 changed files with 44 additions and 7 deletions

2
Cargo.lock generated
View File

@@ -397,7 +397,7 @@ checksum = "cabe4fa914dec5870285fa7f71f602645da47c486e68486d2b4ceb4a343e90ac"
[[package]]
name = "rog-daemon"
version = "0.5.0"
version = "0.6.1"
dependencies = [
"aho-corasick",
"dbus",

View File

@@ -1,6 +1,6 @@
[package]
name = "rog-daemon"
version = "0.6.0"
version = "0.6.1"
authors = ["Luke <luke@ljones.dev>"]
edition = "2018"

View File

@@ -50,8 +50,6 @@ rog-core <command> <subcommand> --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

View File

@@ -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<u8> for FanLevel {
fn from(n: u8) -> Self {
match n {
0 => FanLevel::Normal,
1 => FanLevel::Boost,
2 => FanLevel::Silent,
_ => FanLevel::Normal,
}
}
}
impl From<FanLevel> for u8 {
fn from(n: FanLevel) -> Self {
match n {
FanLevel::Normal => 0,
FanLevel::Boost => 1,
FanLevel::Silent => 2,
}
}
}
impl From<FanLevel> for &str {
fn from(n: FanLevel) -> Self {
match n {
FanLevel::Normal => "Normal",
FanLevel::Boost => "Boosted",
FanLevel::Silent => "Silent",
}
}
}

View File

@@ -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 {