mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
IsUsedGPU fix
This commit is contained in:
@@ -48,6 +48,20 @@ public static class HardwareMonitor
|
|||||||
return " Fan: " + Math.Min(Math.Round((float)fan/fanMax*100), 100).ToString() + "%"; // relatively to 6000 rpm
|
return " Fan: " + Math.Min(Math.Round((float)fan/fanMax*100), 100).ToString() + "%"; // relatively to 6000 rpm
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int GetGpuUse()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int? gpuUse = GpuTemperatureProvider?.GetGpuUse();
|
||||||
|
if (gpuUse is not null) return (int)gpuUse;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
public static void ReadSensors()
|
public static void ReadSensors()
|
||||||
{
|
{
|
||||||
batteryDischarge = -1;
|
batteryDischarge = -1;
|
||||||
@@ -84,20 +98,8 @@ public static class HardwareMonitor
|
|||||||
if (gpuTemp is null || gpuTemp < 0)
|
if (gpuTemp is null || gpuTemp < 0)
|
||||||
gpuTemp = Program.wmi.DeviceGet(ASUSWmi.Temp_GPU);
|
gpuTemp = Program.wmi.DeviceGet(ASUSWmi.Temp_GPU);
|
||||||
|
|
||||||
try
|
gpuUsage.Add(GetGpuUse());
|
||||||
{
|
if (gpuUsage.Count > 3) gpuUsage.RemoveAt(0);
|
||||||
gpuUse = GpuTemperatureProvider?.GetGpuUse();
|
|
||||||
} catch (Exception ex)
|
|
||||||
{
|
|
||||||
gpuUse = -1;
|
|
||||||
Debug.WriteLine(ex.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gpuUse is not null && gpuUse >= 0)
|
|
||||||
{
|
|
||||||
gpuUsage.Add((int)gpuUse);
|
|
||||||
if (gpuUsage.Count > 3) gpuUsage.RemoveAt(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -114,8 +116,10 @@ public static class HardwareMonitor
|
|||||||
|
|
||||||
public static bool IsUsedGPU(int threshold = 50)
|
public static bool IsUsedGPU(int threshold = 50)
|
||||||
{
|
{
|
||||||
if (gpuUsage.Count < 2) return false;
|
if (GetGpuUse() > threshold)
|
||||||
return (gpuUsage.Average() > threshold);
|
return true;
|
||||||
|
else
|
||||||
|
return (gpuUsage.Average() > threshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RecreateGpuTemperatureProviderWithDelay() {
|
public static void RecreateGpuTemperatureProviderWithDelay() {
|
||||||
|
|||||||
@@ -1064,18 +1064,19 @@ namespace GHelper
|
|||||||
if (eco == 1)
|
if (eco == 1)
|
||||||
if ((GpuAuto && Plugged == PowerLineStatus.Online) || (ForceGPU && GpuMode == ASUSWmi.GPUModeStandard))
|
if ((GpuAuto && Plugged == PowerLineStatus.Online) || (ForceGPU && GpuMode == ASUSWmi.GPUModeStandard))
|
||||||
{
|
{
|
||||||
if (HardwareMonitor.IsUsedGPU())
|
|
||||||
{
|
|
||||||
DialogResult dialogResult = MessageBox.Show("Your dGPU seem to be in heavy use, disable it?", "Eco Mode", MessageBoxButtons.YesNo);
|
|
||||||
if (dialogResult == DialogResult.No) return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetEcoGPU(0);
|
SetEcoGPU(0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (eco == 0)
|
if (eco == 0)
|
||||||
if ((GpuAuto && Plugged != PowerLineStatus.Online) || (ForceGPU && GpuMode == ASUSWmi.GPUModeEco))
|
if ((GpuAuto && Plugged != PowerLineStatus.Online) || (ForceGPU && GpuMode == ASUSWmi.GPUModeEco))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (HardwareMonitor.IsUsedGPU())
|
||||||
|
{
|
||||||
|
DialogResult dialogResult = MessageBox.Show("Your dGPU seem to be in heavy use, disable it?", "Eco Mode", MessageBoxButtons.YesNo);
|
||||||
|
if (dialogResult == DialogResult.No) return false;
|
||||||
|
}
|
||||||
|
|
||||||
SetEcoGPU(1);
|
SetEcoGPU(1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1142,7 +1143,6 @@ namespace GHelper
|
|||||||
public void SetEcoGPU(int eco)
|
public void SetEcoGPU(int eco)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
ButtonEnabled(buttonOptimized, false);
|
ButtonEnabled(buttonOptimized, false);
|
||||||
ButtonEnabled(buttonEco, false);
|
ButtonEnabled(buttonEco, false);
|
||||||
ButtonEnabled(buttonStandard, false);
|
ButtonEnabled(buttonStandard, false);
|
||||||
|
|||||||
Reference in New Issue
Block a user