Merge branch 'seerge:main' into cpu-auto-tdp

This commit is contained in:
IceStormNG
2024-03-02 13:18:48 +01:00
committed by GitHub
4 changed files with 28 additions and 70 deletions

View File

@@ -554,7 +554,7 @@ public class AsusACPI
break;
}
Logger.WriteLine($"GetFan {device} :" + BitConverter.ToString(result));
//Logger.WriteLine($"GetFan {device} :" + BitConverter.ToString(result));
return result;

View File

@@ -24,29 +24,6 @@ namespace GHelper.Display
}
}
public void SaveGamma()
{
var screenName = ScreenNative.FindLaptopScreen();
if (screenName is null) return;
try
{
var handle = ScreenNative.CreateDC(screenName, screenName, null, IntPtr.Zero);
var gammaRamp = new GammaRamp();
if (ScreenNative.GetDeviceGammaRamp(handle, ref gammaRamp))
{
var gamma = new DisplayGammaRamp(gammaRamp);
Logger.WriteLine("Gamma R: " + string.Join("-", gamma.Red));
Logger.WriteLine("Gamma G: " + string.Join("-", gamma.Green));
Logger.WriteLine("Gamma B: " + string.Join("-", gamma.Blue));
}
}
catch (Exception ex)
{
Logger.WriteLine(ex.ToString());
}
}
public void SetBrightness(int brightness = -1)
{
if (!AppConfig.IsOLED()) return;
@@ -74,15 +51,15 @@ namespace GHelper.Display
if (ScreenNative.GetDeviceGammaRamp(handle, ref gammaDump))
{
gammaRamp = new DisplayGammaRamp(gammaDump);
Logger.WriteLine("Gamma R: " + string.Join("-", gammaRamp.Red));
Logger.WriteLine("Gamma G: " + string.Join("-", gammaRamp.Green));
Logger.WriteLine("Gamma B: " + string.Join("-", gammaRamp.Blue));
//Logger.WriteLine("Gamma R: " + string.Join("-", gammaRamp.Red));
//Logger.WriteLine("Gamma G: " + string.Join("-", gammaRamp.Green));
//Logger.WriteLine("Gamma B: " + string.Join("-", gammaRamp.Blue));
}
}
if (gammaRamp is null || !gammaRamp.IsOriginal())
{
Logger.WriteLine("Default Gamma");
Logger.WriteLine("Not default Gamma");
gammaRamp = new DisplayGammaRamp();
}

View File

@@ -762,7 +762,10 @@ namespace GHelper
private void TrackPower_MouseUp(object? sender, MouseEventArgs e)
{
modeControl.AutoPower();
Task.Run(() =>
{
modeControl.AutoPower();
});
}

View File

@@ -87,8 +87,13 @@ namespace GHelper.Mode
Program.toast.RunToast(Modes.GetCurrentName(), SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online ? ToastIcon.Charger : ToastIcon.Battery);
SetGPUClocks();
AutoFans();
AutoPower(1000);
Task.Run(async () =>
{
AutoFans();
AutoPower(1000);
});
// Power plan from config or defaulting to balanced
if (AppConfig.GetModeString("scheme") is not null)
@@ -145,18 +150,17 @@ namespace GHelper.Mode
Program.acpi.SetFanCurve(AsusFan.Mid, AppConfig.GetFanConfig(AsusFan.Mid));
// something went wrong, resetting to default profile
// Alternative way to set fan curve
if (cpuResult != 1 || gpuResult != 1)
{
cpuResult = Program.acpi.SetFanRange(AsusFan.CPU, AppConfig.GetFanConfig(AsusFan.CPU));
gpuResult = Program.acpi.SetFanRange(AsusFan.GPU, AppConfig.GetFanConfig(AsusFan.GPU));
// Something went wrong, resetting to default profile
if (cpuResult != 1 || gpuResult != 1)
{
int mode = Modes.GetCurrentBase();
Logger.WriteLine("ASUS BIOS rejected fan curve, resetting mode to " + mode);
Program.acpi.DeviceSet(AsusACPI.PerformanceMode, mode, "Reset Mode");
settings.LabelFansResult("ASUS BIOS rejected fan curve");
Program.acpi.DeviceSet(AsusACPI.PerformanceMode, Modes.GetCurrentBase(), "Reset Mode");
settings.LabelFansResult("Model doesn't support custom fan curves");
}
}
else
@@ -189,45 +193,19 @@ namespace GHelper.Mode
bool applyPower = AppConfig.IsMode("auto_apply_power");
bool applyFans = AppConfig.IsMode("auto_apply");
//bool applyGPU = true;
if (applyPower && !applyFans)
if (applyPower && !applyFans && (AppConfig.IsFanRequired() || AppConfig.IsManualModeRequired()))
{
// force fan curve for misbehaving bios PPTs on some models
if (AppConfig.IsFanRequired())
{
delay = 500;
AutoFans(true);
}
// Fix for models that don't support PPT settings in all modes, setting a "manual" mode for them
if (AppConfig.IsManualModeRequired())
{
AutoFans(true);
}
delay = 500;
AutoFans(true);
}
if (delay > 0)
{
var timer = new System.Timers.Timer(delay);
timer.Elapsed += delegate
{
timer.Stop();
timer.Dispose();
Thread.Sleep(delay);
if (applyPower) SetPower(delay == 0);
if (applyPower) SetPower();
Thread.Sleep(500);
SetGPUPower();
AutoRyzen();
};
timer.Start();
}
else
{
if (applyPower) SetPower(true);
SetGPUPower();
AutoRyzen();
}
Thread.Sleep(500);
SetGPUPower();
AutoRyzen();
}