mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
34 lines
730 B
C#
34 lines
730 B
C#
using GHelper.Helpers;
|
|
using System.Diagnostics;
|
|
|
|
namespace GHelper.Battery
|
|
{
|
|
internal class BatteryControl
|
|
{
|
|
|
|
public static void SetBatteryChargeLimit(int limit = -1)
|
|
{
|
|
|
|
if (limit < 0) limit = AppConfig.Get("charge_limit");
|
|
if (limit < 40 || limit > 100) return;
|
|
|
|
Program.settingsForm.VisualiseBattery(limit);
|
|
|
|
Program.acpi.DeviceSet(AsusACPI.BatteryLimit, limit, "BatteryLimit");
|
|
|
|
try
|
|
{
|
|
OptimizationService.SetChargeLimit(limit);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Debug.WriteLine(ex);
|
|
}
|
|
|
|
AppConfig.Set("charge_limit", limit);
|
|
|
|
}
|
|
|
|
}
|
|
}
|