Compare commits

...

48 Commits
v0.40 ... v0.46

Author SHA1 Message Date
seerge
dcfaf665cd Force GPU mode 2023-04-02 22:50:13 +02:00
seerge
15e791cbfd Merge branch 'main' of https://github.com/seerge/g-helper 2023-04-02 11:57:01 +02:00
seerge
5d86c821f6 Minor fixes 2023-04-02 11:56:59 +02:00
Serge
e5de404e5c Update README.md 2023-04-01 17:48:46 +02:00
Serge
13aa98e954 Update README.md 2023-04-01 17:40:36 +02:00
seerge
75c397d7a4 Merge branch 'main' of https://github.com/seerge/g-helper 2023-03-31 23:08:06 +02:00
seerge
0ad8efdb7d GPU temp reading 2023-03-31 23:08:04 +02:00
Serge
2064f29433 Update README.md 2023-03-31 23:07:43 +02:00
seerge
890c50d90e Merge branch 'main' of https://github.com/seerge/g-helper 2023-03-31 20:05:16 +02:00
seerge
bd207113f8 Fix for possible fan issues on old laptops 2023-03-31 20:05:14 +02:00
Serge
650a5ff5c0 Update bug_report.md 2023-03-31 17:29:57 +02:00
Serge
01ce91a474 Update bug_report.md 2023-03-31 15:58:28 +02:00
seerge
253e1eb095 Added Strix/Scar built in aura modes 2023-03-31 13:50:10 +02:00
seerge
b95768d547 Merge branch 'main' of https://github.com/seerge/g-helper 2023-03-31 11:45:48 +02:00
seerge
dfbfd16d23 Clock fix 2023-03-31 11:45:46 +02:00
Serge
3eeac0353a Update README.md 2023-03-30 22:03:21 +02:00
Serge
5e7c9a4191 Update README.md 2023-03-30 21:56:59 +02:00
seerge
ee84ba6304 Merge branch 'main' of https://github.com/seerge/g-helper 2023-03-30 21:10:36 +02:00
seerge
d15c6cb073 Improved logging 2023-03-30 21:10:35 +02:00
Serge
1e683a0884 Update README.md 2023-03-30 15:00:04 +02:00
Serge
1ad48bf763 Update README.md 2023-03-30 13:54:53 +02:00
Serge
dcc052a574 Update README.md 2023-03-30 13:54:40 +02:00
Serge
38fca560df Update README.md 2023-03-30 12:14:29 +02:00
seerge
7e0459bd44 Merge branch 'main' of https://github.com/seerge/g-helper 2023-03-30 11:57:13 +02:00
seerge
228ad70b8d UI tweaks 2023-03-30 11:57:11 +02:00
Serge
b42e565cd6 Update README.md 2023-03-30 11:53:54 +02:00
Serge
e021d59737 Update README.md 2023-03-30 11:20:50 +02:00
Serge
dba7967ad5 Update README.md 2023-03-30 11:12:24 +02:00
seerge
a7a7170676 Merge branch 'main' of https://github.com/seerge/g-helper 2023-03-30 00:00:22 +02:00
seerge
1d43ca3ce4 Max fan RPM auto calibration 2023-03-30 00:00:20 +02:00
Serge
ff7618f16f Update README.md 2023-03-29 23:33:14 +02:00
seerge
bb947bf8bf Merge branch 'main' of https://github.com/seerge/g-helper 2023-03-29 23:32:14 +02:00
seerge
63092d8415 Removed unsupported aura modes for some models 2023-03-29 23:32:12 +02:00
Serge
6fbce2f495 Update README.md 2023-03-29 21:06:36 +02:00
seerge
8d89a04608 Merge branch 'main' of https://github.com/seerge/g-helper 2023-03-29 17:51:28 +02:00
seerge
0cbc48d526 Added old cpu temp reading as fallback 2023-03-29 17:51:25 +02:00
Serge
81013ca0be Update README.md 2023-03-29 17:32:07 +02:00
seerge
af2509fc17 Merge branch 'main' of https://github.com/seerge/g-helper 2023-03-29 17:04:24 +02:00
seerge
136b5b4f55 Added native temp sensors, brightness controll, etc 2023-03-29 17:04:22 +02:00
Serge
4e2abff942 Update README.md 2023-03-29 13:58:03 +02:00
Serge
2c8a11fc24 Update README.md 2023-03-29 12:26:19 +02:00
seerge
8af8823ee4 Merge branch 'main' of https://github.com/seerge/g-helper 2023-03-29 12:19:02 +02:00
seerge
ec0a1b710e New slider 2023-03-29 12:19:00 +02:00
Serge
2ac2e84161 Update README.md 2023-03-28 22:09:06 +02:00
seerge
14dc1741f7 New battery slider 2023-03-28 20:11:30 +02:00
seerge
fbed195194 - 2023-03-28 16:35:20 +02:00
seerge
0d002edf65 Animatrix fix for 2020/2021 models 2023-03-28 16:05:24 +02:00
seerge
28a17562a8 CPU boost per mode 2023-03-28 14:19:51 +02:00
18 changed files with 632 additions and 261 deletions

View File

@@ -1,31 +1,40 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
**Clear scenario to Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
4. Explanation of an error or a bug
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
**App Logs**
Please include and attach log.txt from ``%AppData%\GHelper``
**Screenshots or screencasts**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- OS: [e.g. Windows 11]
- Laptop model
**Asus software**
- Armoury crate (or it's services installed)
- MyASUS installed
- Other Asus services running in background
**Additional context**
Add any other context about the problem here.
## NOTE
Bug reports without clear information or scenario to reproduce will be closed without answer.
Please respect time of the developer. Thanks.

View File

@@ -31,6 +31,10 @@ public class ASUSWmi
public const uint DevsGPUFanCurve = 0x00110025;
public const uint DevsMidFanCurve = 0x00110032;
public const int Temp_CPU = 0x00120094;
public const int Temp_GPU = 0x00120097;
public const int PPT_TotalA0 = 0x001200A0; // Total PPT on 2022 and CPU PPT on 2021
public const int PPT_EDCA1 = 0x001200A1; // CPU EDC
public const int PPT_TDCA2 = 0x001200A2; // CPU TDC
@@ -153,21 +157,31 @@ public class ASUSWmi
}
public byte[] DeviceSet(uint DeviceID, int Status)
public int DeviceSet(uint DeviceID, int Status, string logName)
{
byte[] args = new byte[8];
BitConverter.GetBytes((uint)DeviceID).CopyTo(args, 0);
BitConverter.GetBytes((uint)Status).CopyTo(args, 4);
return CallMethod(DEVS, args);
byte[] status = CallMethod(DEVS, args);
int result = BitConverter.ToInt32(status, 0);
Logger.WriteLine(logName + " = " + Status + " : " + (result == 1 ? "OK" : result));
return result;
}
public byte[] DeviceSet(uint DeviceID, byte[] Params)
public int DeviceSet(uint DeviceID, byte[] Params, string logName)
{
byte[] args = new byte[4 + Params.Length];
BitConverter.GetBytes((uint)DeviceID).CopyTo(args, 0);
Params.CopyTo(args, 4);
return CallMethod(DEVS, args);
byte[] status = CallMethod(DEVS, args);
int result = BitConverter.ToInt32(status, 0);
Logger.WriteLine(logName + " = " + BitConverter.ToString(Params) + " : " + (result == 1 ? "OK" : result));
return BitConverter.ToInt32(status, 0);
}
@@ -176,7 +190,9 @@ public class ASUSWmi
byte[] args = new byte[8];
BitConverter.GetBytes((uint)DeviceID).CopyTo(args, 0);
byte[] status = CallMethod(DSTS, args);
return BitConverter.ToInt32(status, 0) - 65536;
}
public byte[] DeviceGetBuffer(uint DeviceID, uint Status = 0)
@@ -184,35 +200,38 @@ public class ASUSWmi
byte[] args = new byte[8];
BitConverter.GetBytes((uint)DeviceID).CopyTo(args, 0);
BitConverter.GetBytes((uint)Status).CopyTo(args, 4);
return CallMethod(DSTS, args);
}
public void SetFanCurve(int device, byte[] curve)
public int SetFanCurve(int device, byte[] curve)
{
if (curve.Length != 16) return;
if (curve.All(singleByte => singleByte == 0)) return;
if (curve.Length != 16) return -1;
if (curve.All(singleByte => singleByte == 0)) return -1;
string name;
int result;
for (int i = 8; i < curve.Length; i++)
{
curve[i] = Math.Max((byte)0, Math.Min((byte)99, curve[i])); // it seems to be a bug, when some old model's bios can go nuts if fan is set to 100%
}
switch (device)
{
case 1:
DeviceSet(DevsGPUFanCurve, curve);
name = "GPU";
result = DeviceSet(DevsGPUFanCurve, curve, "FanGPU");
break;
case 2:
DeviceSet(DevsMidFanCurve, curve);
name = "Mid";
result = DeviceSet(DevsMidFanCurve, curve, "FanMid");
break;
default:
DeviceSet(DevsCPUFanCurve, curve);
name = "CPU";
result = DeviceSet(DevsCPUFanCurve, curve, "FanCPU");
break;
}
Logger.WriteLine("Fans" + name + " " + BitConverter.ToString(curve));
return result;
}
public byte[] GetFanCurve(int device, int mode = 0)
@@ -250,7 +269,7 @@ public class ASUSWmi
setting[4] = color.B;
setting[5] = (byte)speed;
DeviceSet(TUF_KB, setting);
DeviceSet(TUF_KB, setting, "TUF RGB");
//Debug.WriteLine(BitConverter.ToString(setting));
}
@@ -270,16 +289,22 @@ public class ASUSWmi
state = state | 0x01 << 8;
DeviceSet(TUF_KB_STATE, state);
DeviceSet(TUF_KB_STATE, state, "TUF_KB");
}
public void SubscribeToEvents(Action<object, EventArrivedEventArgs> EventHandler)
{
ManagementEventWatcher watcher = new ManagementEventWatcher();
watcher.EventArrived += new EventArrivedEventHandler(EventHandler);
watcher.Scope = new ManagementScope("root\\wmi");
watcher.Query = new WqlEventQuery("SELECT * FROM AsusAtkWmiEvent");
watcher.Start();
try
{
ManagementEventWatcher watcher = new ManagementEventWatcher();
watcher.EventArrived += new EventArrivedEventHandler(EventHandler);
watcher.Scope = new ManagementScope("root\\wmi");
watcher.Query = new WqlEventQuery("SELECT * FROM AsusAtkWmiEvent");
watcher.Start();
} catch
{
Logger.WriteLine("Can't connect to ASUS WMI events");
}
}
}

