Skip to content

Commit

Permalink
Merge pull request #57 from quatquatt/cap-charge-limit
Browse files Browse the repository at this point in the history
charge_limit: cap percentage to 100%
  • Loading branch information
JohnAZoidberg authored Sep 30, 2024
2 parents cc8d1ef + 3bd173b commit 8ffc2f9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion framework_lib/src/commandline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1163,11 +1163,15 @@ pub fn analyze_capsule(data: &[u8]) -> Option<capsule::EfiCapsuleHeader> {
fn handle_charge_limit(ec: &CrosEc, maybe_limit: Option<u8>) -> EcResult<()> {
let (cur_min, _cur_max) = ec.get_charge_limit()?;
if let Some(limit) = maybe_limit {
// Prevent accidentally setting a very low limit
// Prevent setting unreasonable limits
if limit < 25 {
return Err(EcError::DeviceError(
"Not recommended to set charge limit below 25%".to_string(),
));
} else if limit > 100 {
return Err(EcError::DeviceError(
"Charge limit cannot be set above 100%".to_string(),
));
}
ec.set_charge_limit(cur_min, limit)?;
}
Expand Down

0 comments on commit 8ffc2f9

Please sign in to comment.