Compare commits

..

8 Commits
v0.46 ... v0.48

Author SHA1 Message Date
seerge
13ec0f8911 GPU use simplified for now 2023-04-06 12:19:32 +02:00
seerge
fcf213f1a0 - 2023-04-06 00:02:17 +02:00
seerge
c73b4fce97 Added NVidia GPU usage 2023-04-05 20:25:05 +02:00
seerge
aab1e08729 IsUsedGPU fix 2023-04-05 19:59:10 +02:00
seerge
cf3a84aa3d Added GPU usage check 2023-04-05 19:33:53 +02:00
seerge
8d119b386d - 2023-04-05 13:02:02 +02:00
seerge
0605e63433 UI tweaks 2023-04-04 16:36:26 +02:00
seerge
4634404ed4 Fans + power ui simplification 2023-04-03 21:17:16 +02:00
14 changed files with 416 additions and 345 deletions

View File

@@ -21,6 +21,8 @@ public class ASUSWmi
public const uint PerformanceMode = 0x00120075; // Thermal Control public const uint PerformanceMode = 0x00120075; // Thermal Control
public const uint GPUEco = 0x00090020; public const uint GPUEco = 0x00090020;
public const uint GPUXGConnected = 0x00090018;
public const uint GPUXG = 0x00090019;
public const uint GPUMux = 0x00090016; public const uint GPUMux = 0x00090016;
public const uint BatteryLimit = 0x00120057; public const uint BatteryLimit = 0x00120057;
@@ -58,7 +60,7 @@ public class ASUSWmi
public const int GPUModeUltimate = 2; public const int GPUModeUltimate = 2;
public const int MaxTotal = 150; public const int MaxTotal = 180;
public const int MinTotal = 5; public const int MinTotal = 5;
public const int DefaultTotal = 125; public const int DefaultTotal = 125;

View File

@@ -7,44 +7,13 @@ public static class ControlHelper
{ {
static bool _invert = false; static bool _invert = false;
static bool _darkTheme = false;
static float _scale = 1; static float _scale = 1;
static Color formBack; public static void Adjust(RForm container, bool invert = false)
static Color backMain;
static Color foreMain;
static Color foreAccent;
static Color borderMain;
static Color buttonMain;
public static void Adjust(RForm container, bool darkTheme = false, bool invert = false)
{ {
_darkTheme = darkTheme; container.BackColor = RForm.formBack;
container.ForeColor = RForm.foreMain;
if (darkTheme)
{
formBack = Color.FromArgb(255, 35, 35, 35);
backMain = Color.FromArgb(255, 50, 50, 50);
foreMain = Color.FromArgb(255, 240, 240, 240);
foreAccent = Color.FromArgb(255, 100, 100, 100);
borderMain = Color.FromArgb(255, 50, 50, 50);
buttonMain = Color.FromArgb(255, 80, 80, 80);
}
else
{
formBack = SystemColors.Control;
backMain = SystemColors.ControlLightLight;
foreMain = SystemColors.ControlText;
foreAccent = Color.LightGray;
borderMain = Color.LightGray;
buttonMain = Color.FromArgb(255, 230, 230, 230);
}
container.BackColor = formBack;
container.ForeColor = foreMain;
_invert = invert; _invert = invert;
AdjustControls(container.Controls); AdjustControls(container.Controls);
@@ -85,11 +54,11 @@ public static class ControlHelper
var button = control as RButton; var button = control as RButton;
if (button != null) if (button != null)
{ {
button.BackColor = button.Secondary ? buttonMain : backMain; button.BackColor = button.Secondary ? RForm.buttonSecond : RForm.buttonMain;
button.ForeColor = foreMain; button.ForeColor = RForm.foreMain;
button.FlatStyle = FlatStyle.Flat; button.FlatStyle = FlatStyle.Flat;
button.FlatAppearance.BorderColor = borderMain; button.FlatAppearance.BorderColor = RForm.borderMain;
if (button.Image is not null) if (button.Image is not null)
button.Image = AdjustImage(button.Image); button.Image = AdjustImage(button.Image);
@@ -103,46 +72,52 @@ public static class ControlHelper
var combo = control as RComboBox; var combo = control as RComboBox;
if (combo != null) if (combo != null)
{ {
combo.BackColor = backMain; combo.BackColor = RForm.buttonMain;
combo.ForeColor = foreMain; combo.ForeColor = RForm.foreMain;
combo.BorderColor = backMain; combo.BorderColor = RForm.buttonMain;
combo.ButtonColor = backMain; combo.ButtonColor = RForm.buttonMain;
combo.ArrowColor = foreMain; combo.ArrowColor = RForm.foreMain;
} }
var gb = control as GroupBox; var gb = control as GroupBox;
if (gb != null) if (gb != null)
{ {
gb.ForeColor = foreMain; gb.ForeColor = RForm.foreMain;
} }
var sl = control as Slider; var sl = control as Slider;
if (sl != null) if (sl != null)
{ {
sl.borderColor = buttonMain; sl.borderColor = RForm.buttonMain;
}
var chk = control as CheckBox;
if (chk != null && chk.Padding.Left > 5)
{
chk.BackColor = RForm.buttonSecond;
} }
var chart = control as Chart; var chart = control as Chart;
if (chart != null) if (chart != null)
{ {
chart.BackColor = backMain; chart.BackColor = RForm.chartMain;
chart.ChartAreas[0].BackColor = backMain; chart.ChartAreas[0].BackColor = RForm.chartMain;
chart.ChartAreas[0].AxisX.TitleForeColor = foreMain; chart.ChartAreas[0].AxisX.TitleForeColor = RForm.foreMain;
chart.ChartAreas[0].AxisY.TitleForeColor = foreMain; chart.ChartAreas[0].AxisY.TitleForeColor = RForm.foreMain;
chart.ChartAreas[0].AxisX.LabelStyle.ForeColor = foreMain; chart.ChartAreas[0].AxisX.LabelStyle.ForeColor = RForm.foreMain;
chart.ChartAreas[0].AxisY.LabelStyle.ForeColor = foreMain; chart.ChartAreas[0].AxisY.LabelStyle.ForeColor = RForm.foreMain;
chart.ChartAreas[0].AxisX.MajorTickMark.LineColor = foreMain; chart.ChartAreas[0].AxisX.MajorTickMark.LineColor = RForm.foreMain;
chart.ChartAreas[0].AxisY.MajorTickMark.LineColor = foreMain; chart.ChartAreas[0].AxisY.MajorTickMark.LineColor = RForm.foreMain;
chart.ChartAreas[0].AxisX.MajorGrid.LineColor = foreAccent; chart.ChartAreas[0].AxisX.MajorGrid.LineColor = RForm.chartGrid;
chart.ChartAreas[0].AxisY.MajorGrid.LineColor = foreAccent; chart.ChartAreas[0].AxisY.MajorGrid.LineColor = RForm.chartGrid;
chart.ChartAreas[0].AxisX.LineColor = foreAccent; chart.ChartAreas[0].AxisX.LineColor = RForm.chartGrid;
chart.ChartAreas[0].AxisY.LineColor = foreAccent; chart.ChartAreas[0].AxisY.LineColor = RForm.chartGrid;
chart.Titles[0].ForeColor = foreMain; chart.Titles[0].ForeColor = RForm.foreMain;
} }

View File

@@ -1,6 +1,5 @@
using Microsoft.Win32; using Microsoft.Win32;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
@@ -10,9 +9,18 @@ namespace CustomControls
public class RForm : Form public class RForm : Form
{ {
protected static Color colorEco = Color.FromArgb(255, 6, 180, 138); public static Color colorEco = Color.FromArgb(255, 6, 180, 138);
protected static Color colorStandard = Color.FromArgb(255, 58, 174, 239); public static Color colorStandard = Color.FromArgb(255, 58, 174, 239);
protected static Color colorTurbo = Color.FromArgb(255, 255, 32, 32); public static Color colorTurbo = Color.FromArgb(255, 255, 32, 32);
public static Color buttonMain;
public static Color buttonSecond;
public static Color formBack;
public static Color foreMain;
public static Color borderMain;
public static Color chartMain;
public static Color chartGrid;
[DllImport("UXTheme.dll", SetLastError = true, EntryPoint = "#138")] [DllImport("UXTheme.dll", SetLastError = true, EntryPoint = "#138")]
public static extern bool CheckSystemDarkModeStatus(); public static extern bool CheckSystemDarkModeStatus();
@@ -22,6 +30,34 @@ namespace CustomControls
public bool darkTheme; public bool darkTheme;
public static void InitColors(bool darkTheme)
{
if (darkTheme)
{
buttonMain = Color.FromArgb(255, 55, 55, 55);
buttonSecond = Color.FromArgb(255, 38, 38, 38);
formBack = Color.FromArgb(255, 28, 28, 28);
foreMain = Color.FromArgb(255, 240, 240, 240);
borderMain = Color.FromArgb(255, 50, 50, 50);
chartMain = Color.FromArgb(255, 35, 35, 35);
chartGrid = Color.FromArgb(255, 70, 70, 70);
}
else
{
buttonMain = SystemColors.ControlLightLight;
buttonSecond = SystemColors.ControlLight;
formBack = SystemColors.Control;
foreMain = SystemColors.ControlText;
borderMain = Color.LightGray;
chartMain = SystemColors.ControlLightLight;
chartGrid = Color.LightGray;
}
}
private static bool IsDarkTheme() private static bool IsDarkTheme()
{ {
using var key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize"); using var key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize");
@@ -37,13 +73,15 @@ namespace CustomControls
bool changed = (darkTheme != newDarkTheme); bool changed = (darkTheme != newDarkTheme);
darkTheme = newDarkTheme; darkTheme = newDarkTheme;
InitColors(darkTheme);
if (setDPI) if (setDPI)
ControlHelper.Resize(this); ControlHelper.Resize(this);
if (changed) if (changed)
{ {
DwmSetWindowAttribute(this.Handle, 20, new[] { darkTheme ? 1 : 0 }, 4); DwmSetWindowAttribute(this.Handle, 20, new[] { darkTheme ? 1 : 0 }, 4);
ControlHelper.Adjust(this, darkTheme, changed); ControlHelper.Adjust(this, changed);
} }
return changed; return changed;
@@ -53,7 +91,13 @@ namespace CustomControls
} }
public class RComboBox : ComboBox public class RCheckBox : CheckBox
{
}
public class RComboBox : ComboBox
{ {
private Color borderColor = Color.Gray; private Color borderColor = Color.Gray;
[DefaultValue(typeof(Color), "Gray")] [DefaultValue(typeof(Color), "Gray")]

151
app/Fans.Designer.cs generated
View File

@@ -31,12 +31,12 @@ namespace GHelper
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
ChartArea chartArea1 = new ChartArea(); ChartArea chartArea4 = new ChartArea();
Title title1 = new Title(); Title title4 = new Title();
ChartArea chartArea2 = new ChartArea(); ChartArea chartArea5 = new ChartArea();
Title title2 = new Title(); Title title5 = new Title();
ChartArea chartArea3 = new ChartArea(); ChartArea chartArea6 = new ChartArea();
Title title3 = new Title(); Title title6 = new Title();
panelFans = new Panel(); panelFans = new Panel();
labelTip = new Label(); labelTip = new Label();
labelBoost = new Label(); labelBoost = new Label();
@@ -47,14 +47,12 @@ namespace GHelper
chartCPU = new Chart(); chartCPU = new Chart();
chartMid = new Chart(); chartMid = new Chart();
labelFans = new Label(); labelFans = new Label();
checkAuto = new CheckBox(); checkApplyFans = new RCheckBox();
buttonReset = new RButton(); buttonReset = new RButton();
buttonApply = new RButton();
panelPower = new Panel(); panelPower = new Panel();
pictureBox1 = new PictureBox(); pictureBox1 = new PictureBox();
labelPowerLimits = new Label(); labelPowerLimits = new Label();
checkApplyPower = new CheckBox(); checkApplyPower = new RCheckBox();
buttonApplyPower = new RButton();
panelCPU = new Panel(); panelCPU = new Panel();
labelCPU = new Label(); labelCPU = new Label();
label2 = new Label(); label2 = new Label();
@@ -63,7 +61,6 @@ namespace GHelper
labelTotal = new Label(); labelTotal = new Label();
label1 = new Label(); label1 = new Label();
trackTotal = new TrackBar(); trackTotal = new TrackBar();
labelApplied = new Label();
pictureFine = new PictureBox(); pictureFine = new PictureBox();
labelInfo = new Label(); labelInfo = new Label();
panelFans.SuspendLayout(); panelFans.SuspendLayout();
@@ -89,9 +86,8 @@ namespace GHelper
panelFans.Controls.Add(picturePerf); panelFans.Controls.Add(picturePerf);
panelFans.Controls.Add(tableFanCharts); panelFans.Controls.Add(tableFanCharts);
panelFans.Controls.Add(labelFans); panelFans.Controls.Add(labelFans);
panelFans.Controls.Add(checkAuto); panelFans.Controls.Add(checkApplyFans);
panelFans.Controls.Add(buttonReset); panelFans.Controls.Add(buttonReset);
panelFans.Controls.Add(buttonApply);
panelFans.Dock = DockStyle.Left; panelFans.Dock = DockStyle.Left;
panelFans.Location = new Point(364, 0); panelFans.Location = new Point(364, 0);
panelFans.Margin = new Padding(0); panelFans.Margin = new Padding(0);
@@ -104,7 +100,7 @@ namespace GHelper
// //
labelTip.AutoSize = true; labelTip.AutoSize = true;
labelTip.BackColor = SystemColors.ControlLightLight; labelTip.BackColor = SystemColors.ControlLightLight;
labelTip.Location = new Point(245, 13); labelTip.Location = new Point(271, 13);
labelTip.Name = "labelTip"; labelTip.Name = "labelTip";
labelTip.Padding = new Padding(5); labelTip.Padding = new Padding(5);
labelTip.Size = new Size(107, 42); labelTip.Size = new Size(107, 42);
@@ -124,6 +120,7 @@ namespace GHelper
// //
comboBoost.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; comboBoost.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
comboBoost.BorderColor = Color.White; comboBoost.BorderColor = Color.White;
comboBoost.ButtonColor = Color.FromArgb(255, 255, 255);
comboBoost.DropDownStyle = ComboBoxStyle.DropDownList; comboBoost.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoost.FormattingEnabled = true; comboBoost.FormattingEnabled = true;
comboBoost.Items.AddRange(new object[] { "Disabled", "Enabled", "Aggressive", "Efficient Enabled", "Efficient Aggressive" }); comboBoost.Items.AddRange(new object[] { "Disabled", "Enabled", "Aggressive", "Efficient Enabled", "Efficient Aggressive" });
@@ -164,8 +161,8 @@ namespace GHelper
// //
// chartGPU // chartGPU
// //
chartArea1.Name = "ChartArea1"; chartArea4.Name = "ChartArea1";
chartGPU.ChartAreas.Add(chartArea1); chartGPU.ChartAreas.Add(chartArea4);
chartGPU.Dock = DockStyle.Fill; chartGPU.Dock = DockStyle.Fill;
chartGPU.Location = new Point(2, 340); chartGPU.Location = new Point(2, 340);
chartGPU.Margin = new Padding(2, 10, 2, 10); chartGPU.Margin = new Padding(2, 10, 2, 10);
@@ -173,13 +170,13 @@ namespace GHelper
chartGPU.Size = new Size(760, 310); chartGPU.Size = new Size(760, 310);
chartGPU.TabIndex = 17; chartGPU.TabIndex = 17;
chartGPU.Text = "chartGPU"; chartGPU.Text = "chartGPU";
title1.Name = "Title1"; title4.Name = "Title1";
chartGPU.Titles.Add(title1); chartGPU.Titles.Add(title4);
// //
// chartCPU // chartCPU
// //
chartArea2.Name = "ChartArea1"; chartArea5.Name = "ChartArea1";
chartCPU.ChartAreas.Add(chartArea2); chartCPU.ChartAreas.Add(chartArea5);
chartCPU.Dock = DockStyle.Fill; chartCPU.Dock = DockStyle.Fill;
chartCPU.Location = new Point(2, 10); chartCPU.Location = new Point(2, 10);
chartCPU.Margin = new Padding(2, 10, 2, 10); chartCPU.Margin = new Padding(2, 10, 2, 10);
@@ -187,13 +184,13 @@ namespace GHelper
chartCPU.Size = new Size(760, 310); chartCPU.Size = new Size(760, 310);
chartCPU.TabIndex = 14; chartCPU.TabIndex = 14;
chartCPU.Text = "chartCPU"; chartCPU.Text = "chartCPU";
title2.Name = "Title1"; title5.Name = "Title1";
chartCPU.Titles.Add(title2); chartCPU.Titles.Add(title5);
// //
// chartMid // chartMid
// //
chartArea3.Name = "ChartArea3"; chartArea6.Name = "ChartArea3";
chartMid.ChartAreas.Add(chartArea3); chartMid.ChartAreas.Add(chartArea6);
chartMid.Dock = DockStyle.Fill; chartMid.Dock = DockStyle.Fill;
chartMid.Location = new Point(2, 670); chartMid.Location = new Point(2, 670);
chartMid.Margin = new Padding(2, 10, 2, 10); chartMid.Margin = new Padding(2, 10, 2, 10);
@@ -201,8 +198,8 @@ namespace GHelper
chartMid.Size = new Size(760, 312); chartMid.Size = new Size(760, 312);
chartMid.TabIndex = 14; chartMid.TabIndex = 14;
chartMid.Text = "chartMid"; chartMid.Text = "chartMid";
title3.Name = "Title3"; title6.Name = "Title3";
chartMid.Titles.Add(title3); chartMid.Titles.Add(title6);
chartMid.Visible = false; chartMid.Visible = false;
// //
// labelFans // labelFans
@@ -216,61 +213,44 @@ namespace GHelper
labelFans.TabIndex = 28; labelFans.TabIndex = 28;
labelFans.Text = "Fan Curves"; labelFans.Text = "Fan Curves";
// //
// checkAuto // checkApplyFans
// //
checkAuto.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; checkApplyFans.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
checkAuto.AutoSize = true; checkApplyFans.AutoSize = true;
checkAuto.Location = new Point(377, 1086); checkApplyFans.BackColor = SystemColors.ControlLight;
checkAuto.Margin = new Padding(4, 2, 4, 2); checkApplyFans.Location = new Point(449, 1084);
checkAuto.Name = "checkAuto"; checkApplyFans.Margin = new Padding(4, 2, 4, 2);
checkAuto.Size = new Size(165, 36); checkApplyFans.Name = "checkApplyFans";
checkAuto.TabIndex = 17; checkApplyFans.Padding = new Padding(15, 5, 15, 5);
checkAuto.Text = "Auto Apply"; checkApplyFans.Size = new Size(339, 46);
checkAuto.UseVisualStyleBackColor = true; checkApplyFans.TabIndex = 17;
checkApplyFans.Text = "Apply Custom Fan Curve";
checkApplyFans.UseVisualStyleBackColor = false;
// //
// buttonReset // buttonReset
// //
buttonReset.Activated = false; buttonReset.Activated = false;
buttonReset.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; buttonReset.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonReset.BackColor = Color.FromArgb(230, 230, 230); buttonReset.BackColor = SystemColors.ControlLight;
buttonReset.BorderColor = Color.Transparent; buttonReset.BorderColor = Color.Transparent;
buttonReset.BorderRadius = 2; buttonReset.BorderRadius = 2;
buttonReset.FlatStyle = FlatStyle.Flat; buttonReset.FlatStyle = FlatStyle.Flat;
buttonReset.Location = new Point(30, 1081); buttonReset.Location = new Point(30, 1084);
buttonReset.Margin = new Padding(4, 2, 4, 2); buttonReset.Margin = new Padding(4, 2, 4, 2);
buttonReset.Name = "buttonReset"; buttonReset.Name = "buttonReset";
buttonReset.Secondary = true; buttonReset.Secondary = true;
buttonReset.Size = new Size(232, 44); buttonReset.Size = new Size(232, 50);
buttonReset.TabIndex = 15; buttonReset.TabIndex = 15;
buttonReset.Text = "Factory Defaults"; buttonReset.Text = "Factory Defaults";
buttonReset.UseVisualStyleBackColor = false; buttonReset.UseVisualStyleBackColor = false;
// //
// buttonApply
//
buttonApply.Activated = false;
buttonApply.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonApply.BackColor = Color.FromArgb(230, 230, 230);
buttonApply.BorderColor = Color.Transparent;
buttonApply.BorderRadius = 2;
buttonApply.FlatStyle = FlatStyle.Flat;
buttonApply.Location = new Point(542, 1081);
buttonApply.Margin = new Padding(4, 2, 4, 2);
buttonApply.Name = "buttonApply";
buttonApply.Secondary = true;
buttonApply.Size = new Size(248, 44);
buttonApply.TabIndex = 14;
buttonApply.Text = "Apply Custom Curve";
buttonApply.UseVisualStyleBackColor = false;
//
// panelPower // panelPower
// //
panelPower.Controls.Add(pictureBox1); panelPower.Controls.Add(pictureBox1);
panelPower.Controls.Add(labelPowerLimits); panelPower.Controls.Add(labelPowerLimits);
panelPower.Controls.Add(checkApplyPower); panelPower.Controls.Add(checkApplyPower);
panelPower.Controls.Add(buttonApplyPower);
panelPower.Controls.Add(panelCPU); panelPower.Controls.Add(panelCPU);
panelPower.Controls.Add(panelTotal); panelPower.Controls.Add(panelTotal);
panelPower.Controls.Add(labelApplied);
panelPower.Controls.Add(pictureFine); panelPower.Controls.Add(pictureFine);
panelPower.Controls.Add(labelInfo); panelPower.Controls.Add(labelInfo);
panelPower.Dock = DockStyle.Left; panelPower.Dock = DockStyle.Left;
@@ -308,37 +288,22 @@ namespace GHelper
// //
checkApplyPower.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; checkApplyPower.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
checkApplyPower.AutoSize = true; checkApplyPower.AutoSize = true;
checkApplyPower.Location = new Point(27, 1039); checkApplyPower.BackColor = SystemColors.ControlLight;
checkApplyPower.Location = new Point(20, 1086);
checkApplyPower.Margin = new Padding(4, 2, 4, 2); checkApplyPower.Margin = new Padding(4, 2, 4, 2);
checkApplyPower.Name = "checkApplyPower"; checkApplyPower.Name = "checkApplyPower";
checkApplyPower.Size = new Size(165, 36); checkApplyPower.Padding = new Padding(15, 5, 15, 5);
checkApplyPower.Size = new Size(277, 46);
checkApplyPower.TabIndex = 25; checkApplyPower.TabIndex = 25;
checkApplyPower.Text = "Auto Apply"; checkApplyPower.Text = "Apply Power Limits";
checkApplyPower.UseVisualStyleBackColor = true; checkApplyPower.UseVisualStyleBackColor = false;
//
// buttonApplyPower
//
buttonApplyPower.Activated = false;
buttonApplyPower.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
buttonApplyPower.BackColor = Color.FromArgb(230, 230, 230);
buttonApplyPower.BorderColor = Color.Transparent;
buttonApplyPower.BorderRadius = 2;
buttonApplyPower.FlatStyle = FlatStyle.Flat;
buttonApplyPower.Location = new Point(20, 1081);
buttonApplyPower.Margin = new Padding(4, 2, 4, 2);
buttonApplyPower.Name = "buttonApplyPower";
buttonApplyPower.Secondary = true;
buttonApplyPower.Size = new Size(324, 44);
buttonApplyPower.TabIndex = 24;
buttonApplyPower.Text = "Apply Power Limits";
buttonApplyPower.UseVisualStyleBackColor = false;
// //
// panelCPU // panelCPU
// //
panelCPU.Controls.Add(labelCPU); panelCPU.Controls.Add(labelCPU);
panelCPU.Controls.Add(label2); panelCPU.Controls.Add(label2);
panelCPU.Controls.Add(trackCPU); panelCPU.Controls.Add(trackCPU);
panelCPU.Location = new Point(184, 93); panelCPU.Location = new Point(184, 72);
panelCPU.Margin = new Padding(4); panelCPU.Margin = new Padding(4);
panelCPU.Name = "panelCPU"; panelCPU.Name = "panelCPU";
panelCPU.Size = new Size(160, 510); panelCPU.Size = new Size(160, 510);
@@ -371,7 +336,7 @@ namespace GHelper
trackCPU.Location = new Point(48, 88); trackCPU.Location = new Point(48, 88);
trackCPU.Margin = new Padding(4, 2, 4, 2); trackCPU.Margin = new Padding(4, 2, 4, 2);
trackCPU.Maximum = 85; trackCPU.Maximum = 85;
trackCPU.Minimum = 15; trackCPU.Minimum = 5;
trackCPU.Name = "trackCPU"; trackCPU.Name = "trackCPU";
trackCPU.Orientation = Orientation.Vertical; trackCPU.Orientation = Orientation.Vertical;
trackCPU.Size = new Size(90, 416); trackCPU.Size = new Size(90, 416);
@@ -384,7 +349,7 @@ namespace GHelper
panelTotal.Controls.Add(labelTotal); panelTotal.Controls.Add(labelTotal);
panelTotal.Controls.Add(label1); panelTotal.Controls.Add(label1);
panelTotal.Controls.Add(trackTotal); panelTotal.Controls.Add(trackTotal);
panelTotal.Location = new Point(16, 93); panelTotal.Location = new Point(16, 72);
panelTotal.Margin = new Padding(4); panelTotal.Margin = new Padding(4);
panelTotal.Name = "panelTotal"; panelTotal.Name = "panelTotal";
panelTotal.Size = new Size(160, 512); panelTotal.Size = new Size(160, 512);
@@ -416,8 +381,8 @@ namespace GHelper
// //
trackTotal.Location = new Point(44, 88); trackTotal.Location = new Point(44, 88);
trackTotal.Margin = new Padding(4, 2, 4, 2); trackTotal.Margin = new Padding(4, 2, 4, 2);
trackTotal.Maximum = 150; trackTotal.Maximum = 180;
trackTotal.Minimum = 15; trackTotal.Minimum = 10;
trackTotal.Name = "trackTotal"; trackTotal.Name = "trackTotal";
trackTotal.Orientation = Orientation.Vertical; trackTotal.Orientation = Orientation.Vertical;
trackTotal.Size = new Size(90, 416); trackTotal.Size = new Size(90, 416);
@@ -426,17 +391,6 @@ namespace GHelper
trackTotal.TickStyle = TickStyle.TopLeft; trackTotal.TickStyle = TickStyle.TopLeft;
trackTotal.Value = 125; trackTotal.Value = 125;
// //
// labelApplied
//
labelApplied.AutoSize = true;
labelApplied.ForeColor = Color.Tomato;
labelApplied.Location = new Point(56, 54);
labelApplied.Margin = new Padding(4, 0, 4, 0);
labelApplied.Name = "labelApplied";
labelApplied.Size = new Size(143, 32);
labelApplied.TabIndex = 21;
labelApplied.Text = "Not Applied";
//
// pictureFine // pictureFine
// //
pictureFine.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; pictureFine.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
@@ -501,12 +455,10 @@ namespace GHelper
#endregion #endregion
private Panel panelFans; private Panel panelFans;
private CheckBox checkAuto; private RCheckBox checkApplyFans;
private RButton buttonReset; private RButton buttonReset;
private RButton buttonApply;
private Panel panelPower; private Panel panelPower;
private CheckBox checkApplyPower; private RCheckBox checkApplyPower;
private RButton buttonApplyPower;
private Panel panelCPU; private Panel panelCPU;
private Label labelCPU; private Label labelCPU;
private Label label2; private Label label2;
@@ -515,7 +467,6 @@ namespace GHelper
private Label labelTotal; private Label labelTotal;
private Label label1; private Label label1;
private TrackBar trackTotal; private TrackBar trackTotal;
private Label labelApplied;
private PictureBox pictureFine; private PictureBox pictureFine;
private Label labelInfo; private Label labelInfo;
private Label labelPowerLimits; private Label labelPowerLimits;

View File

@@ -13,76 +13,6 @@ namespace GHelper
Series seriesMid; Series seriesMid;
static int MinRPM, MaxRPM; static int MinRPM, MaxRPM;
static string ChartPercToRPM(int percentage, string unit = "")
{
if (percentage == 0) return "OFF";
return (200 * Math.Round((float)(MinRPM*100 + (MaxRPM - MinRPM) * percentage) / 200)).ToString() + unit;
}
void SetChart(Chart chart, int device)
{
string title;
if (device == 1)
title = "GPU Fan Profile";
else if (device == 2)
title = "Middle Fan Profile";
else
title = "CPU Fan Profile";
if (Program.settingsForm.perfName.Length > 0)
labelFans.Text = "Fan Profiles: " + Program.settingsForm.perfName;
chart.Titles[0].Text = title;
chart.ChartAreas[0].AxisX.Minimum = 10;
chart.ChartAreas[0].AxisX.Maximum = 100;
chart.ChartAreas[0].AxisX.Interval = 10;
chart.ChartAreas[0].AxisY.Minimum = 0;
chart.ChartAreas[0].AxisY.Maximum = 100;
chart.ChartAreas[0].AxisY.LabelStyle.Font = new Font("Arial", 7F);
var foreAccent = Color.FromArgb(255, 180, 180, 180);
chart.ChartAreas[0].AxisX.MajorGrid.LineColor = foreAccent;
chart.ChartAreas[0].AxisY.MajorGrid.LineColor = foreAccent;
chart.ChartAreas[0].AxisX.LineColor = foreAccent;
chart.ChartAreas[0].AxisY.LineColor = foreAccent;
for (int i = 0; i <= 90; i += 10)
chart.ChartAreas[0].AxisY.CustomLabels.Add(i - 2, i + 2, ChartPercToRPM(i));
chart.ChartAreas[0].AxisY.CustomLabels.Add(98, 102, "RPM");
chart.ChartAreas[0].AxisY.Interval = 10;
if (chart.Legends.Count > 0)
chart.Legends[0].Enabled = false;
}
private void Fans_Shown(object? sender, EventArgs e)
{
if (Height > Program.settingsForm.Height)
{
Top = Program.settingsForm.Top + Program.settingsForm.Height - Height;
}
else
{
MinimumSize = new Size(0, Program.settingsForm.Height);
Height = Program.settingsForm.Height;
Top = Program.settingsForm.Top;
}
Left = Program.settingsForm.Left - Width - 5;
}
public Fans() public Fans()
{ {
@@ -117,7 +47,6 @@ namespace GHelper
chartMid.MouseUp += ChartCPU_MouseUp; chartMid.MouseUp += ChartCPU_MouseUp;
buttonReset.Click += ButtonReset_Click; buttonReset.Click += ButtonReset_Click;
buttonApply.Click += ButtonApply_Click;
trackTotal.Maximum = ASUSWmi.MaxTotal; trackTotal.Maximum = ASUSWmi.MaxTotal;
trackTotal.Minimum = ASUSWmi.MinTotal; trackTotal.Minimum = ASUSWmi.MinTotal;
@@ -125,12 +54,13 @@ namespace GHelper
trackCPU.Maximum = ASUSWmi.MaxCPU; trackCPU.Maximum = ASUSWmi.MaxCPU;
trackCPU.Minimum = ASUSWmi.MinCPU; trackCPU.Minimum = ASUSWmi.MinCPU;
trackCPU.Scroll += TrackCPU_Scroll; trackCPU.Scroll += TrackPower_Scroll;
trackTotal.Scroll += TrackTotal_Scroll; trackTotal.Scroll += TrackPower_Scroll;
buttonApplyPower.Click += ButtonApplyPower_Click; trackCPU.MouseUp += TrackPower_MouseUp;
trackTotal.MouseUp += TrackPower_MouseUp;
checkAuto.Click += CheckAuto_Click; checkApplyFans.Click += CheckApplyFans_Click;
checkApplyPower.Click += CheckApplyPower_Click; checkApplyPower.Click += CheckApplyPower_Click;
//labelInfo.MaximumSize = new Size(280, 0); //labelInfo.MaximumSize = new Size(280, 0);
@@ -146,6 +76,79 @@ namespace GHelper
} }
static string ChartPercToRPM(int percentage, string unit = "")
{
if (percentage == 0) return "OFF";
return (200 * Math.Round((float)(MinRPM * 100 + (MaxRPM - MinRPM) * percentage) / 200)).ToString() + unit;
}
void SetChart(Chart chart, int device)
{
string title;
if (device == 1)
title = "GPU Fan Profile";
else if (device == 2)
title = "Middle Fan Profile";
else
title = "CPU Fan Profile";
if (Program.settingsForm.perfName.Length > 0)
labelFans.Text = "Fan Profiles: " + Program.settingsForm.perfName;
chart.Titles[0].Text = title;
chart.ChartAreas[0].AxisX.Minimum = 10;
chart.ChartAreas[0].AxisX.Maximum = 100;
chart.ChartAreas[0].AxisX.Interval = 10;
chart.ChartAreas[0].AxisY.Minimum = 0;
chart.ChartAreas[0].AxisY.Maximum = 100;
chart.ChartAreas[0].AxisY.LabelStyle.Font = new Font("Arial", 7F);
chart.ChartAreas[0].AxisX.MajorGrid.LineColor = chartGrid;
chart.ChartAreas[0].AxisY.MajorGrid.LineColor = chartGrid;
chart.ChartAreas[0].AxisX.LineColor = chartGrid;
chart.ChartAreas[0].AxisY.LineColor = chartGrid;
for (int i = 0; i <= 90; i += 10)
chart.ChartAreas[0].AxisY.CustomLabels.Add(i - 2, i + 2, ChartPercToRPM(i));
chart.ChartAreas[0].AxisY.CustomLabels.Add(98, 102, "RPM");
chart.ChartAreas[0].AxisY.Interval = 10;
if (chart.Legends.Count > 0)
chart.Legends[0].Enabled = false;
}
private void Fans_Shown(object? sender, EventArgs e)
{
if (Height > Program.settingsForm.Height)
{
Top = Program.settingsForm.Top + Program.settingsForm.Height - Height;
}
else
{
MinimumSize = new Size(0, Program.settingsForm.Height);
Height = Program.settingsForm.Height;
Top = Program.settingsForm.Top;
}
Left = Program.settingsForm.Left - Width - 5;
}
private void TrackPower_MouseUp(object? sender, MouseEventArgs e)
{
Program.settingsForm.AutoPower();
}
public void InitBoost() public void InitBoost()
{ {
@@ -168,13 +171,38 @@ namespace GHelper
if (sender is null) return; if (sender is null) return;
CheckBox chk = (CheckBox)sender; CheckBox chk = (CheckBox)sender;
Program.config.setConfigPerf("auto_apply_power", chk.Checked ? 1 : 0); Program.config.setConfigPerf("auto_apply_power", chk.Checked ? 1 : 0);
if (chk.Checked)
{
Program.settingsForm.AutoPower();
}
else
{
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, Program.config.getConfig("performance_mode"), "PerfMode");
Program.settingsForm.AutoFans();
}
} }
private void CheckAuto_Click(object? sender, EventArgs e) private void CheckApplyFans_Click(object? sender, EventArgs e)
{ {
if (sender is null) return; if (sender is null) return;
CheckBox chk = (CheckBox)sender; CheckBox chk = (CheckBox)sender;
Program.config.setConfigPerf("auto_apply", chk.Checked ? 1 : 0); Program.config.setConfigPerf("auto_apply", chk.Checked ? 1 : 0);
if (chk.Checked)
{
Program.settingsForm.AutoFans();
}
else
{
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, Program.config.getConfig("performance_mode"), "PerfMode");
Program.settingsForm.AutoPower();
}
} }
private void Fans_FormClosing(object? sender, FormClosingEventArgs e) private void Fans_FormClosing(object? sender, FormClosingEventArgs e)
@@ -186,11 +214,6 @@ namespace GHelper
} }
} }
private void ButtonApplyPower_Click(object? sender, EventArgs e)
{
Program.settingsForm.SetPower();
ApplyLabel(true);
}
public void InitPower(bool changed = false) public void InitPower(bool changed = false)
{ {
@@ -215,13 +238,11 @@ namespace GHelper
{ {
limit_total = trackTotal.Value; limit_total = trackTotal.Value;
limit_cpu = trackCPU.Value; limit_cpu = trackCPU.Value;
ApplyLabel(false);
} }
else else
{ {
limit_total = Program.config.getConfigPerf("limit_total"); limit_total = Program.config.getConfigPerf("limit_total");
limit_cpu = Program.config.getConfigPerf("limit_cpu"); limit_cpu = Program.config.getConfigPerf("limit_cpu");
ApplyLabel(apply);
} }
if (limit_total < 0) limit_total = ASUSWmi.DefaultTotal; if (limit_total < 0) limit_total = ASUSWmi.DefaultTotal;
@@ -243,34 +264,16 @@ namespace GHelper
Program.config.setConfigPerf("limit_total", limit_total); Program.config.setConfigPerf("limit_total", limit_total);
Program.config.setConfigPerf("limit_cpu", limit_cpu); Program.config.setConfigPerf("limit_cpu", limit_cpu);
} }
private void TrackTotal_Scroll(object? sender, EventArgs e) private void TrackPower_Scroll(object? sender, EventArgs e)
{ {
InitPower(true); InitPower(true);
} }
private void TrackCPU_Scroll(object? sender, EventArgs e)
{
InitPower(true);
}
public void ApplyLabel(bool applied = false)
{
if (applied)
{
labelApplied.ForeColor = colorStandard;
labelApplied.Text = "Applied";
}
else
{
labelApplied.ForeColor = colorTurbo;
labelApplied.Text = "Not Applied";
}
}
public void InitFans() public void InitFans()
{ {
@@ -299,7 +302,7 @@ namespace GHelper
int auto_apply = Program.config.getConfigPerf("auto_apply"); int auto_apply = Program.config.getConfigPerf("auto_apply");
checkAuto.Checked = (auto_apply == 1); checkApplyFans.Checked = (auto_apply == 1);
} }
@@ -351,16 +354,6 @@ namespace GHelper
} }
private void ButtonApply_Click(object? sender, EventArgs e)
{
SaveProfile(seriesCPU, 0);
SaveProfile(seriesGPU, 1);
if (Program.config.getConfig("mid_fan") == 1)
SaveProfile(seriesMid, 2);
Program.settingsForm.AutoFans(true);
}
private void ButtonReset_Click(object? sender, EventArgs e) private void ButtonReset_Click(object? sender, EventArgs e)
{ {
@@ -369,21 +362,28 @@ namespace GHelper
if (Program.config.getConfig("mid_fan") == 1) if (Program.config.getConfig("mid_fan") == 1)
LoadProfile(seriesMid, 2, 1); LoadProfile(seriesMid, 2, 1);
checkAuto.Checked = false; checkApplyFans.Checked = false;
checkApplyPower.Checked = false; checkApplyPower.Checked = false;
Program.config.setConfigPerf("auto_apply", 0); Program.config.setConfigPerf("auto_apply", 0);
Program.config.setConfigPerf("auto_apply_power", 0); Program.config.setConfigPerf("auto_apply_power", 0);
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, Program.config.getConfig("performance_mode"), "PerfMode"); Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, Program.config.getConfig("performance_mode"), "PerfMode");
ApplyLabel(false);
} }
private void ChartCPU_MouseUp(object? sender, MouseEventArgs e) private void ChartCPU_MouseUp(object? sender, MouseEventArgs e)
{ {
curPoint = null; curPoint = null;
labelTip.Visible = false; labelTip.Visible = false;
SaveProfile(seriesCPU, 0);
SaveProfile(seriesGPU, 1);
if (Program.config.getConfig("mid_fan") == 1)
SaveProfile(seriesMid, 2);
Program.settingsForm.AutoFans();
} }
private void ChartCPU_MouseMove(object? sender, MouseEventArgs e) private void ChartCPU_MouseMove(object? sender, MouseEventArgs e)

View File

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

View File

@@ -73,6 +73,24 @@ public class AmdGpuTemperatureProvider : IGpuTemperatureProvider {
return temperatureSensor.Value; return temperatureSensor.Value;
} }
public int? GetGpuUse()
{
if (!IsValid)
return null;
if (Adl2.NativeMethods.ADL2_New_QueryPMLogData_Get(_adlContextHandle, _internalDiscreteAdapter.AdapterIndex, out ADLPMLogDataOutput adlpmLogDataOutput) != Adl2.ADL_SUCCESS)
return null;
ADLSingleSensorData gpuUsage = adlpmLogDataOutput.Sensors[(int)ADLSensorType.PMLOG_INFO_ACTIVITY_GFX];
if (gpuUsage.Supported == 0)
return null;
return gpuUsage.Value;
}
private void ReleaseUnmanagedResources() { private void ReleaseUnmanagedResources() {
if (_adlContextHandle != IntPtr.Zero) { if (_adlContextHandle != IntPtr.Zero) {
Adl2.NativeMethods.ADL2_Main_Control_Destroy(_adlContextHandle); Adl2.NativeMethods.ADL2_Main_Control_Destroy(_adlContextHandle);

View File

@@ -3,4 +3,5 @@
public interface IGpuTemperatureProvider : IDisposable { public interface IGpuTemperatureProvider : IDisposable {
bool IsValid { get; } bool IsValid { get; }
int? GetCurrentTemperature(); int? GetCurrentTemperature();
int? GetGpuUse();
} }

View File

@@ -1,42 +1,68 @@
using NvAPIWrapper.GPU; using NvAPIWrapper.GPU;
using NvAPIWrapper.Native; using NvAPIWrapper.Native;
using NvAPIWrapper.Native.Exceptions;
using NvAPIWrapper.Native.GPU; using NvAPIWrapper.Native.GPU;
using NvAPIWrapper.Native.Interfaces.GPU; using NvAPIWrapper.Native.Interfaces.GPU;
namespace GHelper.Gpu; namespace GHelper.Gpu;
public class NvidiaGpuTemperatureProvider : IGpuTemperatureProvider { public class NvidiaGpuTemperatureProvider : IGpuTemperatureProvider
{
private readonly PhysicalGPU? _internalGpu; private readonly PhysicalGPU? _internalGpu;
public NvidiaGpuTemperatureProvider() { public NvidiaGpuTemperatureProvider()
{
_internalGpu = GetInternalDiscreteGpu(); _internalGpu = GetInternalDiscreteGpu();
} }
public bool IsValid => _internalGpu != null; public bool IsValid => _internalGpu != null;
public int? GetCurrentTemperature() { public int? GetCurrentTemperature()
{
if (!IsValid) if (!IsValid)
return null; return null;
PhysicalGPU internalGpu = _internalGpu!; PhysicalGPU internalGpu = _internalGpu!;
IThermalSensor? gpuSensor = IThermalSensor? gpuSensor =
GPUApi.GetThermalSettings(internalGpu.Handle).Sensors GPUApi.GetThermalSettings(internalGpu.Handle).Sensors
.FirstOrDefault(s => s.Target == ThermalSettingsTarget.GPU); .FirstOrDefault(s => s.Target == ThermalSettingsTarget.GPU);
return gpuSensor?.CurrentTemperature; return gpuSensor?.CurrentTemperature;
} }
public void Dispose() { public void Dispose()
{
} }
private static PhysicalGPU? GetInternalDiscreteGpu() { private static PhysicalGPU? GetInternalDiscreteGpu()
try { {
try
{
return PhysicalGPU return PhysicalGPU
.GetPhysicalGPUs() .GetPhysicalGPUs()
.FirstOrDefault(gpu => gpu.SystemType == SystemType.Laptop); .FirstOrDefault(gpu => gpu.SystemType == SystemType.Laptop);
} catch { }
catch
{
return null; return null;
} }
} }
public int? GetGpuUse()
{
if (!IsValid)
return null;
PhysicalGPU internalGpu = _internalGpu!;
IUtilizationDomainInfo? gpuUsage = GPUApi.GetUsages(internalGpu.Handle).GPU;
if (gpuUsage == null)
return null;
return
(int)gpuUsage?.Percentage;
}
} }

View File

@@ -1,6 +1,6 @@
using System.Diagnostics; using GHelper;
using GHelper;
using GHelper.Gpu; using GHelper.Gpu;
using System.Diagnostics;
public static class HardwareMonitor public static class HardwareMonitor
{ {
@@ -14,6 +14,9 @@ public static class HardwareMonitor
public static string? gpuFan; public static string? gpuFan;
public static string? midFan; public static string? midFan;
//public static List<int> gpuUsage = new List<int>();
public static int? gpuUse;
public static int GetFanMax() public static int GetFanMax()
{ {
int max = 58; int max = 58;
@@ -41,13 +44,29 @@ public static class HardwareMonitor
if (Program.config.getConfig("fan_rpm") == 1) if (Program.config.getConfig("fan_rpm") == 1)
return " Fan: " + (fan * 100).ToString() + "RPM"; return " Fan: " + (fan * 100).ToString() + "RPM";
else else
return " Fan: " + Math.Min(Math.Round((float)fan/fanMax*100), 100).ToString() + "%"; // relatively to 6000 rpm return " Fan: " + Math.Min(Math.Round((float)fan / fanMax * 100), 100).ToString() + "%"; // relatively to 6000 rpm
}
private static int GetGpuUse()
{
try
{
int? gpuUse = GpuTemperatureProvider?.GetGpuUse();
if (gpuUse is not null) return (int)gpuUse;
}
catch (Exception ex)
{
Debug.WriteLine(ex.ToString());
}
return 0;
} }
public static void ReadSensors() public static void ReadSensors()
{ {
batteryDischarge = -1; batteryDischarge = -1;
gpuTemp = -1; gpuTemp = -1;
gpuUse = -1;
cpuFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.CPU_Fan)); cpuFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.CPU_Fan));
gpuFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.GPU_Fan)); gpuFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.GPU_Fan));
@@ -55,32 +74,36 @@ public static class HardwareMonitor
cpuTemp = Program.wmi.DeviceGet(ASUSWmi.Temp_CPU); cpuTemp = Program.wmi.DeviceGet(ASUSWmi.Temp_CPU);
if (cpuTemp < 0) try if (cpuTemp < 0) try
{ {
var ct = new PerformanceCounter("Thermal Zone Information", "Temperature", @"\_TZ.THRM", true); var ct = new PerformanceCounter("Thermal Zone Information", "Temperature", @"\_TZ.THRM", true);
cpuTemp = ct.NextValue() - 273; cpuTemp = ct.NextValue() - 273;
ct.Dispose(); ct.Dispose();
} catch }
catch
{ {
Logger.WriteLine("Failed reading CPU temp"); Debug.WriteLine("Failed reading CPU temp");
} }
if (gpuTemp < 0) try try
{ {
if (GpuTemperatureProvider is null) RecreateGpuTemperatureProvider(); gpuTemp = GpuTemperatureProvider?.GetCurrentTemperature();
gpuTemp = GpuTemperatureProvider?.GetCurrentTemperature();
} }
catch (Exception ex) { catch (Exception ex)
{
gpuTemp = -1; gpuTemp = -1;
Logger.WriteLine("Failed reading GPU temp"); Debug.WriteLine("Failed reading GPU temp");
Logger.WriteLine(ex.ToString()); Debug.WriteLine(ex.ToString());
} }
if (gpuTemp is null || gpuTemp < 0) if (gpuTemp is null || gpuTemp < 0)
gpuTemp = Program.wmi.DeviceGet(ASUSWmi.Temp_GPU); gpuTemp = Program.wmi.DeviceGet(ASUSWmi.Temp_GPU);
/*
gpuUsage.Add(GetGpuUse());
if (gpuUsage.Count > 3) gpuUsage.RemoveAt(0);
*/
try try
{ {
@@ -91,15 +114,22 @@ public static class HardwareMonitor
} }
catch catch
{ {
Logger.WriteLine("Failed reading Battery discharge"); Debug.WriteLine("Failed reading Battery discharge");
} }
} }
public static void RecreateGpuTemperatureProviderWithDelay() { public static bool IsUsedGPU(int threshold = 50)
{
return (GetGpuUse() > threshold);
}
public static void RecreateGpuTemperatureProviderWithDelay()
{
// Re-enabling the discrete GPU takes a bit of time, // Re-enabling the discrete GPU takes a bit of time,
// so a simple workaround is to refresh again after that happens // so a simple workaround is to refresh again after that happens
Task.Run(async () => { Task.Run(async () =>
{
await Task.Delay(TimeSpan.FromSeconds(5)); await Task.Delay(TimeSpan.FromSeconds(5));
RecreateGpuTemperatureProvider(); RecreateGpuTemperatureProvider();
}); });
@@ -108,7 +138,8 @@ public static class HardwareMonitor
} }
public static void RecreateGpuTemperatureProvider() { public static void RecreateGpuTemperatureProvider()
{
try try
{ {
GpuTemperatureProvider?.Dispose(); GpuTemperatureProvider?.Dispose();
@@ -135,8 +166,8 @@ public static class HardwareMonitor
GpuTemperatureProvider = null; GpuTemperatureProvider = null;
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine(ex.ToString()); Debug.WriteLine(ex.ToString());
} }
} }
} }