View File

@@ -1,10 +1,11 @@
// Source thanks to https://github.com/vddCore/Starlight with some adjustments from me
using Starlight.Communication;
using System.Diagnostics;
using System.Management;
using System.Runtime.CompilerServices;
using System.Drawing.Drawing2D;
using System.Text;
using System.Globalization;
using System;
namespace Starlight.AnimeMatrix
{
@@ -104,13 +105,14 @@ namespace Starlight.AnimeMatrix
_model = AnimeType.GA401;
MaxColumns = 33;
dx = 0;
dx = 1;
//FullRows = 7;
//FullEvenRows = 3;
MaxRows = 55;
LedCount = 1214;
LedCount = 1245;
UpdatePageLength = 410;
}
@@ -179,7 +181,8 @@ namespace Starlight.AnimeMatrix
if (y < 11)
{
return 0;
} else
}
else
{
return (y) / 2 - 5;
}
@@ -358,44 +361,54 @@ namespace Starlight.AnimeMatrix
}
public void PresentClock()
{
int second = DateTime.Now.Second;
public void PresentText(string text, float fontSize = 8.5F)
if (CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern.Contains("H"))
PresentText(DateTime.Now.ToString("H" + ((second % 2 == 0)?":":" ") + "mm"));
else
PresentText(DateTime.Now.ToString("h" + ((second % 2 == 0) ? ":" : " ") + "mm"), DateTime.Now.ToString("tt"));
}
public void PresentText(string text1, string text2 = "")
{
using (Bitmap bmp = new Bitmap(MaxColumns * 3, MaxRows))
{
using (Graphics g = Graphics.FromImage(bmp))
{
using (Font font = new Font("Arial", fontSize))
g.CompositingQuality = CompositingQuality.HighQuality;
g.SmoothingMode = SmoothingMode.AntiAlias;
using (Font font = new Font("Arial", 12F))
{
g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
/*
SizeF textSize = g.MeasureString(text, font);
g.TranslateTransform(bmp.Width / 2, bmp.Height / 2);
g.RotateTransform(33);
g.DrawString(text, font, Brushes.White, -textSize.Width/2, -textSize.Height / 2);
*/
g.DrawString(text, font, Brushes.White, 5, -2);
SizeF textSize = g.MeasureString(text1, font);
g.DrawString(text1, font, Brushes.White, (MaxColumns*3 - textSize.Width)+3, -5);
}
if (text2.Length > 0)
using (Font font = new Font("Arial", 9F))
{
SizeF textSize = g.MeasureString(text2, font);
g.DrawString(text2, font, Brushes.White, (MaxColumns * 3 - textSize.Width)+1, 25);
}
}
GenerateFrame(bmp, System.Drawing.Drawing2D.InterpolationMode.Bicubic);
GenerateFrame(bmp, InterpolationMode.Bicubic);
Present();
}
}
public void GenerateFrame(Image image, System.Drawing.Drawing2D.InterpolationMode interpolation = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic)
public void GenerateFrame(Image image, InterpolationMode interpolation = InterpolationMode.High)
{
int width = MaxColumns * 3;
int width = MaxColumns/2 * 6;
int height = MaxRows;
int targetWidth = MaxColumns * 2;
float scale;
using (Bitmap bmp = new Bitmap(targetWidth, height))
@@ -408,8 +421,8 @@ namespace Starlight.AnimeMatrix
var scaleHeight = (float)(image.Height * scale);
graph.InterpolationMode = interpolation;
graph.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
graph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
graph.CompositingQuality = CompositingQuality.HighQuality;
graph.SmoothingMode = SmoothingMode.AntiAlias;
graph.DrawImage(image, (float)Math.Round(targetWidth - scaleWidth * targetWidth / width), 0, (float)Math.Round(scaleWidth * targetWidth / width), scaleHeight);
@@ -418,7 +431,7 @@ namespace Starlight.AnimeMatrix
for (int y = 0; y < bmp.Height; y++)
{
for (int x = 0; x < bmp.Width; x++)
if (x % 2 == y % 2)
if (x % 2 == (y+dx) % 2)
{
var pixel = bmp.GetPixel(x, y);
var color = (pixel.R + pixel.G + pixel.B) / 3;

View File

@@ -108,6 +108,8 @@ public class AppConfig
if (device == 1)
name = "gpu";
else if (device == 2)
name = "mid";
else
name = "cpu";

View File

@@ -1,5 +1,8 @@
using HidLibrary;
using System.Data;
using System.Diagnostics;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TextBox;
using System.Security.Policy;
namespace GHelper
{
@@ -71,9 +74,8 @@ namespace GHelper
{ 2, "Fast" }
};
}
public static Dictionary<int, string> GetModes()
{
return new Dictionary<int, string>
static Dictionary<int, string> _modes = new Dictionary<int, string>
{
{ 0, "Static" },
{ 1, "Breathe" },
@@ -81,6 +83,43 @@ namespace GHelper
{ 3, "Rainbow" },
{ 10, "Strobe" },
};
static Dictionary<int, string> _modesStrix = new Dictionary<int, string>
{
{ 0, "Static" },
{ 1, "Breathe" },
{ 2, "Color Cycle" },
{ 3, "Rainbow" },
{ 4, "Star" },
{ 5, "Rain" },
{ 6, "Highlight" },
{ 7, "Laser" },
{ 8, "Ripple" },
{ 10, "Strobe" },
{ 11, "Comet" },
{ 12, "Flash" },
};
public static Dictionary<int, string> GetModes()
{
if (Program.config.ContainsModel("TUF"))
{
_modes.Remove(3);
}
if (Program.config.ContainsModel("401"))
{
_modes.Remove(2);
_modes.Remove(3);
}
if (Program.config.ContainsModel("Strix") || Program.config.ContainsModel("Scar"))
{
return _modesStrix;
}
return _modes;
}
@@ -98,7 +137,7 @@ namespace GHelper
public static bool HasSecondColor()
{
return mode == 1;
return (mode == 1 && !Program.config.ContainsModel("TUF"));
}
public static int Speed
@@ -148,7 +187,7 @@ namespace GHelper
{
HidDevice[] HidDeviceList = HidDevices.Enumerate(0x0b05, deviceIds).ToArray();
byte[] msg = { 0x5a, 0xba, 0xc5, 0xc4, (byte)brightness };
byte[] msg = { 0x5d, 0xba, 0xc5, 0xc4, (byte)brightness };
foreach (HidDevice device in HidDeviceList)
if (device.IsConnected && device.Description.Contains("HID"))
@@ -184,7 +223,8 @@ namespace GHelper
device.CloseDevice();
}
Program.wmi.TUFKeyboardPower(awake, boot, sleep, shutdown);
if (Program.config.ContainsModel("TUF"))
Program.wmi.TUFKeyboardPower(awake, boot, sleep, shutdown);
}
@@ -220,7 +260,8 @@ namespace GHelper
device.CloseDevice();
}
Program.wmi.TUFKeyboardRGB(Mode, Color1, _speed);
if (Program.config.ContainsModel("TUF"))
Program.wmi.TUFKeyboardRGB(Mode, Color1, _speed);
}
}

View File

@@ -1,4 +1,5 @@
using CustomControls;
using WinFormsSliderBar;
using System.Drawing.Drawing2D;
using System.Windows.Forms.DataVisualization.Charting;
@@ -8,6 +9,7 @@ public static class ControlHelper
static bool _invert = false;
static bool _darkTheme = false;
static float _scale = 1;
static Color formBack;
@@ -53,7 +55,7 @@ public static class ControlHelper
public static void Resize(RForm container, float baseScale = 2)
{
_scale = GetDpiScale(container).Value / baseScale;
ResizeControls(container.Controls);
if (Math.Abs(_scale - 1) > 0.2) ResizeControls(container.Controls);
}
@@ -65,9 +67,11 @@ public static class ControlHelper
if (button != null && button.Image is not null)
button.Image = ResizeImage(button.Image);
/*
var pictureBox = control as PictureBox;
if (pictureBox != null && pictureBox.BackgroundImage is not null)
pictureBox.BackgroundImage = ResizeImage(pictureBox.BackgroundImage);
*/
ResizeControls(control.Controls);
}
@@ -95,14 +99,15 @@ public static class ControlHelper
if (pictureBox != null && pictureBox.BackgroundImage is not null)
pictureBox.BackgroundImage = AdjustImage(pictureBox.BackgroundImage);
var combo = control as RComboBox;
if (combo != null)
{
combo.BackColor = backMain;
combo.ForeColor = foreMain;
combo.BorderColor = backMain;
combo.ButtonColor = buttonMain;
combo.ButtonColor = backMain;
combo.ArrowColor = foreMain;
}
var gb = control as GroupBox;
@@ -111,6 +116,11 @@ public static class ControlHelper
gb.ForeColor = foreMain;
}
var sl = control as Slider;
if (sl != null)
{
sl.borderColor = buttonMain;
}
var chart = control as Chart;
if (chart != null)

View File

@@ -1,5 +1,6 @@
using Microsoft.Win32;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing.Drawing2D;
using System.Runtime.InteropServices;
@@ -30,9 +31,9 @@ namespace CustomControls
return (int)registryValueObject <= 0;
}
public void InitTheme(bool setDPI = true)
public bool InitTheme(bool setDPI = false)
{
bool newDarkTheme = IsDarkTheme();
bool newDarkTheme = CheckSystemDarkModeStatus();
bool changed = (darkTheme != newDarkTheme);
darkTheme = newDarkTheme;
@@ -45,16 +46,13 @@ namespace CustomControls
ControlHelper.Adjust(this, darkTheme, changed);
}
return changed;
}
}
public class RTrackBar : TrackBar
{
}
public class RComboBox : ComboBox
{
private Color borderColor = Color.Gray;
@@ -71,8 +69,10 @@ namespace CustomControls
}
}
}
private Color buttonColor = Color.FromArgb(255,230, 230, 230);
[DefaultValue(typeof(Color), "230, 230, 230")]
private Color buttonColor = Color.FromArgb(255, 255, 255, 255);
[DefaultValue(typeof(Color), "255, 255, 255")]
public Color ButtonColor
{
get { return buttonColor; }

View File

@@ -18,7 +18,7 @@ namespace GHelper
{
if (percentage == 0) return "OFF";
return (200 * Math.Round((float)(MinRPM + (MaxRPM - MinRPM) * percentage * 0.01) / 200)).ToString() + unit;
return (200 * Math.Round((float)(MinRPM*100 + (MaxRPM - MinRPM) * percentage) / 200)).ToString() + unit;
}
void SetChart(Chart chart, int device)
@@ -47,7 +47,7 @@ namespace GHelper
chart.ChartAreas[0].AxisY.LabelStyle.Font = new Font("Arial", 7F);
var foreAccent = Color.FromArgb(255, 100, 100, 100);
var foreAccent = Color.FromArgb(255, 180, 180, 180);
chart.ChartAreas[0].AxisX.MajorGrid.LineColor = foreAccent;
chart.ChartAreas[0].AxisY.MajorGrid.LineColor = foreAccent;
@@ -89,14 +89,8 @@ namespace GHelper
InitializeComponent();
InitTheme();
MinRPM = 1800;
if (Program.config.ContainsModel("401"))
MaxRPM = 7200;
else if (Program.config.ContainsModel("503"))
MaxRPM = 6800;
else
MaxRPM = 5800;
MinRPM = 18;
MaxRPM = HardwareMonitor.GetFanMax();
@@ -146,7 +140,7 @@ namespace GHelper
InitPower();
InitBoost();
comboBoost.SelectedIndexChanged += ComboBoost_Changed;
comboBoost.SelectedValueChanged += ComboBoost_Changed;
Shown += Fans_Shown;
@@ -162,9 +156,11 @@ namespace GHelper
private void ComboBoost_Changed(object? sender, EventArgs e)
{
if (sender is null) return;
ComboBox cmb = (ComboBox)sender;
NativeMethods.SetCPUBoost(cmb.SelectedIndex);
if (Program.config.getConfigPerf("auto_boost") != comboBoost.SelectedIndex)
{
NativeMethods.SetCPUBoost(comboBoost.SelectedIndex);
Program.config.setConfigPerf("auto_boost", comboBoost.SelectedIndex);
}
}
private void CheckApplyPower_Click(object? sender, EventArgs e)
@@ -338,7 +334,7 @@ namespace GHelper
}
void ApplyProfile(Series series, int device)
void SaveProfile(Series series, int device)
{
byte[] curve = new byte[16];
int i = 0;
@@ -350,17 +346,19 @@ namespace GHelper
}
Program.config.setFanConfig(device, curve);
Program.wmi.SetFanCurve(device, curve);
//Program.wmi.SetFanCurve(device, curve);
}
private void ButtonApply_Click(object? sender, EventArgs e)
{
ApplyProfile(seriesCPU, 0);
ApplyProfile(seriesGPU, 1);
SaveProfile(seriesCPU, 0);
SaveProfile(seriesGPU, 1);
if (Program.config.getConfig("mid_fan") == 1)
ApplyProfile(seriesMid, 2);
SaveProfile(seriesMid, 2);
Program.settingsForm.AutoFans(true);
}
private void ButtonReset_Click(object? sender, EventArgs e)
@@ -377,7 +375,7 @@ namespace GHelper
Program.config.setConfigPerf("auto_apply", 0);
Program.config.setConfigPerf("auto_apply_power", 0);
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, Program.config.getConfig("performance_mode"));
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, Program.config.getConfig("performance_mode"), "PerfMode");
ApplyLabel(false);
}

View File

@@ -16,7 +16,7 @@
<PlatformTarget>x64</PlatformTarget>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<AssemblyVersion>0.40</AssemblyVersion>
<AssemblyVersion>0.46</AssemblyVersion>
</PropertyGroup>
<ItemGroup>
@@ -48,7 +48,7 @@
<PackageReference Include="NvAPIWrapper.Net" Version="0.8.1.101" />
<PackageReference Include="System.Management" Version="7.0.0" />
<PackageReference Include="TaskScheduler" Version="2.10.1" />
<PackageReference Include="WinForms.DataVisualization" Version="1.7.0" />
<PackageReference Include="WinForms.DataVisualization" Version="1.8.0" />
</ItemGroup>
<ItemGroup>

View File

@@ -1,4 +1,5 @@
using System.Diagnostics;
using GHelper;
using GHelper.Gpu;
public static class HardwareMonitor
@@ -9,12 +10,53 @@ public static class HardwareMonitor
public static float? batteryDischarge = -1;
public static int? gpuTemp = null;
public static string? cpuFan;
public static string? gpuFan;
public static string? midFan;
public static int GetFanMax()
{
int max = 58;
if (Program.config.ContainsModel("401")) max = 72;
else if (Program.config.ContainsModel("503")) max = 68;
return Math.Max(max, Program.config.getConfig("fan_max"));
}
public static void SetFanMax(int fan)
{
Program.config.setConfig("fan_max", fan);
}
private static string FormatFan(int fan)
{
// fix for old models
if (fan < 0)
{
fan += 65536;
if (fan <= 0 || fan > 100) return null; //nothing reasonable
}
int fanMax = GetFanMax();
if (fan > fanMax) SetFanMax(fan);
if (Program.config.getConfig("fan_rpm") == 1)
return " Fan: " + (fan * 100).ToString() + "RPM";
else
return " Fan: " + Math.Min(Math.Round((float)fan/fanMax*100), 100).ToString() + "%"; // relatively to 6000 rpm
}
public static void ReadSensors()
{
cpuTemp = -1;
batteryDischarge = -1;
gpuTemp = -1;
try
cpuFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.CPU_Fan));
gpuFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.GPU_Fan));
midFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.Mid_Fan));
cpuTemp = Program.wmi.DeviceGet(ASUSWmi.Temp_CPU);
if (cpuTemp < 0) try
{
var ct = new PerformanceCounter("Thermal Zone Information", "Temperature", @"\_TZ.THRM", true);
cpuTemp = ct.NextValue() - 273;
@@ -24,26 +66,33 @@ public static class HardwareMonitor
Logger.WriteLine("Failed reading CPU temp");
}
if (gpuTemp < 0) try
{
if (GpuTemperatureProvider is null) RecreateGpuTemperatureProvider();
gpuTemp = GpuTemperatureProvider?.GetCurrentTemperature();
}
catch (Exception ex) {
gpuTemp = -1;
Logger.WriteLine("Failed reading GPU temp");
Logger.WriteLine(ex.ToString());
}
if (gpuTemp is null || gpuTemp < 0)
gpuTemp = Program.wmi.DeviceGet(ASUSWmi.Temp_GPU);
try
{
var cb = new PerformanceCounter("Power Meter", "Power", "Power Meter (0)", true);
batteryDischarge = cb.NextValue() / 1000;
cb.Dispose();
} catch
}
catch
{
Logger.WriteLine("Failed reading Battery discharge");
}
try
{
gpuTemp = GpuTemperatureProvider?.GetCurrentTemperature();
} catch (Exception ex) {
gpuTemp = null;
Logger.WriteLine("Failed reading GPU temp");
Logger.WriteLine(ex.ToString());
}
}
public static void RecreateGpuTemperatureProviderWithDelay() {

View File

@@ -1,6 +1,8 @@
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Xml.Linq;
using static Tools.ScreenInterrogatory;
namespace Tools
@@ -630,6 +632,7 @@ public class NativeMethods
{
dm.dmDisplayFrequency = frequency;
int iRet = NativeMethods.ChangeDisplaySettingsEx(laptopScreen, ref dm, IntPtr.Zero, DisplaySettingsFlags.CDS_UPDATEREGISTRY, IntPtr.Zero);
Logger.WriteLine("Screen = " + frequency.ToString() + "Hz : " + (iRet == 0 ? "OK" : iRet));
return iRet;
}
@@ -683,6 +686,7 @@ public class NativeMethods
PowerSetActiveScheme(IntPtr.Zero, activeSchemeGuid);
*/
Logger.WriteLine("Boost " + boost);
}
public static void SetPowerScheme(int mode)

View File

@@ -1,8 +1,6 @@
using Microsoft.Win32;
using System.Diagnostics;
using System.Management;
using System.Reflection;
using System.Text.Json;
namespace GHelper
{
@@ -58,30 +56,31 @@ namespace GHelper
}
Logger.WriteLine("------------");
Logger.WriteLine("App launched");
Application.EnableVisualStyles();
SystemEvents.UserPreferenceChanged += new
UserPreferenceChangedEventHandler(SystemEvents_UserPreferenceChanged);
var ds = settingsForm.Handle;
trayIcon.MouseClick += TrayIcon_MouseClick;
wmi.SubscribeToEvents(WatcherEventArrived);
settingsForm.InitGPUMode();
settingsForm.InitAura();
settingsForm.InitMatrix();
settingsForm.SetStartupCheck(Startup.IsScheduled());
SetAutoModes();
HardwareMonitor.RecreateGpuTemperatureProvider();
// Subscribing for system power change events
SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
SystemEvents.UserPreferenceChanged += SystemEvents_UserPreferenceChanged;
// Subscribing for monitor power on events
var settingGuid = new NativeMethods.PowerSettingGuid();
unRegPowerNotify = NativeMethods.RegisterPowerSettingNotification(ds, settingGuid.ConsoleDisplayState, NativeMethods.DEVICE_NOTIFY_WINDOW_HANDLE);
if (Environment.CurrentDirectory.Trim('\\') == Application.StartupPath.Trim('\\'))
@@ -106,13 +105,13 @@ namespace GHelper
case UserPreferenceCategory.General:
Debug.WriteLine("Theme Changed");
Thread.Sleep(1000);
settingsForm.InitTheme(false);
settingsForm.InitTheme();
if (settingsForm.fans is not null && settingsForm.fans.Text != "")
settingsForm.fans.InitTheme(false);
settingsForm.fans.InitTheme();
if (settingsForm.keyb is not null && settingsForm.keyb.Text != "")
settingsForm.keyb.InitTheme(false);
settingsForm.keyb.InitTheme();
break;
}
@@ -133,8 +132,14 @@ namespace GHelper
settingsForm.AutoPerformance();
bool switched = settingsForm.AutoGPUMode();
if (!switched) settingsForm.AutoScreen();
if (!switched)
{
settingsForm.InitGPUMode();
settingsForm.AutoScreen();
}
settingsForm.AutoKeyboard();
settingsForm.SetMatrix();
}
@@ -143,7 +148,6 @@ namespace GHelper
if (SystemInformation.PowerStatus.PowerLineStatus == isPlugged) return;
Logger.WriteLine("Windows - Power Mode Changed");
settingsForm.AutoKeyboard();
SetAutoModes();
}
@@ -160,7 +164,7 @@ namespace GHelper
}
catch
{
Logger.WriteLine("Failed to run " + fileName);
Logger.WriteLine("Failed to run " + fileName);
}

View File

@@ -40,12 +40,12 @@ namespace GHelper
pictureMatrix = new PictureBox();
labelMatrix = new Label();
panelBattery = new Panel();
sliderBattery = new WinFormsSliderBar.Slider();
labelModel = new Label();
labelVersion = new Label();
labelBattery = new Label();
pictureBattery = new PictureBox();
labelBatteryTitle = new Label();
trackBattery = new TrackBar();
panelFooter = new Panel();
buttonQuit = new RButton();
checkStartup = new CheckBox();
@@ -93,7 +93,6 @@ namespace GHelper
((System.ComponentModel.ISupportInitialize)pictureMatrix).BeginInit();
panelBattery.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBattery).BeginInit();
((System.ComponentModel.ISupportInitialize)trackBattery).BeginInit();
panelFooter.SuspendLayout();
panelPerformance.SuspendLayout();
((System.ComponentModel.ISupportInitialize)picturePerf).BeginInit();
@@ -164,7 +163,6 @@ namespace GHelper
// comboMatrix
//
comboMatrix.BorderColor = Color.White;
comboMatrix.ButtonColor = SystemColors.ControlLight;
comboMatrix.Dock = DockStyle.Top;
comboMatrix.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
comboMatrix.FormattingEnabled = true;
@@ -180,7 +178,6 @@ namespace GHelper
// comboMatrixRunning
//
comboMatrixRunning.BorderColor = Color.White;
comboMatrixRunning.ButtonColor = SystemColors.ControlLight;
comboMatrixRunning.Dock = DockStyle.Top;
comboMatrixRunning.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
comboMatrixRunning.FormattingEnabled = true;
@@ -237,12 +234,12 @@ namespace GHelper
//
panelBattery.AutoSize = true;
panelBattery.AutoSizeMode = AutoSizeMode.GrowAndShrink;
panelBattery.Controls.Add(sliderBattery);
panelBattery.Controls.Add(labelModel);
panelBattery.Controls.Add(labelVersion);
panelBattery.Controls.Add(labelBattery);
panelBattery.Controls.Add(pictureBattery);
panelBattery.Controls.Add(labelBatteryTitle);
panelBattery.Controls.Add(trackBattery);
panelBattery.Dock = DockStyle.Top;
panelBattery.Location = new Point(10, 926);
panelBattery.Margin = new Padding(8);
@@ -251,6 +248,17 @@ namespace GHelper
panelBattery.Size = new Size(810, 163);
panelBattery.TabIndex = 34;
//
// sliderBattery
//
sliderBattery.Location = new Point(16, 70);
sliderBattery.Max = 100;
sliderBattery.Min = 50;
sliderBattery.Name = "sliderBattery";
sliderBattery.Size = new Size(772, 40);
sliderBattery.TabIndex = 39;
sliderBattery.Text = "sliderBattery";
sliderBattery.Value = 80;
//
// labelModel
//
labelModel.Anchor = AnchorStyles.Top | AnchorStyles.Right;
@@ -307,22 +315,6 @@ namespace GHelper
labelBatteryTitle.TabIndex = 34;
labelBatteryTitle.Text = "Battery Charge Limit";
//
// trackBattery
//
trackBattery.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
trackBattery.LargeChange = 10;
trackBattery.Location = new Point(20, 52);
trackBattery.Margin = new Padding(8, 4, 8, 4);
trackBattery.Maximum = 100;
trackBattery.Minimum = 50;
trackBattery.Name = "trackBattery";
trackBattery.Size = new Size(766, 90);
trackBattery.SmallChange = 5;
trackBattery.TabIndex = 33;
trackBattery.TickFrequency = 10;
trackBattery.TickStyle = TickStyle.TopLeft;
trackBattery.Value = 100;
//
// panelFooter
//
panelFooter.AutoSize = true;
@@ -896,7 +888,6 @@ namespace GHelper
// comboKeyboard
//
comboKeyboard.BorderColor = Color.White;
comboKeyboard.ButtonColor = SystemColors.ControlLight;
comboKeyboard.Dock = DockStyle.Top;
comboKeyboard.FlatStyle = FlatStyle.Flat;
comboKeyboard.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
@@ -1033,7 +1024,6 @@ namespace GHelper
panelBattery.ResumeLayout(false);
panelBattery.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBattery).EndInit();
((System.ComponentModel.ISupportInitialize)trackBattery).EndInit();
panelFooter.ResumeLayout(false);
panelFooter.PerformLayout();
panelPerformance.ResumeLayout(false);
@@ -1069,7 +1059,6 @@ namespace GHelper
private Label labelBattery;
private PictureBox pictureBattery;
private Label labelBatteryTitle;
private TrackBar trackBattery;
private Panel panelFooter;
private RButton buttonQuit;
private CheckBox checkStartup;
@@ -1118,5 +1107,6 @@ namespace GHelper
private RButton buttonFans;
private Label labelMidFan;
private Label labelModel;
private WinFormsSliderBar.Slider sliderBattery;
}
}

View File

@@ -2,7 +2,6 @@
using Starlight.AnimeMatrix;
using System.Diagnostics;
using System.Drawing.Imaging;
using System.Globalization;
using System.Reflection;
using System.Text.Json;
using System.Timers;
@@ -26,12 +25,13 @@ namespace GHelper
public Keyboard keyb;
static AnimeMatrixDevice mat;
static int matrixTick = 0;
static long lastRefresh;
public SettingsForm()
{
InitializeComponent();
InitTheme();
InitTheme(true);
FormClosing += SettingsForm_FormClosing;
@@ -114,20 +114,14 @@ namespace GHelper
button120Hz.MouseMove += Button120Hz_MouseHover;
button120Hz.MouseLeave += ButtonScreen_MouseLeave;
trackBattery.ValueChanged += TrackBattery_ValueChanged;
sliderBattery.ValueChanged += SliderBattery_ValueChanged;
Program.trayIcon.MouseMove += TrayIcon_MouseMove;
//buttonStandard.Image = (Image)(new Bitmap(buttonStandard.Image, new Size(16, 16)));
aTimer = new System.Timers.Timer(500);
aTimer = new System.Timers.Timer(1000);
aTimer.Elapsed += OnTimedEvent;
// Subscribing for monitor power on events
var settingGuid = new NativeMethods.PowerSettingGuid();
Program.unRegPowerNotify = NativeMethods.RegisterPowerSettingNotification(Handle, settingGuid.ConsoleDisplayState, NativeMethods.DEVICE_NOTIFY_WINDOW_HANDLE);
SetVersionLabel("Version: " + Assembly.GetExecutingAssembly().GetName().Version);
string model = Program.config.GetModel();
int trim = model.LastIndexOf("_");
if (trim > 0) model = model.Substring(0, trim);
@@ -138,17 +132,16 @@ namespace GHelper
Task.Run(async () =>
{
await Task.Delay(TimeSpan.FromSeconds(5));
await Task.Delay(TimeSpan.FromSeconds(1));
CheckForUpdatesAsync();
});
}
private void TrackBattery_ValueChanged(object? sender, EventArgs e)
private void SliderBattery_ValueChanged(object? sender, EventArgs e)
{
SetBatteryChargeLimit(trackBattery.Value);
SetBatteryChargeLimit(sliderBattery.Value);
}
@@ -356,7 +349,7 @@ namespace GHelper
mat.PresentNextFrame();
break;
case 3:
mat.PresentText(DateTime.Now.ToString("H:mm:ss"));
mat.PresentClock();
break;
}
@@ -696,19 +689,18 @@ namespace GHelper
if (frequency > 0)
{
NativeMethods.SetRefreshRate(frequency);
Logger.WriteLine("Screen " + frequency.ToString() + "Hz");
}
if (overdrive >= 0)
{
if (Program.config.getConfig("no_overdrive") == 1) overdrive = 0;
Program.wmi.DeviceSet(ASUSWmi.ScreenOverdrive, overdrive);
Program.wmi.DeviceSet(ASUSWmi.ScreenOverdrive, overdrive, "ScreenOverdrive");
}
if (miniled >= 0)
{
Program.wmi.DeviceSet(ASUSWmi.ScreenMiniled, miniled);
Program.wmi.DeviceSet(ASUSWmi.ScreenMiniled, miniled, "Miniled");
Debug.WriteLine("Miniled " + miniled);
}
@@ -726,7 +718,6 @@ namespace GHelper
bool overdriveSetting = (Program.config.getConfig("no_overdrive") != 1);
int overdrive = Program.wmi.DeviceGet(ASUSWmi.ScreenOverdrive);
int miniled = Program.wmi.DeviceGet(ASUSWmi.ScreenMiniled);
bool screenEnabled = (frequency >= 0);
@@ -808,26 +799,12 @@ namespace GHelper
}
private static string FormatFan(int fan)
{
if (fan < 0) return null;
if (Program.config.getConfig("fan_rpm") == 1)
return " Fan: " + (fan * 100).ToString() + "RPM";
else
return " Fan: " + Math.Min(Math.Round(fan / 0.6), 100).ToString() + "%"; // relatively to 6000 rpm
}
private static void RefreshSensors(bool force = false)
{
if (!force && Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastRefresh) < 2000) return;
lastRefresh = DateTimeOffset.Now.ToUnixTimeMilliseconds();
string cpuFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.CPU_Fan));
string gpuFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.GPU_Fan));
string midFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.Mid_Fan));
string cpuTemp = "";
string gpuTemp = "";
string battery = "";
@@ -840,19 +817,23 @@ namespace GHelper
if (HardwareMonitor.batteryDischarge > 0)
battery = "Discharging: " + Math.Round((decimal)HardwareMonitor.batteryDischarge, 1).ToString() + "W";
if (HardwareMonitor.gpuTemp != null)
if (HardwareMonitor.gpuTemp > 0)
{
gpuTemp = $": {HardwareMonitor.gpuTemp}°C - ";
}
Program.settingsForm.BeginInvoke(delegate
{
Program.settingsForm.labelCPUFan.Text = "CPU" + cpuTemp + cpuFan;
Program.settingsForm.labelGPUFan.Text = "GPU" + gpuTemp + gpuFan;
if (midFan is not null) Program.settingsForm.labelMidFan.Text = "Mid" + midFan;
Program.settingsForm.labelCPUFan.Text = "CPU" + cpuTemp + HardwareMonitor.cpuFan;
Program.settingsForm.labelGPUFan.Text = "GPU" + gpuTemp + HardwareMonitor.gpuFan;
if (HardwareMonitor.midFan is not null)
Program.settingsForm.labelMidFan.Text = "Mid" + HardwareMonitor.midFan;
Program.settingsForm.labelBattery.Text = battery;
Program.trayIcon.Text = "CPU" + cpuTemp + cpuFan + "\n" + "GPU" + gpuTemp + gpuFan + ((battery.Length > 0) ? ("\n" + battery) : "");
Program.trayIcon.Text = "CPU" + cpuTemp + HardwareMonitor.cpuFan + "\n"
+ "GPU" + gpuTemp + HardwareMonitor.gpuFan +
((battery.Length > 0) ? ("\n" + battery) : "");
});
}
@@ -868,7 +849,7 @@ namespace GHelper
this.Top = Screen.FromControl(this).WorkingArea.Height - 10 - this.Height;
this.Activate();
aTimer.Interval = 300;
//aTimer.Interval = 300;
aTimer.Enabled = true;
//RefreshSensors();
@@ -891,36 +872,45 @@ namespace GHelper
if (limit_cpu < ASUSWmi.MinCPU) return;
if (Program.wmi.DeviceGet(ASUSWmi.PPT_TotalA0) >= 0)
Program.wmi.DeviceSet(ASUSWmi.PPT_TotalA0, limit_total);
Program.wmi.DeviceSet(ASUSWmi.PPT_TotalA0, limit_total, "PowerLimit A");
if (Program.wmi.DeviceGet(ASUSWmi.PPT_CPUB0) >= 0)
Program.wmi.DeviceSet(ASUSWmi.PPT_CPUB0, limit_cpu);
Program.wmi.DeviceSet(ASUSWmi.PPT_CPUB0, limit_cpu, "PowerLimit B");
Logger.WriteLine("PowerLimits " + limit_total.ToString() + ", " + limit_cpu.ToString());
}
public void AutoFansAndPower()
public void AutoFans(bool force = false)
{
if (Program.config.getConfigPerf("auto_apply") == 1)
if (force || Program.config.getConfigPerf("auto_apply") == 1)
{
Program.wmi.SetFanCurve(0, Program.config.getFanConfig(0));
Program.wmi.SetFanCurve(1, Program.config.getFanConfig(1));
int cpuResult = Program.wmi.SetFanCurve(0, Program.config.getFanConfig(0));
int gpuResult = Program.wmi.SetFanCurve(1, Program.config.getFanConfig(1));
if (Program.config.getConfig("mid_fan") == 1)
Program.wmi.SetFanCurve(2, Program.config.getFanConfig(2));
labelPerf.Text = "Performance Mode+";
} else
{
labelPerf.Text = "Performance Mode";
if (cpuResult != 1 || gpuResult != 1) // something went wrong, resetting to default profile
{
int mode = Program.config.getConfig("performance_mode");
Logger.WriteLine("Bios rejected fan curve, resetting mode to " + mode);
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, mode, "PerformanceMode");
}
else
labelPerf.Text = "Performance Mode+";
}
else
labelPerf.Text = "Performance Mode";
if (Program.config.getConfigPerf("auto_apply_power") == 1)
}
public void AutoPower(bool force = false)
{
if (force || Program.config.getConfigPerf("auto_apply_power") == 1)
{
var timer = new System.Timers.Timer(1000);
timer.Elapsed += delegate
@@ -934,6 +924,7 @@ namespace GHelper
}
public void SetPerformanceMode(int PerformanceMode = ASUSWmi.PerformanceBalanced, bool notify = false)
{
@@ -963,8 +954,7 @@ namespace GHelper
Program.config.setConfig("performance_" + (int)SystemInformation.PowerStatus.PowerLineStatus, PerformanceMode);
Program.config.setConfig("performance_mode", PerformanceMode);
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, PerformanceMode);
Logger.WriteLine("PerfMode " + perfName + " " + PerformanceMode);
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, PerformanceMode, "PerformanceMode");
if (notify && (oldMode != PerformanceMode))
{
@@ -978,7 +968,13 @@ namespace GHelper
}
}
AutoFansAndPower();
AutoFans();
AutoPower();
if (Program.config.getConfigPerf("auto_boost") != -1)
{
NativeMethods.SetCPUBoost(Program.config.getConfigPerf("auto_boost"));
}
NativeMethods.SetPowerScheme(PerformanceMode);
@@ -991,6 +987,7 @@ namespace GHelper
{
fans.InitFans();
fans.InitPower();
fans.InitBoost();
}
@@ -1009,9 +1006,11 @@ namespace GHelper
if (Program.config.getConfig("keyboard_auto") != 1) return;
if (SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online)
Program.wmi.DeviceSet(ASUSWmi.UniversalControl, ASUSWmi.KB_Light_Up);
Aura.ApplyBrightness(3);
//Program.wmi.DeviceSet(ASUSWmi.UniversalControl, ASUSWmi.KB_Light_Up);
else
Program.wmi.DeviceSet(ASUSWmi.UniversalControl, ASUSWmi.KB_Light_Down);
Aura.ApplyBrightness(0);
//Program.wmi.DeviceSet(ASUSWmi.UniversalControl, ASUSWmi.KB_Light_Down);
}
@@ -1046,7 +1045,11 @@ namespace GHelper
var Plugged = SystemInformation.PowerStatus.PowerLineStatus;
bool GpuAuto = Program.config.getConfig("gpu_auto") == 1;
if (!GpuAuto) return false;
bool ForceGPU = Program.config.ContainsModel("503");
int GpuMode = Program.config.getConfig("gpu_mode");
if (!GpuAuto && !ForceGPU) return false;
int eco = Program.wmi.DeviceGet(ASUSWmi.GPUEco);
int mux = Program.wmi.DeviceGet(ASUSWmi.GPUMux);
@@ -1055,16 +1058,18 @@ namespace GHelper
return false;
else
{
if (eco == 1 && Plugged == PowerLineStatus.Online) // Eco going Standard on plugged
{
SetEcoGPU(0);
return true;
}
else if (eco == 0 && Plugged != PowerLineStatus.Online) // Standard going Eco on plugged
{
SetEcoGPU(1);
return true;
}
if (eco == 1)
if ((GpuAuto && Plugged == PowerLineStatus.Online) || (ForceGPU && GpuMode == ASUSWmi.GPUModeStandard))
{
SetEcoGPU(0);
return true;
}
if (eco == 0)
if ((GpuAuto && Plugged != PowerLineStatus.Online) || (ForceGPU && GpuMode == ASUSWmi.GPUModeEco))
{
SetEcoGPU(1);
return true;
}
}
return false;
@@ -1093,6 +1098,9 @@ namespace GHelper
int eco = Program.wmi.DeviceGet(ASUSWmi.GPUEco);
int mux = Program.wmi.DeviceGet(ASUSWmi.GPUMux);
Logger.WriteLine("Eco flag : " + eco);
Logger.WriteLine("Mux flag : " + mux);
int GpuMode;
if (mux == 0)
@@ -1143,12 +1151,12 @@ namespace GHelper
foreach (var process in Process.GetProcessesByName(kill)) process.Kill();
}
Program.wmi.DeviceSet(ASUSWmi.GPUEco, eco);
Program.wmi.DeviceSet(ASUSWmi.GPUEco, eco, "GPUEco");
Program.settingsForm.BeginInvoke(delegate
{
InitGPUMode();
HardwareMonitor.RecreateGpuTemperatureProviderWithDelay();
Thread.Sleep(500);
InitGPUMode();
AutoScreen();
});
});
@@ -1177,7 +1185,7 @@ namespace GHelper
DialogResult dialogResult = MessageBox.Show("Switching off Ultimate Mode requires restart", "Reboot now?", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
Program.wmi.DeviceSet(ASUSWmi.GPUMux, 1);
Program.wmi.DeviceSet(ASUSWmi.GPUMux, 1, "GPUMux");
restart = true;
changed = true;
}
@@ -1187,7 +1195,7 @@ namespace GHelper
DialogResult dialogResult = MessageBox.Show("Ultimate Mode requires restart", "Reboot now?", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
Program.wmi.DeviceSet(ASUSWmi.GPUMux, 0);
Program.wmi.DeviceSet(ASUSWmi.GPUMux, 0, "GPUMux");
restart = true;
changed = true;
}
@@ -1298,10 +1306,12 @@ namespace GHelper
if (limit < 40 || limit > 100) return;
labelBatteryTitle.Text = "Battery Charge Limit: " + limit.ToString() + "%";
trackBattery.Value = limit;
//Debug.WriteLine(limit);
Program.wmi.DeviceSet(ASUSWmi.BatteryLimit, limit);
labelBatteryTitle.Text = "Battery Charge Limit: " + limit.ToString() + "%";
sliderBattery.Value = limit;
Program.wmi.DeviceSet(ASUSWmi.BatteryLimit, limit, "BatteryLimit");
Program.config.setConfig("charge_limit", limit);
}

