From 8c1885c2ae9894d900ee5b3ca439a937086b257b Mon Sep 17 00:00:00 2001 From: Serge <5920850+seerge@users.noreply.github.com> Date: Thu, 19 Oct 2023 14:36:19 +0200 Subject: [PATCH] Auto turn off 100% charge option when battery is fully charged https://github.com/seerge/g-helper/issues/1485 --- app/Battery/BatteryControl.cs | 6 +++++- app/HardwareControl.cs | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Battery/BatteryControl.cs b/app/Battery/BatteryControl.cs index 3400eac7..6f41b246 100644 --- a/app/Battery/BatteryControl.cs +++ b/app/Battery/BatteryControl.cs @@ -13,10 +13,14 @@ { AppConfig.Set("charge_full", 1); Program.acpi.DeviceSet(AsusACPI.BatteryLimit, 100, "BatteryLimit"); - Program.settingsForm.VisualiseBatteryFull(); } + public static void UnSetBatteryLimitFull() + { + AppConfig.Set("charge_full", 0); + Program.settingsForm.VisualiseBatteryFull(); + } public static void AutoBattery(bool init = false) { diff --git a/app/HardwareControl.cs b/app/HardwareControl.cs index 05f35dcb..86c1c462 100644 --- a/app/HardwareControl.cs +++ b/app/HardwareControl.cs @@ -7,6 +7,7 @@ using GHelper.Gpu.AMD; using GHelper.Helpers; using System.Diagnostics; using System.Management; +using GHelper.Battery; public static class HardwareControl { @@ -211,6 +212,7 @@ public static class HardwareControl if (fullCapacity > 0 && chargeCapacity > 0) { batteryCapacity = Math.Min(100, ((decimal)chargeCapacity / (decimal)fullCapacity) * 100); + if (batteryCapacity > 99) BatteryControl.UnSetBatteryLimitFull(); }