mirror of
https://github.com/RGBCube/superfreq
synced 2025-07-27 17:07:44 +00:00
battery: better validation for battery charge thresholds
To accommodate vendors that use 0 to mean "charge immediately" or "disable start threshold," we modified the validation logic to allow start to be 0 *as long as* start is less than stop and stop is less than OR equal to 100
This commit is contained in:
parent
622f4f6f32
commit
8f860424f9
1 changed files with 2 additions and 2 deletions
|
@ -11,9 +11,9 @@ pub struct BatteryChargeThresholds {
|
||||||
|
|
||||||
impl BatteryChargeThresholds {
|
impl BatteryChargeThresholds {
|
||||||
pub fn new(start: u8, stop: u8) -> Result<Self, ConfigError> {
|
pub fn new(start: u8, stop: u8) -> Result<Self, ConfigError> {
|
||||||
if start == 0 || stop == 0 {
|
if stop == 0 {
|
||||||
return Err(ConfigError::ValidationError(
|
return Err(ConfigError::ValidationError(
|
||||||
"Thresholds must be greater than 0%".to_string(),
|
"Stop threshold must be greater than 0%".to_string(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
if start >= stop {
|
if start >= stop {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue