Fix some state bugs which caused fan pulsing
This commit is contained in:
parent
d41ee9bbcf
commit
3ebf62341f
2 changed files with 14 additions and 2 deletions
2
backend/Cargo.lock
generated
2
backend/Cargo.lock
generated
|
@ -106,7 +106,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fantastic-rs"
|
name = "fantastic-rs"
|
||||||
version = "0.3.1"
|
version = "0.3.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"serde",
|
"serde",
|
||||||
|
|
|
@ -56,9 +56,11 @@ impl ControlRuntime {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
if settings.enable {
|
||||||
Self::on_set_enable(&settings, &state);
|
Self::on_set_enable(&settings, &state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
start_time = Instant::now();
|
start_time = Instant::now();
|
||||||
{ // save to file
|
{ // save to file
|
||||||
let state = match runtime_state.read() {
|
let state = match runtime_state.read() {
|
||||||
|
@ -82,6 +84,15 @@ impl ControlRuntime {
|
||||||
log::error!("SettingsJson.save({}) error: {}", settings_path(&state.home).display(), e);
|
log::error!("SettingsJson.save({}) error: {}", settings_path(&state.home).display(), e);
|
||||||
}
|
}
|
||||||
Self::on_set_enable(&settings, &state);
|
Self::on_set_enable(&settings, &state);
|
||||||
|
drop(state);
|
||||||
|
let mut state = match runtime_state.write() {
|
||||||
|
Ok(x) => x,
|
||||||
|
Err(e) => {
|
||||||
|
log::error!("runtime failed to acquire state write lock: {}", e);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
state.dirty = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{ // fan control
|
{ // fan control
|
||||||
|
@ -200,6 +211,7 @@ impl ControlRuntime {
|
||||||
else:
|
else:
|
||||||
return 0.5
|
return 0.5
|
||||||
*/
|
*/
|
||||||
|
// step fan, what are you doing?
|
||||||
if let Some(index) = index {
|
if let Some(index) = index {
|
||||||
settings.curve[index].y
|
settings.curve[index].y
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue