Skip to content

Commit

Permalink
Mid Fan support
Browse files Browse the repository at this point in the history
  • Loading branch information
seerge committed Mar 21, 2023
1 parent 06be8c7 commit 7cb9b1f
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 19 deletions.
37 changes: 28 additions & 9 deletions app/ASUSWmi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class ASUSWmi

public const uint DevsCPUFanCurve = 0x00110024;
public const uint DevsGPUFanCurve = 0x00110025;
public const uint DevsMidFanCurve = 0x00110032;

public const int PPT_TotalA0 = 0x001200A0; // Total PPT on 2022 and CPU PPT on 2021
public const int PPT_EDCA1 = 0x001200A1; // CPU EDC
Expand Down Expand Up @@ -185,12 +186,25 @@ public void SetFanCurve(int device, byte[] curve)
if (curve.Length != 16) return;
if (curve.All(singleByte => singleByte == 0)) return;

Logger.WriteLine("Fans" + ((device == 1) ? "GPU" : "CPU") + " " + BitConverter.ToString(curve));
string name;

if (device == 1)
DeviceSet(DevsGPUFanCurve, curve);
else
DeviceSet(DevsCPUFanCurve, curve);
switch (device)
{
case 1:
DeviceSet(DevsGPUFanCurve, curve);
name = "GPU";
break;
case 2:
DeviceSet(DevsMidFanCurve, curve);
name = "Mid";
break;
default:
DeviceSet(DevsCPUFanCurve, curve);
name = "CPU";
break;
}

Logger.WriteLine("Fans" + name + " " + BitConverter.ToString(curve));
}

public byte[] GetFanCurve(int device, int mode = 0)
Expand All @@ -205,10 +219,15 @@ public byte[] GetFanCurve(int device, int mode = 0)
default: fan_mode = 0; break;
}

if (device == 1)
return DeviceGetBuffer(DevsGPUFanCurve, fan_mode);
else
return DeviceGetBuffer(DevsCPUFanCurve, fan_mode);
switch (device)
{
case 1:
return DeviceGetBuffer(DevsGPUFanCurve, fan_mode);
case 2:
return DeviceGetBuffer(DevsMidFanCurve, fan_mode);
default:
return DeviceGetBuffer(DevsCPUFanCurve, fan_mode);
}

}

Expand Down
2 changes: 1 addition & 1 deletion app/AnimeMatrix/AnimeMatrixDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public void GenerateFrame(Image image)
{
for (int x = 0; x < bmp.Width; x++)
{
if (x % 2 == (y % 2))
if (x % 2 == y % 2)
{
var color = GetColor(bmp, x, y);
//var color2= GetColor(bmp, x+1, y);
Expand Down
36 changes: 28 additions & 8 deletions app/Fans.Designer.cs

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

27 changes: 27 additions & 0 deletions app/Fans.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public partial class Fans : RForm
DataPoint curPoint = null;
Series seriesCPU;
Series seriesGPU;
Series seriesMid;

static int MinRPM, MaxRPM;

Expand All @@ -27,6 +28,8 @@ void SetChart(Chart chart, int device)

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

Expand Down Expand Up @@ -97,16 +100,21 @@ public Fans()

seriesCPU = chartCPU.Series.Add("CPU");
seriesGPU = chartGPU.Series.Add("GPU");
seriesMid = chartMid.Series.Add("Mid");

seriesCPU.Color = colorStandard;
seriesGPU.Color = colorTurbo;
seriesMid.Color = colorEco;

chartCPU.MouseMove += ChartCPU_MouseMove;
chartCPU.MouseUp += ChartCPU_MouseUp;

chartGPU.MouseMove += ChartCPU_MouseMove;
chartGPU.MouseUp += ChartCPU_MouseUp;

chartMid.MouseMove += ChartCPU_MouseMove;
chartMid.MouseUp += ChartCPU_MouseUp;

buttonReset.Click += ButtonReset_Click;
buttonApply.Click += ButtonApply_Click;

Expand Down Expand Up @@ -264,6 +272,21 @@ public void ApplyLabel(bool applied = false)
public void InitFans()
{

byte[] curve = Program.wmi.GetFanCurve(2);

if (curve.All(singleByte => singleByte == 0))
{
Program.config.setConfig("mid_fan", 0);
chartMid.Visible = false;

} else
{
Program.config.setConfig("mid_fan", 1);
SetChart(chartMid, 2);
LoadProfile(seriesMid, 2);
}


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

Expand Down Expand Up @@ -328,13 +351,17 @@ private void ButtonApply_Click(object? sender, EventArgs e)
{
ApplyProfile(seriesCPU, 0);
ApplyProfile(seriesGPU, 1);
if (Program.config.getConfig("mid_fan") == 1)
ApplyProfile(seriesMid, 2);
}

private void ButtonReset_Click(object? sender, EventArgs e)
{

LoadProfile(seriesCPU, 0, 1);
LoadProfile(seriesGPU, 1, 1);
if (Program.config.getConfig("mid_fan") == 1)
LoadProfile(seriesMid, 2, 1);

checkAuto.Checked = false;
checkApplyPower.Checked = false;
Expand Down
2 changes: 1 addition & 1 deletion app/GHelper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PlatformTarget>x64</PlatformTarget>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<AssemblyVersion>0.33</AssemblyVersion>
<AssemblyVersion>0.35</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions app/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,9 @@ public void AutoFansAndPower()
{
Program.wmi.SetFanCurve(0, Program.config.getFanConfig(0));
Program.wmi.SetFanCurve(1, Program.config.getFanConfig(1));

if (Program.config.getConfig("mid_fan") == 1)
Program.wmi.SetFanCurve(2, Program.config.getFanConfig(2));
}

if (Program.config.getConfigPerf("auto_apply_power") == 1)
Expand Down

0 comments on commit 7cb9b1f

Please sign in to comment.