diff --git a/ASUSWmi.cs b/ASUSWmi.cs
index 5bbe14f2..e2f09859 100644
--- a/ASUSWmi.cs
+++ b/ASUSWmi.cs
@@ -169,6 +169,11 @@ public class ASUSWmi
public void SetFanCurve(int device, byte[] curve)
{
+ if (curve.Length != 16) return;
+ if (curve.All(singleByte => singleByte == 0)) return;
+
+ Debug.WriteLine(BitConverter.ToString(curve));
+
if (device == 1)
DeviceSet(DevsGPUFanCurve, curve);
else
diff --git a/Fans.Designer.cs b/Fans.Designer.cs
index ae8b2837..417f1c38 100644
--- a/Fans.Designer.cs
+++ b/Fans.Designer.cs
@@ -45,6 +45,7 @@
trackCPU = new TrackBar();
trackTotal = new TrackBar();
buttonApplyPower = new Button();
+ checkAuto = new CheckBox();
((System.ComponentModel.ISupportInitialize)chartCPU).BeginInit();
((System.ComponentModel.ISupportInitialize)chartGPU).BeginInit();
groupBox1.SuspendLayout();
@@ -74,7 +75,7 @@
//
// buttonReset
//
- buttonReset.Location = new Point(619, 1016);
+ buttonReset.Location = new Point(362, 1016);
buttonReset.Name = "buttonReset";
buttonReset.Size = new Size(254, 46);
buttonReset.TabIndex = 2;
@@ -104,6 +105,7 @@
groupBox1.Controls.Add(trackTotal);
groupBox1.Location = new Point(12, 12);
groupBox1.Name = "groupBox1";
+ groupBox1.Padding = new Padding(5);
groupBox1.Size = new Size(330, 979);
groupBox1.TabIndex = 4;
groupBox1.TabStop = false;
@@ -113,7 +115,7 @@
//
labelApplied.AutoSize = true;
labelApplied.ForeColor = Color.Tomato;
- labelApplied.Location = new Point(12, 37);
+ labelApplied.Location = new Point(14, 39);
labelApplied.Name = "labelApplied";
labelApplied.Size = new Size(143, 32);
labelApplied.TabIndex = 13;
@@ -121,11 +123,12 @@
//
// pictureFine
//
+ pictureFine.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
pictureFine.BackgroundImage = Properties.Resources.everything_is_fine_itsfine;
pictureFine.BackgroundImageLayout = ImageLayout.Zoom;
- pictureFine.Location = new Point(12, 725);
+ pictureFine.Location = new Point(9, 730);
pictureFine.Name = "pictureFine";
- pictureFine.Size = new Size(304, 240);
+ pictureFine.Size = new Size(311, 240);
pictureFine.TabIndex = 12;
pictureFine.TabStop = false;
pictureFine.Visible = false;
@@ -133,7 +136,8 @@
// labelInfo
//
labelInfo.AutoSize = true;
- labelInfo.Location = new Point(22, 644);
+ labelInfo.Dock = DockStyle.Bottom;
+ labelInfo.Location = new Point(5, 942);
labelInfo.Name = "labelInfo";
labelInfo.Size = new Size(65, 32);
labelInfo.TabIndex = 11;
@@ -143,7 +147,7 @@
//
labelCPU.AutoSize = true;
labelCPU.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
- labelCPU.Location = new Point(195, 123);
+ labelCPU.Location = new Point(197, 125);
labelCPU.Name = "labelCPU";
labelCPU.Size = new Size(61, 32);
labelCPU.TabIndex = 10;
@@ -154,7 +158,7 @@
//
labelTotal.AutoSize = true;
labelTotal.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
- labelTotal.Location = new Point(37, 123);
+ labelTotal.Location = new Point(39, 125);
labelTotal.Name = "labelTotal";
labelTotal.Size = new Size(70, 32);
labelTotal.TabIndex = 9;
@@ -164,7 +168,7 @@
// label2
//
label2.AutoSize = true;
- label2.Location = new Point(198, 89);
+ label2.Location = new Point(200, 91);
label2.Name = "label2";
label2.Size = new Size(58, 32);
label2.TabIndex = 8;
@@ -174,7 +178,7 @@
// label1
//
label1.AutoSize = true;
- label1.Location = new Point(39, 89);
+ label1.Location = new Point(41, 91);
label1.Name = "label1";
label1.Size = new Size(65, 32);
label1.TabIndex = 7;
@@ -215,11 +219,22 @@
buttonApplyPower.Text = "Apply Power Limits";
buttonApplyPower.UseVisualStyleBackColor = true;
//
+ // checkAuto
+ //
+ checkAuto.AutoSize = true;
+ checkAuto.Location = new Point(708, 1022);
+ checkAuto.Name = "checkAuto";
+ checkAuto.Size = new Size(165, 36);
+ checkAuto.TabIndex = 12;
+ checkAuto.Text = "Auto Apply";
+ checkAuto.UseVisualStyleBackColor = true;
+ //
// Fans
//
AutoScaleDimensions = new SizeF(13F, 32F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1154, 1089);
+ Controls.Add(checkAuto);
Controls.Add(buttonApplyPower);
Controls.Add(groupBox1);
Controls.Add(chartGPU);
@@ -243,6 +258,7 @@
((System.ComponentModel.ISupportInitialize)trackCPU).EndInit();
((System.ComponentModel.ISupportInitialize)trackTotal).EndInit();
ResumeLayout(false);
+ PerformLayout();
}
#endregion
@@ -262,5 +278,6 @@
private Label labelInfo;
private PictureBox pictureFine;
private Label labelApplied;
+ private CheckBox checkAuto;
}
}
\ No newline at end of file
diff --git a/Fans.cs b/Fans.cs
index 0104f776..a3f3f194 100644
--- a/Fans.cs
+++ b/Fans.cs
@@ -93,6 +93,8 @@ namespace GHelper
buttonApplyPower.Click += ButtonApplyPower_Click;
+ checkAuto.Click += CheckAuto_Click;
+
labelInfo.MaximumSize = new Size(300, 0);
labelInfo.Text = "Power Limits (PPT) is experimental feature.\n\nValues will be applied only after you click 'Apply' and reset after performance mode change.\n\nUse carefully and on your own risk!";
@@ -103,6 +105,16 @@ namespace GHelper
}
+ private void CheckAuto_Click(object? sender, EventArgs e)
+ {
+ if (sender is null)
+ return;
+
+ CheckBox chk = (CheckBox)sender;
+
+ Program.config.setConfig("auto_apply_" + Program.config.getConfig("performance_mode"), chk.Checked ? 1 : 0);
+ }
+
private void Fans_FormClosing(object? sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing)
@@ -193,28 +205,12 @@ namespace GHelper
LoadProfile(seriesCPU, 0);
LoadProfile(seriesGPU, 1);
+ int auto_apply = Program.config.getConfig("auto_apply_" + Program.config.getConfig("performance_mode"));
+
+ checkAuto.Checked = (auto_apply == 1);
+
}
- byte[] StringToBytes(string str)
- {
- String[] arr = str.Split('-');
- byte[] array = new byte[arr.Length];
- for (int i = 0; i < arr.Length; i++) array[i] = Convert.ToByte(arr[i], 16);
- return array;
- }
-
- string GetFanName(int device)
- {
- int mode = Program.config.getConfig("performance_mode");
- string name;
-
- if (device == 1)
- name = "gpu";
- else
- name = "cpu";
-
- return "fan_profile_" + name + "_" + mode;
- }
void LoadProfile(Series series, int device, int def = 0)
{
@@ -226,42 +222,13 @@ namespace GHelper
series.Points.Clear();
int mode = Program.config.getConfig("performance_mode");
- string curveString = Program.config.getConfigString(GetFanName(device));
- byte[] curve = { };
-
- if (curveString is not null)
- curve = StringToBytes(curveString);
+ byte[] curve = Program.config.getFanConfig(device);
if (def == 1 || curve.Length != 16)
curve = Program.wmi.GetFanCurve(device, mode);
if (curve.All(singleByte => singleByte == 0))
- {
- switch (mode)
- {
- case 1:
- if (device == 1)
- curve = StringToBytes("14-3F-44-48-4C-50-54-62-16-1F-26-2D-39-47-55-5F");
- else
- curve = StringToBytes("14-3F-44-48-4C-50-54-62-11-1A-22-29-34-43-51-5A");
- break;
- case 2:
- if (device == 1)
- curve = StringToBytes("3C-41-42-46-47-4B-4C-62-08-11-11-1D-1D-26-26-2D");
- else
- curve = StringToBytes("3C-41-42-46-47-4B-4C-62-03-0C-0C-16-16-22-22-29");
- break;
- default:
- if (device == 1)
- curve = StringToBytes("3A-3D-40-44-48-4D-51-62-0C-16-1D-1F-26-2D-34-4A");
- else
- curve = StringToBytes("3A-3D-40-44-48-4D-51-62-08-11-16-1A-22-29-30-45");
- break;
- }
-
- }
-
-
+ Program.config.getDefaultCurve(device);
//Debug.WriteLine(BitConverter.ToString(curve));
@@ -286,10 +253,7 @@ namespace GHelper
i++;
}
- string bitCurve = BitConverter.ToString(curve);
- Debug.WriteLine(bitCurve);
- Program.config.setConfig(GetFanName(device), bitCurve);
-
+ Program.config.setFanConfig(device, curve);
Program.wmi.SetFanCurve(device, curve);
}
@@ -305,7 +269,12 @@ namespace GHelper
{
LoadProfile(seriesCPU, 0, 1);
LoadProfile(seriesGPU, 1, 1);
+
+ checkAuto.Checked = false;
+ Program.config.setConfig("auto_apply_" + Program.config.getConfig("performance_mode"), 0);
+
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, Program.config.getConfig("performance_mode"));
+
ResetApplyLabel();
}
diff --git a/GHelper.csproj b/GHelper.csproj
index 4791ecfb..2e857890 100644
--- a/GHelper.csproj
+++ b/GHelper.csproj
@@ -15,7 +15,7 @@
GHelper
x64
False
- 0.10.0
+ 0.11.0
diff --git a/Program.cs b/Program.cs
index 90e2571a..adf68f9a 100644
--- a/Program.cs
+++ b/Program.cs
@@ -75,6 +75,74 @@ public class AppConfig
File.WriteAllText(configFile, jsonString);
}
+ public string getFanName(int device)
+ {
+ int mode = getConfig("performance_mode");
+ string name;
+
+ if (device == 1)
+ name = "gpu";
+ else
+ name = "cpu";
+
+ return "fan_profile_" + name + "_" + mode;
+ }
+
+ public byte[] getFanConfig(int device)
+ {
+ string curveString = getConfigString(getFanName(device));
+ byte[] curve = { };
+
+ if (curveString is not null)
+ curve = StringToBytes(curveString);
+
+ return curve;
+ }
+
+ public void setFanConfig(int device, byte[] curve)
+ {
+ string bitCurve = BitConverter.ToString(curve);
+ setConfig(getFanName(device), bitCurve);
+ }
+
+
+ public static byte[] StringToBytes(string str)
+ {
+ String[] arr = str.Split('-');
+ byte[] array = new byte[arr.Length];
+ for (int i = 0; i < arr.Length; i++) array[i] = Convert.ToByte(arr[i], 16);
+ return array;
+ }
+
+ public byte[] getDefaultCurve(int device)
+ {
+ int mode = getConfig("performance_mode");
+ byte[] curve;
+
+ switch (mode)
+ {
+ case 1:
+ if (device == 1)
+ curve = StringToBytes("14-3F-44-48-4C-50-54-62-16-1F-26-2D-39-47-55-5F");
+ else
+ curve = StringToBytes("14-3F-44-48-4C-50-54-62-11-1A-22-29-34-43-51-5A");
+ break;
+ case 2:
+ if (device == 1)
+ curve = StringToBytes("3C-41-42-46-47-4B-4C-62-08-11-11-1D-1D-26-26-2D");
+ else
+ curve = StringToBytes("3C-41-42-46-47-4B-4C-62-03-0C-0C-16-16-22-22-29");
+ break;
+ default:
+ if (device == 1)
+ curve = StringToBytes("3A-3D-40-44-48-4D-51-62-0C-16-1D-1F-26-2D-34-4A");
+ else
+ curve = StringToBytes("3A-3D-40-44-48-4D-51-62-08-11-16-1A-22-29-30-45");
+ break;
+ }
+
+ return curve;
+ }
}
@@ -176,7 +244,8 @@ namespace GHelper
try
{
Process proc = Process.Start(start);
- } catch
+ }
+ catch
{
Debug.WriteLine("Failed to run " + fileName);
}
diff --git a/Settings.cs b/Settings.cs
index 8341ae33..69708ef9 100644
--- a/Settings.cs
+++ b/Settings.cs
@@ -1,5 +1,6 @@
using System.Diagnostics;
using System.Reflection;
+using System.Security.Cryptography;
using System.Timers;
namespace GHelper
@@ -429,7 +430,7 @@ namespace GHelper
private static void OnTimedEvent(Object? source, ElapsedEventArgs? e)
{
RefreshSensors();
- aTimer.Interval = 2000;
+ aTimer.Interval = 1000;
}
private void SettingsForm_VisibleChanged(object? sender, EventArgs e)
@@ -478,13 +479,12 @@ namespace GHelper
Program.config.setConfig("performance_mode", PerformanceMode);
- try
+ Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, PerformanceMode);
+
+ if (Program.config.getConfig("auto_apply_" + PerformanceMode) == 1)
{
- Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, PerformanceMode);
- }
- catch
- {
- labelPerf.Text = "Performance Mode: not supported";
+ Program.wmi.SetFanCurve(0, Program.config.getFanConfig(0));
+ Program.wmi.SetFanCurve(1, Program.config.getFanConfig(1));
}
if (fans != null && fans.Text != "")