mirror of
https://github.com/RGBCube/superfreq
synced 2025-07-27 17:07:44 +00:00
engine: simplify AC power status determination
This commit is contained in:
parent
8a92c124b1
commit
5f1d2c9748
2 changed files with 10 additions and 11 deletions
|
@ -222,9 +222,7 @@ impl From<ProfileConfigToml> for ProfileConfig {
|
||||||
min_freq_mhz: toml_config.min_freq_mhz,
|
min_freq_mhz: toml_config.min_freq_mhz,
|
||||||
max_freq_mhz: toml_config.max_freq_mhz,
|
max_freq_mhz: toml_config.max_freq_mhz,
|
||||||
platform_profile: toml_config.platform_profile,
|
platform_profile: toml_config.platform_profile,
|
||||||
turbo_auto_settings: toml_config
|
turbo_auto_settings: toml_config.turbo_auto_settings.unwrap_or_default(),
|
||||||
.turbo_auto_settings
|
|
||||||
.unwrap_or_default(),
|
|
||||||
enable_auto_turbo: toml_config.enable_auto_turbo,
|
enable_auto_turbo: toml_config.enable_auto_turbo,
|
||||||
battery_charge_thresholds: toml_config.battery_charge_thresholds,
|
battery_charge_thresholds: toml_config.battery_charge_thresholds,
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,20 +202,21 @@ pub fn determine_and_apply_settings(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Determine AC/Battery status once for the entire function
|
||||||
|
let on_ac_power = if report.batteries.is_empty() {
|
||||||
|
// No batteries means desktop/server, always on AC
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
// Check if any battery reports AC connected
|
||||||
|
report.batteries.iter().any(|b| b.ac_connected)
|
||||||
|
};
|
||||||
|
|
||||||
if let Some(turbo_setting) = selected_profile_config.turbo {
|
if let Some(turbo_setting) = selected_profile_config.turbo {
|
||||||
info!("Setting turbo to '{turbo_setting:?}'");
|
info!("Setting turbo to '{turbo_setting:?}'");
|
||||||
match turbo_setting {
|
match turbo_setting {
|
||||||
TurboSetting::Auto => {
|
TurboSetting::Auto => {
|
||||||
if selected_profile_config.enable_auto_turbo {
|
if selected_profile_config.enable_auto_turbo {
|
||||||
debug!("Managing turbo in auto mode based on system conditions");
|
debug!("Managing turbo in auto mode based on system conditions");
|
||||||
// Determine AC status and pass it to manage_auto_turbo
|
|
||||||
let on_ac_power = if report.batteries.is_empty() {
|
|
||||||
// No batteries means desktop/server, always on AC
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
// Check if any battery reports AC connected
|
|
||||||
report.batteries.iter().any(|b| b.ac_connected)
|
|
||||||
};
|
|
||||||
manage_auto_turbo(report, selected_profile_config, on_ac_power)?;
|
manage_auto_turbo(report, selected_profile_config, on_ac_power)?;
|
||||||
} else {
|
} else {
|
||||||
debug!(
|
debug!(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue