This commit is contained in:
seerge
2023-04-06 00:02:17 +02:00
parent c73b4fce97
commit fcf213f1a0
4 changed files with 46 additions and 42 deletions

View File

@@ -60,7 +60,7 @@ public class ASUSWmi
public const int GPUModeUltimate = 2; public const int GPUModeUltimate = 2;
public const int MaxTotal = 150; public const int MaxTotal = 180;
public const int MinTotal = 5; public const int MinTotal = 5;
public const int DefaultTotal = 125; public const int DefaultTotal = 125;

42
app/Fans.Designer.cs generated
View File

@@ -31,12 +31,12 @@ namespace GHelper
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
ChartArea chartArea1 = new ChartArea(); ChartArea chartArea4 = new ChartArea();
Title title1 = new Title(); Title title4 = new Title();
ChartArea chartArea2 = new ChartArea(); ChartArea chartArea5 = new ChartArea();
Title title2 = new Title(); Title title5 = new Title();
ChartArea chartArea3 = new ChartArea(); ChartArea chartArea6 = new ChartArea();
Title title3 = new Title(); Title title6 = new Title();
panelFans = new Panel(); panelFans = new Panel();
labelTip = new Label(); labelTip = new Label();
labelBoost = new Label(); labelBoost = new Label();
@@ -161,8 +161,8 @@ namespace GHelper
// //
// chartGPU // chartGPU
// //
chartArea1.Name = "ChartArea1"; chartArea4.Name = "ChartArea1";
chartGPU.ChartAreas.Add(chartArea1); chartGPU.ChartAreas.Add(chartArea4);
chartGPU.Dock = DockStyle.Fill; chartGPU.Dock = DockStyle.Fill;
chartGPU.Location = new Point(2, 340); chartGPU.Location = new Point(2, 340);
chartGPU.Margin = new Padding(2, 10, 2, 10); chartGPU.Margin = new Padding(2, 10, 2, 10);
@@ -170,13 +170,13 @@ namespace GHelper
chartGPU.Size = new Size(760, 310); chartGPU.Size = new Size(760, 310);
chartGPU.TabIndex = 17; chartGPU.TabIndex = 17;
chartGPU.Text = "chartGPU"; chartGPU.Text = "chartGPU";
title1.Name = "Title1"; title4.Name = "Title1";
chartGPU.Titles.Add(title1); chartGPU.Titles.Add(title4);
// //
// chartCPU // chartCPU
// //
chartArea2.Name = "ChartArea1"; chartArea5.Name = "ChartArea1";
chartCPU.ChartAreas.Add(chartArea2); chartCPU.ChartAreas.Add(chartArea5);
chartCPU.Dock = DockStyle.Fill; chartCPU.Dock = DockStyle.Fill;
chartCPU.Location = new Point(2, 10); chartCPU.Location = new Point(2, 10);
chartCPU.Margin = new Padding(2, 10, 2, 10); chartCPU.Margin = new Padding(2, 10, 2, 10);
@@ -184,13 +184,13 @@ namespace GHelper
chartCPU.Size = new Size(760, 310); chartCPU.Size = new Size(760, 310);
chartCPU.TabIndex = 14; chartCPU.TabIndex = 14;
chartCPU.Text = "chartCPU"; chartCPU.Text = "chartCPU";
title2.Name = "Title1"; title5.Name = "Title1";
chartCPU.Titles.Add(title2); chartCPU.Titles.Add(title5);
// //
// chartMid // chartMid
// //
chartArea3.Name = "ChartArea3"; chartArea6.Name = "ChartArea3";
chartMid.ChartAreas.Add(chartArea3); chartMid.ChartAreas.Add(chartArea6);
chartMid.Dock = DockStyle.Fill; chartMid.Dock = DockStyle.Fill;
chartMid.Location = new Point(2, 670); chartMid.Location = new Point(2, 670);
chartMid.Margin = new Padding(2, 10, 2, 10); chartMid.Margin = new Padding(2, 10, 2, 10);
@@ -198,8 +198,8 @@ namespace GHelper
chartMid.Size = new Size(760, 312); chartMid.Size = new Size(760, 312);
chartMid.TabIndex = 14; chartMid.TabIndex = 14;
chartMid.Text = "chartMid"; chartMid.Text = "chartMid";
title3.Name = "Title3"; title6.Name = "Title3";
chartMid.Titles.Add(title3); chartMid.Titles.Add(title6);
chartMid.Visible = false; chartMid.Visible = false;
// //
// labelFans // labelFans
@@ -336,7 +336,7 @@ namespace GHelper
trackCPU.Location = new Point(48, 88); trackCPU.Location = new Point(48, 88);
trackCPU.Margin = new Padding(4, 2, 4, 2); trackCPU.Margin = new Padding(4, 2, 4, 2);
trackCPU.Maximum = 85; trackCPU.Maximum = 85;
trackCPU.Minimum = 15; trackCPU.Minimum = 5;
trackCPU.Name = "trackCPU"; trackCPU.Name = "trackCPU";
trackCPU.Orientation = Orientation.Vertical; trackCPU.Orientation = Orientation.Vertical;
trackCPU.Size = new Size(90, 416); trackCPU.Size = new Size(90, 416);
@@ -381,8 +381,8 @@ namespace GHelper
// //
trackTotal.Location = new Point(44, 88); trackTotal.Location = new Point(44, 88);
trackTotal.Margin = new Padding(4, 2, 4, 2); trackTotal.Margin = new Padding(4, 2, 4, 2);
trackTotal.Maximum = 150; trackTotal.Maximum = 180;
trackTotal.Minimum = 15; trackTotal.Minimum = 10;
trackTotal.Name = "trackTotal"; trackTotal.Name = "trackTotal";
trackTotal.Orientation = Orientation.Vertical; trackTotal.Orientation = Orientation.Vertical;
trackTotal.Size = new Size(90, 416); trackTotal.Size = new Size(90, 416);