View File

@@ -1,4 +1,5 @@
using CustomControls; using CustomControls;
using Microsoft.Win32;
namespace GHelper namespace GHelper
{ {
@@ -98,6 +99,16 @@ namespace GHelper
private void CheckKeyboardAuto_CheckedChanged(object? sender, EventArgs e) private void CheckKeyboardAuto_CheckedChanged(object? sender, EventArgs e)
{ {
Program.config.setConfig("keyboard_auto", (checkKeyboardAuto.Checked ? 1 : 0)); Program.config.setConfig("keyboard_auto", (checkKeyboardAuto.Checked ? 1 : 0));
/*
RegistryKey myKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\ASUS\\ASUS System Control Interface\\AsusOptimization\\ASUS Keyboard Hotkeys", true);
if (myKey != null)
{
myKey.SetValue("TurnOffKeybdLight", 30, RegistryValueKind.DWord);
myKey.Close();
}
*/
} }
private void CheckTopmost_CheckedChanged(object? sender, EventArgs e) private void CheckTopmost_CheckedChanged(object? sender, EventArgs e)

View File

@@ -74,6 +74,8 @@ namespace GHelper
SetAutoModes(); SetAutoModes();
HardwareMonitor.RecreateGpuTemperatureProvider();
// Subscribing for system power change events // Subscribing for system power change events
SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged; SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
SystemEvents.UserPreferenceChanged += SystemEvents_UserPreferenceChanged; SystemEvents.UserPreferenceChanged += SystemEvents_UserPreferenceChanged;

View File

@@ -163,6 +163,7 @@ namespace GHelper
// comboMatrix // comboMatrix
// //
comboMatrix.BorderColor = Color.White; comboMatrix.BorderColor = Color.White;
comboMatrix.ButtonColor = Color.FromArgb(255, 255, 255);
comboMatrix.Dock = DockStyle.Top; comboMatrix.Dock = DockStyle.Top;
comboMatrix.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point); comboMatrix.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
comboMatrix.FormattingEnabled = true; comboMatrix.FormattingEnabled = true;
@@ -178,6 +179,7 @@ namespace GHelper
// comboMatrixRunning // comboMatrixRunning
// //
comboMatrixRunning.BorderColor = Color.White; comboMatrixRunning.BorderColor = Color.White;
comboMatrixRunning.ButtonColor = Color.FromArgb(255, 255, 255);
comboMatrixRunning.Dock = DockStyle.Top; comboMatrixRunning.Dock = DockStyle.Top;
comboMatrixRunning.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point); comboMatrixRunning.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
comboMatrixRunning.FormattingEnabled = true; comboMatrixRunning.FormattingEnabled = true;
@@ -193,7 +195,7 @@ namespace GHelper
// buttonMatrix // buttonMatrix
// //
buttonMatrix.Activated = false; buttonMatrix.Activated = false;
buttonMatrix.BackColor = Color.FromArgb(230, 230, 230); buttonMatrix.BackColor = SystemColors.ControlLight;
buttonMatrix.BorderColor = Color.Transparent; buttonMatrix.BorderColor = Color.Transparent;
buttonMatrix.BorderRadius = 2; buttonMatrix.BorderRadius = 2;
buttonMatrix.Dock = DockStyle.Top; buttonMatrix.Dock = DockStyle.Top;
@@ -333,7 +335,7 @@ namespace GHelper
// //
buttonQuit.Activated = false; buttonQuit.Activated = false;
buttonQuit.Anchor = AnchorStyles.Top | AnchorStyles.Right; buttonQuit.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonQuit.BackColor = Color.FromArgb(230, 230, 230); buttonQuit.BackColor = SystemColors.ControlLight;
buttonQuit.BorderColor = Color.Transparent; buttonQuit.BorderColor = Color.Transparent;
buttonQuit.BorderRadius = 2; buttonQuit.BorderRadius = 2;
buttonQuit.FlatStyle = FlatStyle.Flat; buttonQuit.FlatStyle = FlatStyle.Flat;
@@ -501,7 +503,7 @@ namespace GHelper
// buttonFans // buttonFans
// //
buttonFans.Activated = false; buttonFans.Activated = false;
buttonFans.BackColor = Color.FromArgb(230, 230, 230); buttonFans.BackColor = SystemColors.ControlLight;
buttonFans.BorderColor = Color.Transparent; buttonFans.BorderColor = Color.Transparent;
buttonFans.BorderRadius = 5; buttonFans.BorderRadius = 5;
buttonFans.Dock = DockStyle.Fill; buttonFans.Dock = DockStyle.Fill;
@@ -888,6 +890,7 @@ namespace GHelper
// comboKeyboard // comboKeyboard
// //
comboKeyboard.BorderColor = Color.White; comboKeyboard.BorderColor = Color.White;
comboKeyboard.ButtonColor = Color.FromArgb(255, 255, 255);
comboKeyboard.Dock = DockStyle.Top; comboKeyboard.Dock = DockStyle.Top;
comboKeyboard.FlatStyle = FlatStyle.Flat; comboKeyboard.FlatStyle = FlatStyle.Flat;
comboKeyboard.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point); comboKeyboard.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
@@ -955,7 +958,7 @@ namespace GHelper
// buttonKeyboard // buttonKeyboard
// //
buttonKeyboard.Activated = false; buttonKeyboard.Activated = false;
buttonKeyboard.BackColor = Color.FromArgb(230, 230, 230); buttonKeyboard.BackColor = SystemColors.ControlLight;
buttonKeyboard.BorderColor = Color.Transparent; buttonKeyboard.BorderColor = Color.Transparent;
buttonKeyboard.BorderRadius = 2; buttonKeyboard.BorderRadius = 2;
buttonKeyboard.Dock = DockStyle.Top; buttonKeyboard.Dock = DockStyle.Top;

