Hotfix for possible crash

This commit is contained in:
Serge
2023-05-13 09:43:26 +02:00
parent 0b7dd42a5d
commit 1fadc6c31e
3 changed files with 15 additions and 9 deletions

View File

@@ -242,10 +242,8 @@ public class ASUSWmi
int result; int result;
for (int i = 8; i < curve.Length; i++) //for (int i = 8; i < curve.Length; i++)
{ // curve[i] = Math.Max((byte)0, Math.Min((byte)99, curve[i])); // it seems to be a bug, when some old model's bios can go nuts if fan is set to 100%
curve[i] = Math.Max((byte)0, Math.Min((byte)99, curve[i])); // it seems to be a bug, when some old model's bios can go nuts if fan is set to 100%
}
switch (device) switch (device)
{ {

View File

@@ -15,6 +15,8 @@ namespace GHelper
static int MinRPM, MaxRPM; static int MinRPM, MaxRPM;
const int fansMax = 100;
NvidiaGpuControl? nvControl = null; NvidiaGpuControl? nvControl = null;
public Fans() public Fans()
@@ -241,7 +243,7 @@ namespace GHelper
chart.ChartAreas[0].AxisX.Interval = 10; chart.ChartAreas[0].AxisX.Interval = 10;
chart.ChartAreas[0].AxisY.Minimum = 0; chart.ChartAreas[0].AxisY.Minimum = 0;
chart.ChartAreas[0].AxisY.Maximum = 100; chart.ChartAreas[0].AxisY.Maximum = fansMax;
chart.ChartAreas[0].AxisY.LabelStyle.Font = new Font("Arial", 7F); chart.ChartAreas[0].AxisY.LabelStyle.Font = new Font("Arial", 7F);
@@ -250,10 +252,10 @@ namespace GHelper
chart.ChartAreas[0].AxisX.LineColor = chartGrid; chart.ChartAreas[0].AxisX.LineColor = chartGrid;
chart.ChartAreas[0].AxisY.LineColor = chartGrid; chart.ChartAreas[0].AxisY.LineColor = chartGrid;
for (int i = 0; i <= 90; i += 10) for (int i = 0; i <= fansMax-10; i += 10)
chart.ChartAreas[0].AxisY.CustomLabels.Add(i - 2, i + 2, ChartPercToRPM(i)); chart.ChartAreas[0].AxisY.CustomLabels.Add(i - 2, i + 2, ChartPercToRPM(i));
chart.ChartAreas[0].AxisY.CustomLabels.Add(98, 102, Properties.Strings.RPM); chart.ChartAreas[0].AxisY.CustomLabels.Add(fansMax-2, fansMax+2, Properties.Strings.RPM);
chart.ChartAreas[0].AxisY.Interval = 10; chart.ChartAreas[0].AxisY.Interval = 10;
@@ -577,7 +579,7 @@ namespace GHelper
if (dx > 100) dx = 100; if (dx > 100) dx = 100;
if (dy < 0) dy = 0; if (dy < 0) dy = 0;
if (dy > 100) dy = 100; if (dy > fansMax) dy = fansMax;
dymin = (dx - 65) * 1.2; dymin = (dx - 65) * 1.2;

View File

@@ -1692,7 +1692,13 @@ namespace GHelper
sliderBattery.Value = limit; sliderBattery.Value = limit;
Program.wmi.DeviceSet(ASUSWmi.BatteryLimit, limit, "BatteryLimit"); Program.wmi.DeviceSet(ASUSWmi.BatteryLimit, limit, "BatteryLimit");
OptimizationService.SetChargeLimit(limit); try
{
OptimizationService.SetChargeLimit(limit);
} catch (Exception ex)
{
Debug.WriteLine(ex);
}
Program.config.setConfig("charge_limit", limit); Program.config.setConfig("charge_limit", limit);