Remember performance mode for plugged / battery

This commit is contained in:
seerge
2023-03-02 21:05:02 +01:00
parent ed579f25d6
commit b3636fd447
2 changed files with 28 additions and 17 deletions

View File

@@ -61,17 +61,11 @@ namespace GHelper
settingsForm.InitBoost();
settingsForm.InitAura();
settingsForm.SetPerformanceMode(config.getConfig("performance_mode"));
settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit"));
settingsForm.VisualiseGPUAuto(config.getConfig("gpu_auto"));
settingsForm.VisualiseScreenAuto(config.getConfig("screen_auto"));
settingsForm.SetStartupCheck(Startup.IsScheduled());
bool isPlugged = (System.Windows.Forms.SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online);
settingsForm.AutoGPUMode(isPlugged ? 1 : 0);
settingsForm.AutoScreen(isPlugged ? 1 : 0);
SetAutoModes();
SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
@@ -81,13 +75,18 @@ namespace GHelper
}
private static void SetAutoModes()
{
PowerLineStatus isPlugged = SystemInformation.PowerStatus.PowerLineStatus;
settingsForm.AutoGPUMode(isPlugged);
settingsForm.AutoScreen(isPlugged);
settingsForm.AutoPerformance(isPlugged);
settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit"));
}
private static void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
{
bool isPlugged = (System.Windows.Forms.SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online);
settingsForm.AutoGPUMode(isPlugged ? 1 : 0);
settingsForm.AutoScreen(isPlugged ? 1 : 0);
settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit"));
SetAutoModes();
}

View File

@@ -498,7 +498,9 @@ namespace GHelper
}
Program.config.setConfig("performance_"+(int)SystemInformation.PowerStatus.PowerLineStatus, PerformanceMode);
Program.config.setConfig("performance_mode", PerformanceMode);
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, PerformanceMode);
if (Program.config.getConfig("auto_apply_" + PerformanceMode) == 1)
@@ -533,12 +535,22 @@ namespace GHelper
SetPerformanceMode(Program.config.getConfig("performance_mode") + 1, true);
}
public void AutoScreen(int Plugged = 1)
public void AutoPerformance(PowerLineStatus Plugged = PowerLineStatus.Online)
{
int mode = Program.config.getConfig("performance_"+(int)Plugged);
if (mode != -1)
SetPerformanceMode(mode, true);
else
SetPerformanceMode(Program.config.getConfig("performance_mode"));
}
public void AutoScreen(PowerLineStatus Plugged = PowerLineStatus.Online)
{
int ScreenAuto = Program.config.getConfig("screen_auto");
if (ScreenAuto != 1) return;
if (Plugged == 1)
if (Plugged == PowerLineStatus.Online)
SetScreen(1000, 1);
else
SetScreen(60, 0);
@@ -547,7 +559,7 @@ namespace GHelper
}
public void AutoGPUMode(int Plugged = 1)
public void AutoGPUMode(PowerLineStatus Plugged = PowerLineStatus.Online)
{
int GpuAuto = Program.config.getConfig("gpu_auto");
@@ -561,12 +573,12 @@ namespace GHelper
return;
else
{
if (eco == 1 && Plugged == 1) // Eco going Standard on plugged
if (eco == 1 && Plugged == PowerLineStatus.Online) // Eco going Standard on plugged
{
Program.wmi.DeviceSet(ASUSWmi.GPUEco, 0);
InitGPUMode();
}
else if (eco == 0 && Plugged == 0) // Standard going Eco on plugged
else if (eco == 0 && Plugged != PowerLineStatus.Online) // Standard going Eco on plugged
{
Program.wmi.DeviceSet(ASUSWmi.GPUEco, 1);
InitGPUMode();