View File

@@ -25,7 +25,6 @@ namespace GHelper
public Keyboard keyb; public Keyboard keyb;
static AnimeMatrixDevice mat; static AnimeMatrixDevice mat;
static int matrixTick = 0;
static long lastRefresh; static long lastRefresh;
public SettingsForm() public SettingsForm()
@@ -272,10 +271,7 @@ namespace GHelper
break; break;
case 1: case 1:
Logger.WriteLine("Monitor Power On"); Logger.WriteLine("Monitor Power On");
Program.settingsForm.BeginInvoke(delegate Program.SetAutoModes();
{
Program.SetAutoModes();
});
break; break;
case 2: case 2:
Logger.WriteLine("Monitor Dimmed"); Logger.WriteLine("Monitor Dimmed");
@@ -812,14 +808,14 @@ namespace GHelper
HardwareMonitor.ReadSensors(); HardwareMonitor.ReadSensors();
if (HardwareMonitor.cpuTemp > 0) if (HardwareMonitor.cpuTemp > 0)
cpuTemp = ": " + Math.Round((decimal)HardwareMonitor.cpuTemp).ToString() + "°C - "; cpuTemp = ": " + Math.Round((decimal)HardwareMonitor.cpuTemp).ToString() + "°C ";
if (HardwareMonitor.batteryDischarge > 0) if (HardwareMonitor.batteryDischarge > 0)
battery = "Discharging: " + Math.Round((decimal)HardwareMonitor.batteryDischarge, 1).ToString() + "W"; battery = "Discharging: " + Math.Round((decimal)HardwareMonitor.batteryDischarge, 1).ToString() + "W";
if (HardwareMonitor.gpuTemp > 0) if (HardwareMonitor.gpuTemp > 0)
{ {
gpuTemp = $": {HardwareMonitor.gpuTemp}°C - "; gpuTemp = $": {HardwareMonitor.gpuTemp}°C ";
} }
Program.settingsForm.BeginInvoke(delegate Program.settingsForm.BeginInvoke(delegate
@@ -849,10 +845,7 @@ namespace GHelper
this.Top = Screen.FromControl(this).WorkingArea.Height - 10 - this.Height; this.Top = Screen.FromControl(this).WorkingArea.Height - 10 - this.Height;
this.Activate(); this.Activate();
//aTimer.Interval = 300;
aTimer.Enabled = true; aTimer.Enabled = true;
//RefreshSensors();
} }
else else
{ {
@@ -877,16 +870,13 @@ namespace GHelper
if (Program.wmi.DeviceGet(ASUSWmi.PPT_CPUB0) >= 0) if (Program.wmi.DeviceGet(ASUSWmi.PPT_CPUB0) >= 0)
Program.wmi.DeviceSet(ASUSWmi.PPT_CPUB0, limit_cpu, "PowerLimit B"); Program.wmi.DeviceSet(ASUSWmi.PPT_CPUB0, limit_cpu, "PowerLimit B");
} }
public void AutoFans(bool force = false) public void AutoFans()
{ {
if (force || Program.config.getConfigPerf("auto_apply") == 1) if (Program.config.getConfigPerf("auto_apply") == 1)
{ {
int cpuResult = Program.wmi.SetFanCurve(0, Program.config.getFanConfig(0)); int cpuResult = Program.wmi.SetFanCurve(0, Program.config.getFanConfig(0));
int gpuResult = Program.wmi.SetFanCurve(1, Program.config.getFanConfig(1)); int gpuResult = Program.wmi.SetFanCurve(1, Program.config.getFanConfig(1));
@@ -897,7 +887,7 @@ namespace GHelper
if (cpuResult != 1 || gpuResult != 1) // something went wrong, resetting to default profile if (cpuResult != 1 || gpuResult != 1) // something went wrong, resetting to default profile
{ {
int mode = Program.config.getConfig("performance_mode"); int mode = Program.config.getConfig("performance_mode");
Logger.WriteLine("Bios rejected fan curve, resetting mode to " + mode); Logger.WriteLine("Driver rejected fan curve, resetting mode to " + mode);
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, mode, "PerformanceMode"); Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, mode, "PerformanceMode");
} }
else else
@@ -908,26 +898,36 @@ namespace GHelper
} }
public void AutoPower(bool force = false) public void AutoPower(int delay = 0)
{ {
if (force || Program.config.getConfigPerf("auto_apply_power") == 1) if (Program.config.getConfigPerf("auto_apply_power") == 1)
{ {
var timer = new System.Timers.Timer(1000); if (delay > 0)
timer.Elapsed += delegate {
var timer = new System.Timers.Timer(1000);
timer.Elapsed += delegate
{
timer.Stop();
timer.Dispose();
SetPower();
};
timer.Start();
}
else
{ {
timer.Stop();
timer.Dispose();
SetPower(); SetPower();
}; }
timer.Start();
} }
} }
public void SetPerformanceMode(int PerformanceMode = ASUSWmi.PerformanceBalanced, bool notify = false) public void SetPerformanceMode(int PerformanceMode = -1, bool notify = false)
{ {
if (PerformanceMode < 0)
PerformanceMode = Program.config.getConfig("performance_mode");
buttonSilent.Activated = false; buttonSilent.Activated = false;
buttonBalanced.Activated = false; buttonBalanced.Activated = false;
@@ -969,7 +969,7 @@ namespace GHelper
} }
AutoFans(); AutoFans();
AutoPower(); AutoPower(1000);
if (Program.config.getConfigPerf("auto_boost") != -1) if (Program.config.getConfigPerf("auto_boost") != -1)
{ {
@@ -1007,10 +1007,10 @@ namespace GHelper
if (SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online) if (SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online)
Aura.ApplyBrightness(3); Aura.ApplyBrightness(3);
//Program.wmi.DeviceSet(ASUSWmi.UniversalControl, ASUSWmi.KB_Light_Up); //Program.wmi.DeviceSet(ASUSWmi.UniversalControl, ASUSWmi.KB_Light_Up);
else else
Aura.ApplyBrightness(0); Aura.ApplyBrightness(0);
//Program.wmi.DeviceSet(ASUSWmi.UniversalControl, ASUSWmi.KB_Light_Down); //Program.wmi.DeviceSet(ASUSWmi.UniversalControl, ASUSWmi.KB_Light_Down);
} }
@@ -1067,6 +1067,13 @@ namespace GHelper
if (eco == 0) if (eco == 0)
if ((GpuAuto && Plugged != PowerLineStatus.Online) || (ForceGPU && GpuMode == ASUSWmi.GPUModeEco)) if ((GpuAuto && Plugged != PowerLineStatus.Online) || (ForceGPU && GpuMode == ASUSWmi.GPUModeEco))
{ {
if (HardwareMonitor.IsUsedGPU())
{
DialogResult dialogResult = MessageBox.Show("Your dGPU seem to be in heavy use, disable it?", "Eco Mode", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.No) return false;
}
SetEcoGPU(1); SetEcoGPU(1);
return true; return true;
} }