mirror of
https://github.com/RGBCube/superfreq
synced 2025-07-27 17:07:44 +00:00
battery: tighten treshhold validation
This commit is contained in:
parent
ded671296a
commit
759ba2a10a
1 changed files with 5 additions and 0 deletions
|
@ -92,6 +92,11 @@ pub fn set_battery_charge_thresholds(start_threshold: u8, stop_threshold: u8) ->
|
|||
|
||||
/// Validates that the threshold values are in acceptable ranges
|
||||
fn validate_thresholds(start_threshold: u8, stop_threshold: u8) -> Result<()> {
|
||||
if start_threshold == 0 || stop_threshold == 0 {
|
||||
return Err(ControlError::InvalidValueError(
|
||||
"Thresholds must be greater than 0%".to_string(),
|
||||
));
|
||||
}
|
||||
if start_threshold >= stop_threshold {
|
||||
return Err(ControlError::InvalidValueError(format!(
|
||||
"Start threshold ({start_threshold}) must be less than stop threshold ({stop_threshold})"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue