mirror of
https://github.com/RGBCube/superfreq
synced 2025-07-27 17:07:44 +00:00
engine: optimize turbo auto settings retrieval; improve validation errors
This commit is contained in:
parent
f1a5ad0b6c
commit
d7d6398041
1 changed files with 3 additions and 11 deletions
|
@ -300,10 +300,10 @@ fn manage_auto_turbo(
|
||||||
on_ac_power: bool,
|
on_ac_power: bool,
|
||||||
) -> Result<(), EngineError> {
|
) -> Result<(), EngineError> {
|
||||||
// Get the auto turbo settings from the config
|
// Get the auto turbo settings from the config
|
||||||
let turbo_settings = config.turbo_auto_settings.clone();
|
let turbo_settings = &config.turbo_auto_settings;
|
||||||
|
|
||||||
// Validate the complete configuration to ensure it's usable
|
// Validate the complete configuration to ensure it's usable
|
||||||
validate_turbo_auto_settings(&turbo_settings)?;
|
validate_turbo_auto_settings(turbo_settings)?;
|
||||||
|
|
||||||
// Get average CPU temperature and CPU load
|
// Get average CPU temperature and CPU load
|
||||||
let cpu_temp = report.cpu_global.average_temperature_celsius;
|
let cpu_temp = report.cpu_global.average_temperature_celsius;
|
||||||
|
@ -440,25 +440,17 @@ fn manage_auto_turbo(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn validate_turbo_auto_settings(settings: &TurboAutoSettings) -> Result<(), EngineError> {
|
fn validate_turbo_auto_settings(settings: &TurboAutoSettings) -> Result<(), EngineError> {
|
||||||
// Validate load thresholds (0-100 % and high > low)
|
|
||||||
if settings.load_threshold_high <= settings.load_threshold_low
|
if settings.load_threshold_high <= settings.load_threshold_low
|
||||||
|| settings.load_threshold_high > 100.0
|
|| settings.load_threshold_high > 100.0
|
||||||
|| settings.load_threshold_low < 0.0
|
|| settings.load_threshold_low < 0.0
|
||||||
|| settings.load_threshold_low > 100.0
|
|| settings.load_threshold_low > 100.0
|
||||||
{
|
{
|
||||||
return Err(EngineError::ConfigurationError(
|
return Err(EngineError::ConfigurationError(
|
||||||
"Invalid turbo auto settings: load thresholds must be in 0-100% and high > low"
|
"Invalid turbo auto settings: load thresholds must be between 0 % and 100 % with high > low"
|
||||||
.to_string(),
|
.to_string(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate range of load thresholds (should be 0-100%)
|
|
||||||
if settings.load_threshold_high > 100.0 || settings.load_threshold_low < 0.0 {
|
|
||||||
return Err(EngineError::ConfigurationError(
|
|
||||||
"Invalid turbo auto settings: load thresholds must be between 0% and 100%".to_string(),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate temperature threshold (realistic range for CPU temps in Celsius)
|
// Validate temperature threshold (realistic range for CPU temps in Celsius)
|
||||||
// TODO: different CPUs have different temperature thresholds. While 110 is a good example
|
// TODO: different CPUs have different temperature thresholds. While 110 is a good example
|
||||||
// "extreme" case, the upper barrier might be *lower* for some devices. We'll want to fix
|
// "extreme" case, the upper barrier might be *lower* for some devices. We'll want to fix
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue