mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Merge branch 'seerge:main' into cpu-auto-tdp
This commit is contained in:
@@ -554,7 +554,7 @@ public class AsusACPI
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.WriteLine($"GetFan {device} :" + BitConverter.ToString(result));
|
//Logger.WriteLine($"GetFan {device} :" + BitConverter.ToString(result));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
public void SetBrightness(int brightness = -1)
|
||||||
{
|
{
|
||||||
if (!AppConfig.IsOLED()) return;
|
if (!AppConfig.IsOLED()) return;
|
||||||
@@ -74,15 +51,15 @@ namespace GHelper.Display
|
|||||||
if (ScreenNative.GetDeviceGammaRamp(handle, ref gammaDump))
|
if (ScreenNative.GetDeviceGammaRamp(handle, ref gammaDump))
|
||||||
{
|
{
|
||||||
gammaRamp = new DisplayGammaRamp(gammaDump);
|
gammaRamp = new DisplayGammaRamp(gammaDump);
|
||||||
Logger.WriteLine("Gamma R: " + string.Join("-", gammaRamp.Red));
|
//Logger.WriteLine("Gamma R: " + string.Join("-", gammaRamp.Red));
|
||||||
Logger.WriteLine("Gamma G: " + string.Join("-", gammaRamp.Green));
|
//Logger.WriteLine("Gamma G: " + string.Join("-", gammaRamp.Green));
|
||||||
Logger.WriteLine("Gamma B: " + string.Join("-", gammaRamp.Blue));
|
//Logger.WriteLine("Gamma B: " + string.Join("-", gammaRamp.Blue));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gammaRamp is null || !gammaRamp.IsOriginal())
|
if (gammaRamp is null || !gammaRamp.IsOriginal())
|
||||||
{
|
{
|
||||||
Logger.WriteLine("Default Gamma");
|
Logger.WriteLine("Not default Gamma");
|
||||||
gammaRamp = new DisplayGammaRamp();
|
gammaRamp = new DisplayGammaRamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -762,7 +762,10 @@ namespace GHelper
|
|||||||
|
|
||||||
private void TrackPower_MouseUp(object? sender, MouseEventArgs e)
|
private void TrackPower_MouseUp(object? sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
modeControl.AutoPower();
|
Task.Run(() =>
|
||||||
|
{
|
||||||
|
modeControl.AutoPower();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -87,8 +87,13 @@ namespace GHelper.Mode
|
|||||||
Program.toast.RunToast(Modes.GetCurrentName(), SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online ? ToastIcon.Charger : ToastIcon.Battery);
|
Program.toast.RunToast(Modes.GetCurrentName(), SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online ? ToastIcon.Charger : ToastIcon.Battery);
|
||||||
|
|
||||||
SetGPUClocks();
|
SetGPUClocks();
|
||||||
AutoFans();
|
|
||||||
AutoPower(1000);
|
Task.Run(async () =>
|
||||||
|
{
|
||||||
|
AutoFans();
|
||||||
|
AutoPower(1000);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// Power plan from config or defaulting to balanced
|
// Power plan from config or defaulting to balanced
|
||||||
if (AppConfig.GetModeString("scheme") is not null)
|
if (AppConfig.GetModeString("scheme") is not null)
|
||||||
@@ -145,18 +150,17 @@ namespace GHelper.Mode
|
|||||||
Program.acpi.SetFanCurve(AsusFan.Mid, AppConfig.GetFanConfig(AsusFan.Mid));
|
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)
|
if (cpuResult != 1 || gpuResult != 1)
|
||||||
{
|
{
|
||||||
cpuResult = Program.acpi.SetFanRange(AsusFan.CPU, AppConfig.GetFanConfig(AsusFan.CPU));
|
cpuResult = Program.acpi.SetFanRange(AsusFan.CPU, AppConfig.GetFanConfig(AsusFan.CPU));
|
||||||
gpuResult = Program.acpi.SetFanRange(AsusFan.GPU, AppConfig.GetFanConfig(AsusFan.GPU));
|
gpuResult = Program.acpi.SetFanRange(AsusFan.GPU, AppConfig.GetFanConfig(AsusFan.GPU));
|
||||||
|
|
||||||
|
// Something went wrong, resetting to default profile
|
||||||
if (cpuResult != 1 || gpuResult != 1)
|
if (cpuResult != 1 || gpuResult != 1)
|
||||||
{
|
{
|
||||||
int mode = Modes.GetCurrentBase();
|
Program.acpi.DeviceSet(AsusACPI.PerformanceMode, Modes.GetCurrentBase(), "Reset Mode");
|
||||||
Logger.WriteLine("ASUS BIOS rejected fan curve, resetting mode to " + mode);
|
settings.LabelFansResult("Model doesn't support custom fan curves");
|
||||||
Program.acpi.DeviceSet(AsusACPI.PerformanceMode, mode, "Reset Mode");
|
|
||||||
settings.LabelFansResult("ASUS BIOS rejected fan curve");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -189,45 +193,19 @@ namespace GHelper.Mode
|
|||||||
|
|
||||||
bool applyPower = AppConfig.IsMode("auto_apply_power");
|
bool applyPower = AppConfig.IsMode("auto_apply_power");
|
||||||
bool applyFans = AppConfig.IsMode("auto_apply");
|
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
|
delay = 500;
|
||||||
if (AppConfig.IsFanRequired())
|
AutoFans(true);
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (delay > 0)
|
Thread.Sleep(delay);
|
||||||
{
|
if (applyPower) SetPower(delay == 0);
|
||||||
var timer = new System.Timers.Timer(delay);
|
|
||||||
timer.Elapsed += delegate
|
|
||||||
{
|
|
||||||
timer.Stop();
|
|
||||||
timer.Dispose();
|
|
||||||
|
|
||||||
if (applyPower) SetPower();
|
Thread.Sleep(500);
|
||||||
Thread.Sleep(500);
|
SetGPUPower();
|
||||||
SetGPUPower();
|
AutoRyzen();
|
||||||
AutoRyzen();
|
|
||||||
};
|
|
||||||
timer.Start();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (applyPower) SetPower(true);
|
|
||||||
SetGPUPower();
|
|
||||||
AutoRyzen();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user