View File

@@ -108,7 +108,7 @@ namespace GHelper
chart.ChartAreas[0].AxisY.Maximum = 100; chart.ChartAreas[0].AxisY.Maximum = 100;
chart.ChartAreas[0].AxisY.LabelStyle.Font = new Font("Arial", 7F); chart.ChartAreas[0].AxisY.LabelStyle.Font = new Font("Arial", 7F);
chart.ChartAreas[0].AxisX.MajorGrid.LineColor = chartGrid; chart.ChartAreas[0].AxisX.MajorGrid.LineColor = chartGrid;
chart.ChartAreas[0].AxisY.MajorGrid.LineColor = chartGrid; chart.ChartAreas[0].AxisY.MajorGrid.LineColor = chartGrid;
chart.ChartAreas[0].AxisX.LineColor = chartGrid; chart.ChartAreas[0].AxisX.LineColor = chartGrid;

View File

@@ -1,7 +1,6 @@
using System.Diagnostics; using GHelper;
using GHelper;
using GHelper.Gpu; using GHelper.Gpu;
using NvAPIWrapper.GPU; using System.Diagnostics;
public static class HardwareMonitor public static class HardwareMonitor
{ {
@@ -45,7 +44,7 @@ public static class HardwareMonitor
if (Program.config.getConfig("fan_rpm") == 1) if (Program.config.getConfig("fan_rpm") == 1)
return " Fan: " + (fan * 100).ToString() + "RPM"; return " Fan: " + (fan * 100).ToString() + "RPM";
else else
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() private static int GetGpuUse()
@@ -80,27 +79,29 @@ public static class HardwareMonitor
var ct = new PerformanceCounter("Thermal Zone Information", "Temperature", @"\_TZ.THRM", true); var ct = new PerformanceCounter("Thermal Zone Information", "Temperature", @"\_TZ.THRM", true);
cpuTemp = ct.NextValue() - 273; cpuTemp = ct.NextValue() - 273;
ct.Dispose(); ct.Dispose();
} catch }
catch
{ {
Logger.WriteLine("Failed reading CPU temp"); Debug.WriteLine("Failed reading CPU temp");
} }
try try
{ {
gpuTemp = GpuTemperatureProvider?.GetCurrentTemperature(); gpuTemp = GpuTemperatureProvider?.GetCurrentTemperature();
} }
catch (Exception ex) { catch (Exception ex)
{
gpuTemp = -1; gpuTemp = -1;
Logger.WriteLine("Failed reading GPU temp"); Debug.WriteLine("Failed reading GPU temp");
Logger.WriteLine(ex.ToString()); Debug.WriteLine(ex.ToString());
} }
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);
gpuUsage.Add(GetGpuUse()); gpuUsage.Add(GetGpuUse());
if (gpuUsage.Count > 3) gpuUsage.RemoveAt(0); if (gpuUsage.Count > 3) gpuUsage.RemoveAt(0);
try try
{ {
@@ -111,23 +112,25 @@ public static class HardwareMonitor
} }
catch catch
{ {
Logger.WriteLine("Failed reading Battery discharge"); Debug.WriteLine("Failed reading Battery discharge");
} }
} }
public static bool IsUsedGPU(int threshold = 50) public static bool IsUsedGPU(int threshold = 50)
{ {
if (GetGpuUse() > threshold) if (GetGpuUse() > threshold)
return true; return true;
else else
return (gpuUsage.Average() > threshold); return (gpuUsage.Average() > threshold);
} }
public static void RecreateGpuTemperatureProviderWithDelay() { public static void RecreateGpuTemperatureProviderWithDelay()
{
// Re-enabling the discrete GPU takes a bit of time, // Re-enabling the discrete GPU takes a bit of time,
// so a simple workaround is to refresh again after that happens // so a simple workaround is to refresh again after that happens
Task.Run(async () => { Task.Run(async () =>
{
await Task.Delay(TimeSpan.FromSeconds(5)); await Task.Delay(TimeSpan.FromSeconds(5));
RecreateGpuTemperatureProvider(); RecreateGpuTemperatureProvider();
}); });
@@ -136,7 +139,8 @@ public static class HardwareMonitor
} }
public static void RecreateGpuTemperatureProvider() { public static void RecreateGpuTemperatureProvider()
{
try try
{ {
GpuTemperatureProvider?.Dispose(); GpuTemperatureProvider?.Dispose();
@@ -163,8 +167,8 @@ public static class HardwareMonitor
GpuTemperatureProvider = null; GpuTemperatureProvider = null;
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine(ex.ToString()); Debug.WriteLine(ex.ToString());
} }
} }
} }