Mid Fan support

This commit is contained in:
seerge
2023-03-21 01:24:42 +01:00
parent 06be8c726e
commit 7cb9b1f64f
6 changed files with 88 additions and 19 deletions

View File

@@ -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
@@ -185,12 +186,25 @@ public class ASUSWmi
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)
@@ -205,10 +219,15 @@ public class ASUSWmi
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);
}
}

View File

@@ -304,7 +304,7 @@ namespace Starlight.AnimeMatrix
{
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);

36
app/Fans.Designer.cs generated
View File

@@ -35,6 +35,8 @@ namespace GHelper
Title title1 = new Title();
ChartArea chartArea2 = new ChartArea();
Title title2 = new Title();
ChartArea chartArea3 = new ChartArea();
Title title3 = new Title();
panelFans = new Panel();
labelTip = new Label();
labelBoost = new Label();
@@ -43,6 +45,7 @@ namespace GHelper
tableFanCharts = new TableLayoutPanel();
chartGPU = new Chart();
chartCPU = new Chart();
chartMid = new Chart();
labelFans = new Label();
checkAuto = new CheckBox();
buttonReset = new RButton();
@@ -68,6 +71,7 @@ namespace GHelper
tableFanCharts.SuspendLayout();
((System.ComponentModel.ISupportInitialize)chartGPU).BeginInit();
((System.ComponentModel.ISupportInitialize)chartCPU).BeginInit();
((System.ComponentModel.ISupportInitialize)chartMid).BeginInit();
panelPower.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
panelCPU.SuspendLayout();
@@ -147,14 +151,14 @@ namespace GHelper
tableFanCharts.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
tableFanCharts.Controls.Add(chartGPU, 0, 1);
tableFanCharts.Controls.Add(chartCPU, 0, 0);
tableFanCharts.Controls.Add(chartMid, 0, 2);
tableFanCharts.Location = new Point(28, 64);
tableFanCharts.Margin = new Padding(6);
tableFanCharts.Name = "tableFanCharts";
tableFanCharts.RowCount = 2;
tableFanCharts.RowStyles.Add(new RowStyle(SizeType.Percent, 50F));
tableFanCharts.RowStyles.Add(new RowStyle(SizeType.Percent, 50F));
tableFanCharts.RowStyles.Add(new RowStyle(SizeType.Absolute, 40F));
tableFanCharts.RowStyles.Add(new RowStyle(SizeType.Absolute, 40F));
tableFanCharts.RowStyles.Add(new RowStyle(SizeType.Percent, 33F));
tableFanCharts.RowStyles.Add(new RowStyle(SizeType.Percent, 33F));
tableFanCharts.RowStyles.Add(new RowStyle(SizeType.Percent, 33F));
tableFanCharts.Size = new Size(764, 992);
tableFanCharts.TabIndex = 36;
//
@@ -163,12 +167,12 @@ namespace GHelper
chartArea1.Name = "ChartArea1";
chartGPU.ChartAreas.Add(chartArea1);
chartGPU.Dock = DockStyle.Fill;
chartGPU.Location = new Point(2, 506);
chartGPU.Location = new Point(2, 340);
chartGPU.Margin = new Padding(2, 10, 2, 10);
chartGPU.Name = "chartGPU";
chartGPU.Size = new Size(760, 476);
chartGPU.Size = new Size(760, 310);
chartGPU.TabIndex = 17;
chartGPU.Text = "chart1";
chartGPU.Text = "chartGPU";
title1.Name = "Title1";
chartGPU.Titles.Add(title1);
//
@@ -180,12 +184,26 @@ namespace GHelper
chartCPU.Location = new Point(2, 10);
chartCPU.Margin = new Padding(2, 10, 2, 10);
chartCPU.Name = "chartCPU";
chartCPU.Size = new Size(760, 476);
chartCPU.Size = new Size(760, 310);
chartCPU.TabIndex = 14;
chartCPU.Text = "chartCPU";
title2.Name = "Title1";
chartCPU.Titles.Add(title2);
//
// chartMid
//
chartArea3.Name = "ChartArea3";
chartMid.ChartAreas.Add(chartArea3);
chartMid.Dock = DockStyle.Fill;
chartMid.Location = new Point(2, 670);
chartMid.Margin = new Padding(2, 10, 2, 10);
chartMid.Name = "chartMid";
chartMid.Size = new Size(760, 312);
chartMid.TabIndex = 14;
chartMid.Text = "chartMid";
title3.Name = "Title3";
chartMid.Titles.Add(title3);
//
// labelFans
//
labelFans.AutoSize = true;
@@ -465,6 +483,7 @@ namespace GHelper
tableFanCharts.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)chartGPU).EndInit();
((System.ComponentModel.ISupportInitialize)chartCPU).EndInit();
((System.ComponentModel.ISupportInitialize)chartMid).EndInit();
panelPower.ResumeLayout(false);
panelPower.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit();
@@ -501,6 +520,7 @@ namespace GHelper
private TableLayoutPanel tableFanCharts;
private System.Windows.Forms.DataVisualization.Charting.Chart chartGPU;
private System.Windows.Forms.DataVisualization.Charting.Chart chartCPU;
private System.Windows.Forms.DataVisualization.Charting.Chart chartMid;
private Label labelFans;
private PictureBox picturePerf;
private PictureBox pictureBox1;

View File

@@ -10,6 +10,7 @@ namespace GHelper
DataPoint curPoint = null;
Series seriesCPU;
Series seriesGPU;
Series seriesMid;
static int MinRPM, MaxRPM;
@@ -27,6 +28,8 @@ namespace GHelper
if (device == 1)
title = "GPU Fan Profile";
else if (device == 2)
title = "Middle Fan Profile";
else
title = "CPU Fan Profile";
@@ -97,9 +100,11 @@ namespace GHelper
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;
@@ -107,6 +112,9 @@ namespace GHelper
chartGPU.MouseMove += ChartCPU_MouseMove;
chartGPU.MouseUp += ChartCPU_MouseUp;
chartMid.MouseMove += ChartCPU_MouseMove;
chartMid.MouseUp += ChartCPU_MouseUp;
buttonReset.Click += ButtonReset_Click;
buttonApply.Click += ButtonApply_Click;
@@ -264,6 +272,21 @@ namespace GHelper
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);
@@ -328,6 +351,8 @@ namespace GHelper
{
ApplyProfile(seriesCPU, 0);
ApplyProfile(seriesGPU, 1);
if (Program.config.getConfig("mid_fan") == 1)
ApplyProfile(seriesMid, 2);
}
private void ButtonReset_Click(object? sender, EventArgs e)
@@ -335,6 +360,8 @@ namespace GHelper
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;

View File

@@ -16,7 +16,7 @@
<PlatformTarget>x64</PlatformTarget>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<AssemblyVersion>0.33</AssemblyVersion>
<AssemblyVersion>0.35</AssemblyVersion>
</PropertyGroup>
<ItemGroup>

View File

@@ -852,6 +852,9 @@ namespace GHelper
{
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)