Fix needing to double-tap fan-mode to change mode

This commit is contained in:
Luke
2020-05-22 15:38:17 +12:00
parent 0e6f6f3289
commit 5e781cbd3d
6 changed files with 29 additions and 21 deletions

View File

@@ -108,24 +108,22 @@ impl RogCore {
let path = RogCore::get_fan_path()?;
let mut fan_ctrl = OpenOptions::new().read(true).write(true).open(path)?;
let mut buf = String::new();
if let Ok(_) = fan_ctrl.read_to_string(&mut buf) {
let mut n = u8::from_str_radix(&buf.trim_end(), 10)?;
info!("Current fan mode: {:#?}", FanLevel::from(n));
// wrap around the step number
if n < 2 {
n += 1;
} else {
n = 0;
}
info!("Fan mode stepped to: {:#?}", FanLevel::from(n));
fan_ctrl
.write_all(format!("{:?}\n", config.fan_mode).as_bytes())
.unwrap_or_else(|err| error!("Could not write to {}, {:?}", path, err));
self.set_pstate_for_fan_mode(FanLevel::from(n), config)?;
config.fan_mode = n;
config.write();
let mut n = config.fan_mode;
info!("Current fan mode: {:?}", FanLevel::from(n));
// wrap around the step number
if n < 2 {
n += 1;
} else {
n = 0;
}
info!("Fan mode stepped to: {:?}", FanLevel::from(n));
fan_ctrl
.write_all(format!("{:?}", config.fan_mode).as_bytes())
.unwrap_or_else(|err| error!("Could not write to {}, {:?}", path, err));
self.set_pstate_for_fan_mode(FanLevel::from(n), config)?;
config.fan_mode = n;
config.write();
Ok(())
}

View File

@@ -7,7 +7,7 @@ use rog_aura::{
AuraDbusWriter, LED_MSG_LEN,
};
static VERSION: &'static str = "0.9.4";
static VERSION: &'static str = "0.9.6";
#[derive(Debug, Options)]
struct CLIStart {