mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Minor refactoring
This commit is contained in:
@@ -227,6 +227,12 @@ public static class AppConfig
|
|||||||
return getConfig(name + "_" + mode);
|
return getConfig(name + "_" + mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool isConfigPerf(string name)
|
||||||
|
{
|
||||||
|
int mode = getConfig("performance_mode");
|
||||||
|
return getConfig(name + "_" + mode) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
public static void setConfigPerf(string name, int value)
|
public static void setConfigPerf(string name, int value)
|
||||||
{
|
{
|
||||||
int mode = getConfig("performance_mode");
|
int mode = getConfig("performance_mode");
|
||||||
|
|||||||
56
app/Fans.cs
56
app/Fans.cs
@@ -360,17 +360,9 @@ namespace GHelper
|
|||||||
{
|
{
|
||||||
if (sender is null) return;
|
if (sender is null) return;
|
||||||
CheckBox chk = (CheckBox)sender;
|
CheckBox chk = (CheckBox)sender;
|
||||||
AppConfig.setConfigPerf("auto_apply_power", chk.Checked ? 1 : 0);
|
|
||||||
|
|
||||||
if (chk.Checked)
|
AppConfig.setConfigPerf("auto_apply_power", chk.Checked ? 1 : 0);
|
||||||
{
|
Program.settingsForm.SetPerformanceMode();
|
||||||
Program.settingsForm.AutoPower();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Program.acpi.DeviceSet(AsusACPI.PerformanceMode, AppConfig.getConfig("performance_mode"), "PerfMode");
|
|
||||||
Program.settingsForm.AutoFans();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -380,16 +372,8 @@ namespace GHelper
|
|||||||
CheckBox chk = (CheckBox)sender;
|
CheckBox chk = (CheckBox)sender;
|
||||||
|
|
||||||
AppConfig.setConfigPerf("auto_apply", chk.Checked ? 1 : 0);
|
AppConfig.setConfigPerf("auto_apply", chk.Checked ? 1 : 0);
|
||||||
|
Program.settingsForm.SetPerformanceMode();
|
||||||
|
|
||||||
if (chk.Checked)
|
|
||||||
{
|
|
||||||
Program.settingsForm.AutoFans();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Program.acpi.DeviceSet(AsusACPI.PerformanceMode, AppConfig.getConfig("performance_mode"), "PerfMode");
|
|
||||||
Program.settingsForm.AutoPower();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -440,7 +424,7 @@ namespace GHelper
|
|||||||
int limit_cpu;
|
int limit_cpu;
|
||||||
int limit_fast;
|
int limit_fast;
|
||||||
|
|
||||||
bool apply = AppConfig.getConfigPerf("auto_apply_power") == 1;
|
bool apply = AppConfig.isConfigPerf("auto_apply_power");
|
||||||
|
|
||||||
if (changed)
|
if (changed)
|
||||||
{
|
{
|
||||||
@@ -621,22 +605,28 @@ namespace GHelper
|
|||||||
AppConfig.setConfigPerf("auto_apply", 0);
|
AppConfig.setConfigPerf("auto_apply", 0);
|
||||||
AppConfig.setConfigPerf("auto_apply_power", 0);
|
AppConfig.setConfigPerf("auto_apply_power", 0);
|
||||||
|
|
||||||
Program.acpi.DeviceSet(AsusACPI.PerformanceMode, AppConfig.getConfig("performance_mode"), "PerfMode");
|
Program.acpi.DeviceSet(AsusACPI.PerformanceMode, AppConfig.getConfig("performance_mode"), "Mode");
|
||||||
if (Program.acpi.IsXGConnected()) AsusUSB.ResetXGM();
|
|
||||||
|
if (Program.acpi.IsXGConnected())
|
||||||
|
AsusUSB.ResetXGM();
|
||||||
|
|
||||||
trackGPUCore.Value = 0;
|
if (gpuVisible)
|
||||||
trackGPUMemory.Value = 0;
|
{
|
||||||
trackGPUBoost.Value = AsusACPI.MaxGPUBoost;
|
trackGPUCore.Value = 0;
|
||||||
trackGPUTemp.Value = AsusACPI.MaxGPUTemp;
|
trackGPUMemory.Value = 0;
|
||||||
|
trackGPUBoost.Value = AsusACPI.MaxGPUBoost;
|
||||||
|
trackGPUTemp.Value = AsusACPI.MaxGPUTemp;
|
||||||
|
|
||||||
AppConfig.setConfigPerf("gpu_boost", trackGPUBoost.Value);
|
AppConfig.setConfigPerf("gpu_boost", trackGPUBoost.Value);
|
||||||
AppConfig.setConfigPerf("gpu_temp", trackGPUTemp.Value);
|
AppConfig.setConfigPerf("gpu_temp", trackGPUTemp.Value);
|
||||||
AppConfig.setConfigPerf("gpu_core", trackGPUCore.Value);
|
AppConfig.setConfigPerf("gpu_core", trackGPUCore.Value);
|
||||||
AppConfig.setConfigPerf("gpu_memory", trackGPUMemory.Value);
|
AppConfig.setConfigPerf("gpu_memory", trackGPUMemory.Value);
|
||||||
VisualiseGPUSettings();
|
|
||||||
|
VisualiseGPUSettings();
|
||||||
|
Program.settingsForm.SetGPUClocks(true);
|
||||||
|
Program.settingsForm.SetGPUPower();
|
||||||
|
}
|
||||||
|
|
||||||
Program.settingsForm.SetGPUClocks(true);
|
|
||||||
Program.settingsForm.SetGPUPower();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ChartCPU_MouseUp(object? sender, MouseEventArgs e)
|
private void ChartCPU_MouseUp(object? sender, MouseEventArgs e)
|
||||||
|
|||||||
@@ -353,7 +353,7 @@ namespace GHelper
|
|||||||
Program.acpi.DeviceSet(AsusACPI.GPUXG, 1, "GPU XGM");
|
Program.acpi.DeviceSet(AsusACPI.GPUXG, 1, "GPU XGM");
|
||||||
await Task.Delay(TimeSpan.FromSeconds(15));
|
await Task.Delay(TimeSpan.FromSeconds(15));
|
||||||
|
|
||||||
if (AppConfig.getConfigPerf("auto_apply") == 1)
|
if (AppConfig.isConfigPerf("auto_apply"))
|
||||||
AsusUSB.SetXGMFan(AppConfig.getFanConfig(AsusFan.XGM));
|
AsusUSB.SetXGMFan(AppConfig.getFanConfig(AsusFan.XGM));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1139,7 +1139,7 @@ namespace GHelper
|
|||||||
{
|
{
|
||||||
customFans = false;
|
customFans = false;
|
||||||
|
|
||||||
if (AppConfig.getConfigPerf("auto_apply") == 1 || force)
|
if (AppConfig.isConfigPerf("auto_apply") || force)
|
||||||
{
|
{
|
||||||
|
|
||||||
bool xgmFan = false;
|
bool xgmFan = false;
|
||||||
@@ -1162,7 +1162,7 @@ namespace GHelper
|
|||||||
{
|
{
|
||||||
int mode = AppConfig.getConfig("performance_mode");
|
int mode = AppConfig.getConfig("performance_mode");
|
||||||
Logger.WriteLine("ASUS BIOS rejected fan curve, resetting mode to " + mode);
|
Logger.WriteLine("ASUS BIOS rejected fan curve, resetting mode to " + mode);
|
||||||
Program.acpi.DeviceSet(AsusACPI.PerformanceMode, mode, "PerformanceMode");
|
Program.acpi.DeviceSet(AsusACPI.PerformanceMode, mode, "Reset Mode");
|
||||||
LabelFansResult("ASUS BIOS rejected fan curve");
|
LabelFansResult("ASUS BIOS rejected fan curve");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1171,8 +1171,8 @@ namespace GHelper
|
|||||||
customFans = true;
|
customFans = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fix for misbehaving bios on intell based TUF 2022
|
// force set PPTs for missbehaving bios on FX507/517 series
|
||||||
if ((AppConfig.ContainsModel("FX507") || AppConfig.ContainsModel("FX517") || xgmFan) && AppConfig.getConfigPerf("auto_apply_power") != 1)
|
if ((AppConfig.ContainsModel("FX507") || AppConfig.ContainsModel("FX517") || xgmFan) && !AppConfig.isConfigPerf("auto_apply_power"))
|
||||||
{
|
{
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
@@ -1188,31 +1188,41 @@ namespace GHelper
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool isManualModeRequired()
|
||||||
|
{
|
||||||
|
if (!AppConfig.isConfigPerf("auto_apply_power"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return
|
||||||
|
//AppConfig.ContainsModel("GA402") ||
|
||||||
|
AppConfig.ContainsModel("GU604") ||
|
||||||
|
AppConfig.ContainsModel("FX517") ||
|
||||||
|
AppConfig.ContainsModel("G733");
|
||||||
|
}
|
||||||
|
|
||||||
public void AutoPower(int delay = 0)
|
public void AutoPower(int delay = 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
customPower = 0;
|
customPower = 0;
|
||||||
|
|
||||||
bool applyPower = (AppConfig.getConfigPerf("auto_apply_power") == 1);
|
bool applyPower = AppConfig.isConfigPerf("auto_apply_power");
|
||||||
|
bool applyFans = AppConfig.isConfigPerf("auto_apply");
|
||||||
//bool applyGPU = true;
|
//bool applyGPU = true;
|
||||||
|
|
||||||
if (applyPower)
|
if (applyPower)
|
||||||
{
|
{
|
||||||
// fix for misbehaving bios PPTs on G513
|
// force fan curve for misbehaving bios PPTs on G513
|
||||||
if (AppConfig.ContainsModel("G513") && AppConfig.getConfigPerf("auto_apply") != 1)
|
if (AppConfig.ContainsModel("G513") && !applyFans)
|
||||||
{
|
{
|
||||||
AutoFans(true);
|
|
||||||
delay = 500;
|
delay = 500;
|
||||||
|
AutoFans(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix for models that don't support PPT settings in all modes, setting a "manual" mode for them
|
// Fix for models that don't support PPT settings in all modes, setting a "manual" mode for them
|
||||||
if (AppConfig.ContainsModel("GU604") ||
|
if (isManualModeRequired())
|
||||||
AppConfig.ContainsModel("FX517") ||
|
|
||||||
AppConfig.ContainsModel("G733"))
|
|
||||||
{
|
{
|
||||||
Program.acpi.DeviceSet(AsusACPI.PerformanceMode, AsusACPI.PerformanceManual, "CustomMode");
|
|
||||||
if (AppConfig.getConfigPerf("auto_apply") != 1) AutoFans(true);
|
|
||||||
delay = 500;
|
delay = 500;
|
||||||
|
if (!applyFans) AutoFans(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1240,8 +1250,8 @@ namespace GHelper
|
|||||||
public void SetPerformanceMode(int PerformanceMode = -1, bool notify = false)
|
public void SetPerformanceMode(int PerformanceMode = -1, bool notify = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (PerformanceMode < 0)
|
int oldMode = AppConfig.getConfig("performance_mode");
|
||||||
PerformanceMode = AppConfig.getConfig("performance_mode");
|
if (PerformanceMode < 0) PerformanceMode = oldMode;
|
||||||
|
|
||||||
buttonSilent.Activated = false;
|
buttonSilent.Activated = false;
|
||||||
buttonBalanced.Activated = false;
|
buttonBalanced.Activated = false;
|
||||||
@@ -1268,11 +1278,14 @@ namespace GHelper
|
|||||||
menuBalanced.Checked = buttonBalanced.Activated;
|
menuBalanced.Checked = buttonBalanced.Activated;
|
||||||
menuTurbo.Checked = buttonTurbo.Activated;
|
menuTurbo.Checked = buttonTurbo.Activated;
|
||||||
|
|
||||||
int oldMode = AppConfig.getConfig("performance_mode");
|
|
||||||
AppConfig.setConfig("performance_" + (int)SystemInformation.PowerStatus.PowerLineStatus, PerformanceMode);
|
AppConfig.setConfig("performance_" + (int)SystemInformation.PowerStatus.PowerLineStatus, PerformanceMode);
|
||||||
AppConfig.setConfig("performance_mode", PerformanceMode);
|
AppConfig.setConfig("performance_mode", PerformanceMode);
|
||||||
|
|
||||||
Program.acpi.DeviceSet(AsusACPI.PerformanceMode, PerformanceMode, "PerformanceMode");
|
if (isManualModeRequired())
|
||||||
|
Program.acpi.DeviceSet(AsusACPI.PerformanceMode, AsusACPI.PerformanceManual, "Manual Mode");
|
||||||
|
else
|
||||||
|
Program.acpi.DeviceSet(AsusACPI.PerformanceMode, PerformanceMode, "Mode");
|
||||||
|
|
||||||
if (AppConfig.isConfig("xgm_fan") && Program.acpi.IsXGConnected()) AsusUSB.ResetXGM();
|
if (AppConfig.isConfig("xgm_fan") && Program.acpi.IsXGConnected()) AsusUSB.ResetXGM();
|
||||||
|
|
||||||
if (notify && (oldMode != PerformanceMode))
|
if (notify && (oldMode != PerformanceMode))
|
||||||
|
|||||||
Reference in New Issue
Block a user