1
Fork 0
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:
NotAShelf 2025-05-16 03:11:05 +03:00
parent 622f4f6f32
commit 8f860424f9
No known key found for this signature in database
GPG key ID: 29D95B64378DB4BF

View file

@ -11,9 +11,9 @@ pub struct BatteryChargeThresholds {
impl BatteryChargeThresholds {
pub fn new(start: u8, stop: u8) -> Result<Self, ConfigError> {
if start == 0 || stop == 0 {
if stop == 0 {
return Err(ConfigError::ValidationError(
"Thresholds must be greater than 0%".to_string(),
"Stop threshold must be greater than 0%".to_string(),
));
}
if start >= stop {