Skip to content

Commit

Permalink
Minor fixes, Factory default profiles will apply immediately on click
Browse files Browse the repository at this point in the history
  • Loading branch information
seerge committed Feb 23, 2023
1 parent 41d92d7 commit 02ae480
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 123 deletions.
3 changes: 2 additions & 1 deletion ASUSWmi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ protected byte[] CallMethod(uint MethodID, byte[] args)
BitConverter.GetBytes((uint)args.Length).CopyTo(acpiBuf, 4);
Array.Copy(args, 0, acpiBuf, 8, args.Length);

//Debug.WriteLine(BitConverter.ToString(acpiBuf, 0, acpiBuf.Length));
// if (MethodID == DEVS) Debug.WriteLine(BitConverter.ToString(acpiBuf, 0, acpiBuf.Length));

Control(CONTROL_CODE, acpiBuf, outBuffer);

Expand Down Expand Up @@ -161,6 +161,7 @@ public byte[] DeviceGetBuffer(uint DeviceID, uint Status = 0)

public void SetFanCurve(int device, byte[] curve)
{

if (device == 1)
DeviceSet(DevsGPUFanCurve, curve);
else
Expand Down
2 changes: 1 addition & 1 deletion Fans.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 36 additions & 9 deletions Fans.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,24 @@ public partial class Fans : Form
Series seriesCPU;
Series seriesGPU;

void SetChart(Chart chart, string title)
void SetChart(Chart chart, int device)
{
chart.Titles.Add(title);

string title;

if (device == 1)
title = "GPU Fan Profile";
else
title = "CPU Fan Profile";

if (Program.settingsForm.perfName.Length > 0)
title += ": " + Program.settingsForm.perfName;

if (chart.Titles.Count > 0)
chart.Titles[0].Text = title;
else
chart.Titles.Add(title);

chart.ChartAreas[0].AxisX.Minimum = 10;
chart.ChartAreas[0].AxisX.Maximum = 100;
chart.ChartAreas[0].AxisX.Interval = 10;
Expand All @@ -23,12 +38,16 @@ void SetChart(Chart chart, string title)

}

private void Fans_Shown(object? sender, EventArgs e)
{
Top = Program.settingsForm.Top;
Left = Program.settingsForm.Left - Width - 10;
}

public Fans()
{
InitializeComponent();

SetChart(chartCPU, "CPU Fan Profile");
SetChart(chartGPU, "GPU Fan Profile");
InitializeComponent();

seriesCPU = chartCPU.Series.Add("CPU");
seriesGPU = chartGPU.Series.Add("GPU");
Expand All @@ -47,12 +66,19 @@ public Fans()
buttonReset.Click += ButtonReset_Click;
buttonApply.Click += ButtonApply_Click;

Shown += Fans_Shown;

}

public void LoadFans()
{

SetChart(chartCPU, 0);
SetChart(chartGPU, 0);

LoadProfile(seriesCPU, 0);
LoadProfile(seriesGPU, 1);

}

byte[] StringToBytes(string str)
Expand Down Expand Up @@ -87,16 +113,16 @@ void LoadProfile(Series series, int device, int def = 0)

int mode = Program.config.getConfig("performance_mode");
string curveString = Program.config.getConfigString(GetFanName(device));
byte[] curve = {};
byte[] curve = { };

if (curveString is not null)
curve = StringToBytes(curveString);

if (def == 1 || curve.Length < 16)
if (def == 1 || curve.Length != 16)
curve = Program.wmi.GetFanCurve(device, mode);

Debug.WriteLine(BitConverter.ToString(curve));

//Debug.WriteLine(BitConverter.ToString(curve));

byte old = 0;
for (int i = 0; i < 8; i++)
Expand Down Expand Up @@ -138,6 +164,7 @@ private void ButtonReset_Click(object? sender, EventArgs e)
{
LoadProfile(seriesCPU, 0, 1);
LoadProfile(seriesGPU, 1, 1);
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, Program.config.getConfig("performance_mode"));
}

private void ChartCPU_MouseUp(object? sender, MouseEventArgs e)
Expand Down
Loading

0 comments on commit 02ae480

Please sign in to comment.