168
app/Slider.cs Normal file
View File

@@ -0,0 +1,168 @@
using System.Drawing.Drawing2D;
namespace WinFormsSliderBar
{
public static class GraphicsExtensions
{
public static void DrawCircle(this Graphics g, Pen pen,
float centerX, float centerY, float radius)
{
g.DrawEllipse(pen, centerX - radius, centerY - radius,
radius + radius, radius + radius);
}
public static void FillCircle(this Graphics g, Brush brush,
float centerX, float centerY, float radius)
{
g.FillEllipse(brush, centerX - radius, centerY - radius,
radius + radius, radius + radius);
}
}
public class Slider : Control
{
private float _radius;
private PointF _thumbPos;
private SizeF _barSize;
private PointF _barPos;
private int _step = 5;
public Color accentColor = Color.FromArgb(255, 58, 174, 239);
public Color borderColor = Color.White;
public event EventHandler ValueChanged;
public Slider()
{
// This reduces flicker
DoubleBuffered = true;
}
private int _min = 0;
public int Min
{
get => _min;
set
{
_min = value;
RecalculateParameters();
}
}
private int _max = 100;
public int Max
{
get => _max;
set
{
_max = value;
RecalculateParameters();
}
}
private int _value = 50;
public int Value
{
get => _value;
set
{
value = (int)Math.Round(value / (float)_step) * _step;
if (_value != value)
{
_value = value;
ValueChanged?.Invoke(this, EventArgs.Empty);
RecalculateParameters();
}
}
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Brush brushAccent = new SolidBrush(accentColor);
Brush brushEmpty = new SolidBrush(Color.Gray);
Brush brushBorder = new SolidBrush(borderColor);
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
e.Graphics.FillRectangle(brushEmpty,
_barPos.X, _barPos.Y, _barSize.Width, _barSize.Height);
e.Graphics.FillRectangle(brushAccent,
_barPos.X, _barPos.Y, _thumbPos.X - _barPos.X, _barSize.Height);
e.Graphics.FillCircle(brushBorder, _thumbPos.X, _thumbPos.Y, _radius);
e.Graphics.FillCircle(brushAccent, _thumbPos.X, _thumbPos.Y, 0.7f * _radius);
}
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
RecalculateParameters();
}
private void RecalculateParameters()
{
_radius = 0.4F * ClientSize.Height;
_barSize = new SizeF(ClientSize.Width - 4 * _radius, ClientSize.Height * 0.15F);
_barPos = new PointF(_radius, (ClientSize.Height - _barSize.Height) / 2);
_thumbPos = new PointF(
_barSize.Width / (Max - Min) * (Value - Min) + _barPos.X,
_barPos.Y + 0.5f * _barSize.Height);
Invalidate();
}
bool _moving = false;
SizeF _delta;
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
// Difference between tumb and mouse position.
_delta = new SizeF(e.Location.X - _thumbPos.X, e.Location.Y - _thumbPos.Y);
if (_delta.Width * _delta.Width + _delta.Height * _delta.Height <= _radius * _radius)
{
// Clicking inside thumb.
_moving = true;
}
_calculateValue(e);
}
private void _calculateValue(MouseEventArgs e)
{
float thumbX = e.Location.X; // - _delta.Width;
if (thumbX < _barPos.X)
{
thumbX = _barPos.X;
}
else if (thumbX > _barPos.X + _barSize.Width)
{
thumbX = _barPos.X + _barSize.Width;
}
Value = (int)Math.Round(Min + (thumbX - _barPos.X) * (Max - Min) / _barSize.Width);
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
if (_moving)
{
_calculateValue(e);
}
}
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp(e);
_moving = false;
}
}
}

View File

@@ -22,31 +22,43 @@ public class Startup
var userId = WindowsIdentity.GetCurrent().Name;
TaskDefinition td = TaskService.Instance.NewTask();
td.RegistrationInfo.Description = "GHelper Auto Start";
td.Triggers.Add(new LogonTrigger { UserId = userId });
td.Actions.Add(strExeFilePath);
td.Settings.StopIfGoingOnBatteries = false;
td.Settings.DisallowStartIfOnBatteries = false;
td.Settings.ExecutionTimeLimit = TimeSpan.Zero;
Debug.WriteLine(strExeFilePath);
Debug.WriteLine(userId);
try
using (TaskDefinition td = TaskService.Instance.NewTask())
{
TaskService.Instance.RootFolder.RegisterTaskDefinition(taskName, td);
} catch (Exception e)
{
MessageBox.Show(e.ToString(), "Scheduler Error", MessageBoxButtons.OK);
td.RegistrationInfo.Description = "G-Helper Auto Start";
td.Triggers.Add(new LogonTrigger { UserId = userId });
td.Actions.Add(strExeFilePath);
td.Settings.StopIfGoingOnBatteries = false;
td.Settings.DisallowStartIfOnBatteries = false;
td.Settings.ExecutionTimeLimit = TimeSpan.Zero;
Debug.WriteLine(strExeFilePath);
Debug.WriteLine(userId);
try
{
TaskService.Instance.RootFolder.RegisterTaskDefinition(taskName, td);
}
catch (Exception e)
{
MessageBox.Show("Can't create a start up task. Try running Task Scheduler by hand and manually deleting GHelper task if it exists there.", "Scheduler Error", MessageBoxButtons.OK);
}
}
}
public static void UnSchedule()
{
TaskService taskService = new TaskService();
taskService.RootFolder.DeleteTask(taskName);
using (TaskService taskService = new TaskService())
{
try
{
taskService.RootFolder.DeleteTask(taskName);
}
catch (Exception e)
{
MessageBox.Show("Can't remove task. Try running Task Scheduler by hand and manually deleting GHelper task if it exists there.", "Scheduler Error", MessageBoxButtons.OK);
}
}
}
}

19
bloat.bat Normal file
View File

@@ -0,0 +1,19 @@
sc config AsusAppService start= auto
sc config ASUSLinkNear start= auto
sc config ASUSLinkRemote start= auto
sc config ASUSSoftwareManager start= auto
sc config ASUSSwitch start= auto
sc config ASUSSystemAnalysis start= auto
sc config ASUSSystemDiagnosis start= auto
sc config ArmouryCrateControlInterface start= auto
sc START AsusAppService
sc START ASUSLinkNear
sc START ASUSLinkRemote
sc START ASUSSoftwareManager
sc START ASUSSwitch
sc START ASUSSystemAnalysis
sc START ASUSSystemDiagnosis
sc START ArmouryCrateControlInterface
set /p asd="Hit enter to finish"

View File

@@ -1,8 +1,9 @@
# [G-Helper (GHelper)](https://github.com/seerge/g-helper)
# [G-Helper](https://github.com/seerge/g-helper)
[![Github all releases](https://img.shields.io/github/downloads/seerge/g-helper/total.svg)](https://GitHub.com/seerge/g-helper/releases/) [![GitHub release](https://img.shields.io/github/release/seerge/g-helper.svg)](https://GitHub.com/seerge/g-helper/releases/) [![GitHub stars](https://img.shields.io/github/stars/seerge/g-helper.svg?style=social&label=Star)](https://GitHub.com/seerge/g-helper/stargazers/)
## Open source Armoury Crate alternative for Asus laptops such as ROG Zephyrus G14, G15, Flow X13, Flow X16, TUF and other models
## Lightweight Armoury Crate alternative for Asus laptops
### Control tool for ROG Zephyrus G14, G15, Flow X13, Flow X16, TUF, Strix, Scar and other models
A small utility that allows you to do almost everything you could do with Armoury Crate but without extra bloat and unnecessary services.
@@ -11,13 +12,17 @@ A small utility that allows you to do almost everything you could do with Armour
1. Seamless and automatic GPU switching (without asking you to close all apps, etc)
2. All performance modes can be fully customized (with fan curves and PPTs)
3. Very lightweight and consumes almost no resources, doesn't install any services. Just a single exe to run
4. Simple and clean UI with easy access to all settings
4. Simple and clean native UI with easy access to all settings
_Doesn't need administrator privileges to run!_
### [:floppy_disk: Download latest release](https://github.com/seerge/g-helper/releases/latest/download/GHelper.zip)
If you like this app, please [star :star: it on Github](https://github.com/seerge/g-helper) and spread a word about it!
![Screenshot](https://raw.githubusercontent.com/seerge/g-helper/main/docs/screenshot.png)
If you post about the app - please include a link. Thanks.
![Screenshot 2023-03-30 115149](https://user-images.githubusercontent.com/5920850/228799078-bc93148f-6580-4319-b9e6-fbde4d246cd2.png)
### :zap: Main features
@@ -26,7 +31,7 @@ If you like this app, please [star :star: it on Github](https://github.com/seerg
3. Laptop screen refresh rate 60hz or 120hz (144hz, etc depending on the model) with display overdrive (OD)
4. Default and custom fan profiles for every performance mode
5. Power limits (PPT) for every performance mode
6. CPU turbo boost mode
6. CPU turbo boost setting for each mode
7. Keyboard backlit animation and colors
8. Anime matrix control thanks to [Starlight](https://github.com/vddCore/Starlight) + some tweaks from my side (including animated GIFs)
9. FN+F5 cycles performance modes, FN+F4 cycles keyboard animation modes
@@ -34,16 +39,19 @@ If you like this app, please [star :star: it on Github](https://github.com/seerg
11. Battery charge limit to preserve battery health
12. Monitor CPU / GPU temperature, fan speeds and battery discharge rate
### :apple: Automatic switching of modes when on battery or plugged in
### :gear: Automatic switching when on battery or plugged in
- Performance modes (app remembers last mode used on battery or when plugged)
- Optimized GPU mode - disables dGPU on battery and enables when plugged
- Auto Screen refresh rate (60hz on battery, 120+ hz when plugged)
- Keyboard backlight can be turned off on battery
To keep auto switching and hotkeys working the app needs to stay in running in the tray. It doesn't consume any resources.
### :rocket: Performance Modes
Modes are **same** as in Armory Crate (as they are stored in bios), including default fan curves
Modes are **same** as in Armoury Crate (as they are stored in bios), including default fan curves
![Screenshot 2023-03-29 122534](https://user-images.githubusercontent.com/5920850/228505581-4e7d087c-bd0a-4a48-b572-de2c01192830.png)
1. Silent (minimal or no fans, 70W PPT total, up to 45W PPT to CPU) + Best power efficiency setting in windows
2. Balanced (balanced fans, 100W PPT total, up to 45W PPT to CPU) + Balanced setting in windows
@@ -60,17 +68,18 @@ PPTs are shown for G14 2022, for other models PPTs will be different as they are
## :question: FAQ
### How do I stop Armory Crate install popup appearing every time I press M4 / Rog key?
Go to BIOS (F2 on boot), open Advanced Settings and disable "Armory Control Interface". If it still appears - delete or move somwhere following file C:\Windows\System32\ASUSACCI\ArmouryCrateKeyControl.exe
### How do I stop the Armory Crate install popup appearing every time I press the M4 / Rog key?
Go to BIOS (F2 on boot), open Advanced Settings and disable "Armory Control Interface".
If it still appears - delete or move somewhere following file ``C:\Windows\System32\ASUSACCI\ArmouryCrateKeyControl.exe``
### Why Ultimate GPU mode is not available on my laptop?
### Why is Ultimate GPU mode not available on my laptop?
Ultimate mode is supported (by hardware) only on G14 2022 (and possibly other models from 2022+)
### I can't set Eco mode (disable dGPU) on my G14 2020
Unfortunately 2020 model doesn't support that on hardware level
### Should I apply custom PPTs and fan profiles?
You don't have to, it's purely optional. From my experience built in (in bios) performance modes work well. Limit your power or apply custom fan curves only if you have issues. As sooon as you click Apply in fan + power section bios will be considering fan profile as "custom"! (no matter if you modified it or not)
You don't have to, it's purely optional. From my experience built in (in bios) performance modes work well. Limit your power or apply custom fan curves only if you have issues. As soon as you click Apply in the fan + power section bios will be considering the fan profile as "custom"! (no matter if you modified it or not)
### How does G-helper control my fan speeds?
It doesn't. Your bios does (same as in case with armoury). What G-helper can do - is (optionally) set a custom fan profile to current performance mode consisting of 8 pairs of temperature + fan speed % via same endpoint armoury seem to use.
@@ -79,11 +88,17 @@ It doesn't. Your bios does (same as in case with armoury). What G-helper can do
Click on them
### I don't see a GPU temperature in G-helper
Most probably either you are using Eco / Optimized mode and your dGPU is simply off, or your windows has put dGPU into sleep (to preserve power). In this situations G-helper won't be able to reach your GPU and get readings
Most probably either you are using Eco / Optimized mode and your dGPU is simply off, or your windows has put the dGPU into sleep (to preserve power). In this situations G-helper won't be able to reach your GPU and get readings
### It says, that app is already running
Please check system tray for a (G) icon. By default windows is keen to hide all icons, so you may need to click ^ to see them all. I would advise to right click on Task Bar select Task Bar Settings -> Other System Tray icons -> Mark G-Helper to be always ON.
### App doesn't start / or crashes, what should I do ?
Open "Event Viewer" from start menu, go to Windows Logs -> Application and check for recent Errors mentioning G-Helper. If you see one - please post a [new issue](https://github.com/seerge/g-helper/issues) with all details from this error.
### Can I use MyASUS app along with G-Helper?
Sure, you can! The only problem is that MyASUS may override the battery charge limit that you set before. My advice in such a situation would be to set the same limit (i.e. 80%) in both MyASUS and G-Helper.
### How do I uninstall G-helper?
G-helper is a single exe, and it doesn't install anything in the system. To remove it - you can simply delete exe :) If you have applied any custom fan profiles or PPTs - before removing I would recommend selecting your favorite performance mode (for example balanced) and clicking "Factory defaults" under Fans + Power.
@@ -95,15 +110,17 @@ G-helper is a single exe, and it doesn't install anything in the system. To remo
2. Unzip to a folder of your choice
3. Run **GHelper.exe**
### Dependencies
### Dependencies & Requirements
- App requires [.NET7](https://dotnet.microsoft.com/en-us/download) to be installed. Most probably you already have it. Otherwise you can [download it](https://dotnet.microsoft.com/en-us/download).
- Microsoft [.NET7](https://dotnet.microsoft.com/en-us/download). Most probably you already have it. Otherwise you can [download it](https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/sdk-7.0.202-windows-x64-installer) from the official website.
- I recommend keeping "Asus Optimization Service" running, as it keeps basic laptop hotkeys such as screen or keyboard brightness adjustment working. If you have (or had) MyASUS app installed, that service is most probably still up and running even after MyASUS uninstalls. It's part of [Asus System Control Interface](https://www.asus.com/support/FAQ/1047338/). You can install it, and later disable / remove unnecessary services by running [this bat file](https://raw.githubusercontent.com/seerge/g-helper/main/debloat.bat) as admin.
- [Asus System Control Interface](https://dlcdnets.asus.com/pub/ASUS/nb/Image/CustomComponent/ASUSSystemControlInterfaceV3/ASUSSystemControlInterfaceV3.exe). If you have or had MyASUS app installed this "driver" probably still in place (even after MyASUS uninstalls). Alternatively - you can download and install it
- It's not recommended to use an app in combination with Armoury Crate, cause they adjust the same settings. You can [uninstall it using it's own uninstall tool](https://dlcdnets.asus.com/pub/ASUS/mb/14Utilities/Armoury_Crate_Uninstall_Tool.zip?model=armoury%20crate). Just in case, you can always install it back later.
- Optionally(!) you can disable / remove unnecessary services by running [this debloat bat file](https://raw.githubusercontent.com/seerge/g-helper/main/debloat.bat) as admin. To restore services - run [this bloat bat file](https://raw.githubusercontent.com/seerge/g-helper/main/bloat.bat) instead.
Note: Doesn't need administrator privileges to run!
- I recommend keeping "Asus Optimization Service" running, as it keeps basic laptop hotkeys such as screen or keyboard brightness adjustment working.
- It's not recommended to use an app in combination with Armoury Crate services, because they adjust the same settings. You can [uninstall it using it's own uninstall tool](https://dlcdnets.asus.com/pub/ASUS/mb/14Utilities/Armoury_Crate_Uninstall_Tool.zip?model=armoury%20crate). Just in case, you can always install it back later.
-------------------------------