Save and restore kb bright only on shutdown/sleep/boot/wak

Closes #213
This commit is contained in:
Luke D. Jones
2022-07-13 22:55:21 +12:00
parent 4d8c05cd92
commit abd412b5d5
2 changed files with 12 additions and 13 deletions

View File

@@ -12,8 +12,6 @@ pub static AURA_CONFIG_PATH: &str = "/etc/asusd/aura.conf";
#[serde(default)]
pub struct AuraConfig {
pub brightness: LedBrightness,
/// Used to re-set brightness on wake from sleep/hibernation
pub last_brightness: LedBrightness,
pub current_mode: AuraModeNum,
pub builtins: BTreeMap<AuraModeNum, AuraEffect>,
pub multizone: Option<BTreeMap<AuraModeNum, Vec<AuraEffect>>>,
@@ -24,7 +22,6 @@ impl Default for AuraConfig {
fn default() -> Self {
AuraConfig {
brightness: LedBrightness::Med,
last_brightness: LedBrightness::Med,
current_mode: AuraModeNum::Static,
builtins: BTreeMap::new(),
multizone: None,

View File

@@ -103,7 +103,7 @@ impl CtrlTask for CtrlKbdLedTask {
// If waking up
if !start {
info!("CtrlKbdLedTask reloading brightness and modes");
lock.set_brightness(lock.config.last_brightness)
lock.set_brightness(lock.config.brightness)
.map_err(|e| error!("CtrlKbdLedTask: {e}"))
.ok();
if let Some(mode) = lock.config.builtins.get(&lock.config.current_mode) {
@@ -113,7 +113,9 @@ impl CtrlTask for CtrlKbdLedTask {
}
} else if start {
info!("CtrlKbdLedTask saving last brightness");
lock.config.last_brightness = lock.config.brightness;
Self::update_config(&mut lock)
.map_err(|e| error!("CtrlKbdLedTask: {e}"))
.ok();
}
};
@@ -153,14 +155,14 @@ impl CtrlTask for CtrlKbdLedTask {
})
.detach();
let inner = self.inner.clone();
self.repeating_task(500, executor, move || loop {
if let Ok(ref mut lock) = inner.try_lock() {
Self::update_config(lock).unwrap();
break;
}
})
.await;
// let inner = self.inner.clone();
// self.repeating_task(500, executor, move || loop {
// if let Ok(ref mut lock) = inner.try_lock() {
// Self::update_config(lock).unwrap();
// break;
// }
// })
// .await;
Ok(())
}
}