From 6fbce2f49572761d88e5208230785ab811ff599c Mon Sep 17 00:00:00 2001 From: Serge <5920850+seerge@users.noreply.github.com> Date: Wed, 29 Mar 2023 21:06:36 +0200 Subject: [PATCH 1/4] Update README.md --- docs/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/README.md b/docs/README.md index af1c192be..7847ac7fa 100644 --- a/docs/README.md +++ b/docs/README.md @@ -16,6 +16,7 @@ A small utility that allows you to do almost everything you could do with Armour ### [: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! + If you post about app - please include a link. Thanks. ![Screenshot 2023-03-29 122524](https://user-images.githubusercontent.com/5920850/228505505-c3682509-a9e4-4cac-a5fd-e10d30c477cd.png) From 63092d8415970e04773aafddfefc420efe26c11d Mon Sep 17 00:00:00 2001 From: seerge Date: Wed, 29 Mar 2023 23:32:12 +0200 Subject: [PATCH 2/4] Removed unsupported aura modes for some models --- app/Aura.cs | 20 ++++++++++++++++--- app/GHelper.csproj | 2 +- app/HardwareMonitor.cs | 45 ++++++++++++++++++++---------------------- app/Program.cs | 5 +---- app/Settings.cs | 4 ++-- 5 files changed, 42 insertions(+), 34 deletions(-) diff --git a/app/Aura.cs b/app/Aura.cs index b24d5c10f..69e46c7bc 100644 --- a/app/Aura.cs +++ b/app/Aura.cs @@ -71,9 +71,8 @@ public static Dictionary GetSpeeds() { 2, "Fast" } }; } - public static Dictionary GetModes() - { - return new Dictionary + + static Dictionary _modes = new Dictionary { { 0, "Static" }, { 1, "Breathe" }, @@ -81,6 +80,21 @@ public static Dictionary GetModes() { 3, "Rainbow" }, { 10, "Strobe" }, }; + + public static Dictionary GetModes() + { + if (Program.config.ContainsModel("TUF")) + { + _modes.Remove(3); + } + + if (Program.config.ContainsModel("401")) + { + _modes.Remove(2); + _modes.Remove(3); + } + + return _modes; } diff --git a/app/GHelper.csproj b/app/GHelper.csproj index a4a29d1a4..509b9e1ba 100644 --- a/app/GHelper.csproj +++ b/app/GHelper.csproj @@ -16,7 +16,7 @@ x64 False True - 0.42 + 0.43 diff --git a/app/HardwareMonitor.cs b/app/HardwareMonitor.cs index 8576ce8e1..8726ad234 100644 --- a/app/HardwareMonitor.cs +++ b/app/HardwareMonitor.cs @@ -31,43 +31,29 @@ private static string FormatFan(int fan) public static void ReadSensors() { - cpuTemp = -1; batteryDischarge = -1; cpuFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.CPU_Fan)); gpuFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.GPU_Fan)); midFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.Mid_Fan)); - try - { - cpuTemp = Program.wmi.DeviceGet(ASUSWmi.Temp_CPU); - if (cpuTemp < 0) - { - var ct = new PerformanceCounter("Thermal Zone Information", "Temperature", @"\_TZ.THRM", true); - cpuTemp = ct.NextValue() - 273; - ct.Dispose(); - } - } catch - { - Logger.WriteLine("Failed reading CPU temp"); - } + cpuTemp = Program.wmi.DeviceGet(ASUSWmi.Temp_CPU); + gpuTemp = Program.wmi.DeviceGet(ASUSWmi.Temp_GPU); - try + if (cpuTemp < 0) try { - var cb = new PerformanceCounter("Power Meter", "Power", "Power Meter (0)", true); - batteryDischarge = cb.NextValue() / 1000; - cb.Dispose(); - + var ct = new PerformanceCounter("Thermal Zone Information", "Temperature", @"\_TZ.THRM", true); + cpuTemp = ct.NextValue() - 273; + ct.Dispose(); } catch { - Logger.WriteLine("Failed reading Battery discharge"); + Logger.WriteLine("Failed reading CPU temp"); } - try + if (gpuTemp < 0) try { - gpuTemp = Program.wmi.DeviceGet(ASUSWmi.Temp_GPU); - if (gpuTemp < 0) - gpuTemp = GpuTemperatureProvider?.GetCurrentTemperature(); + if (GpuTemperatureProvider is null) RecreateGpuTemperatureProvider(); + gpuTemp = GpuTemperatureProvider?.GetCurrentTemperature(); } catch (Exception ex) { @@ -76,6 +62,17 @@ public static void ReadSensors() Logger.WriteLine(ex.ToString()); } + try + { + var cb = new PerformanceCounter("Power Meter", "Power", "Power Meter (0)", true); + batteryDischarge = cb.NextValue() / 1000; + cb.Dispose(); + + } + catch + { + Logger.WriteLine("Failed reading Battery discharge"); + } } public static void RecreateGpuTemperatureProviderWithDelay() { diff --git a/app/Program.cs b/app/Program.cs index 11a1f3627..9faece969 100644 --- a/app/Program.cs +++ b/app/Program.cs @@ -59,13 +59,10 @@ public static void Main() Application.EnableVisualStyles(); - SystemEvents.UserPreferenceChanged += new UserPreferenceChangedEventHandler(SystemEvents_UserPreferenceChanged); - var ds = settingsForm.Handle; trayIcon.MouseClick += TrayIcon_MouseClick; - wmi.SubscribeToEvents(WatcherEventArrived); settingsForm.InitGPUMode(); @@ -75,10 +72,10 @@ public static void Main() settingsForm.SetStartupCheck(Startup.IsScheduled()); SetAutoModes(); - HardwareMonitor.RecreateGpuTemperatureProvider(); // Subscribing for system power change events SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged; + SystemEvents.UserPreferenceChanged += SystemEvents_UserPreferenceChanged; if (Environment.CurrentDirectory.Trim('\\') == Application.StartupPath.Trim('\\')) diff --git a/app/Settings.cs b/app/Settings.cs index afa9d9820..6a3aec5b8 100644 --- a/app/Settings.cs +++ b/app/Settings.cs @@ -118,7 +118,7 @@ public SettingsForm() sliderBattery.ValueChanged += SliderBattery_ValueChanged; Program.trayIcon.MouseMove += TrayIcon_MouseMove; - aTimer = new System.Timers.Timer(500); + aTimer = new System.Timers.Timer(1000); aTimer.Elapsed += OnTimedEvent; // Subscribing for monitor power on events @@ -878,7 +878,7 @@ private void SettingsForm_VisibleChanged(object? sender, EventArgs e) this.Top = Screen.FromControl(this).WorkingArea.Height - 10 - this.Height; this.Activate(); - aTimer.Interval = 300; + //aTimer.Interval = 300; aTimer.Enabled = true; //RefreshSensors(); From ff7618f16f0a3a36f015829f26e7d5c850c8dc61 Mon Sep 17 00:00:00 2001 From: Serge <5920850+seerge@users.noreply.github.com> Date: Wed, 29 Mar 2023 23:33:14 +0200 Subject: [PATCH 3/4] Update README.md --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 7847ac7fa..853d599e1 100644 --- a/docs/README.md +++ b/docs/README.md @@ -11,7 +11,7 @@ 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 ### [:floppy_disk: Download latest release](https://github.com/seerge/g-helper/releases/latest/download/GHelper.zip) From 1d43ca3ce4e1ef4ab53d8543ccd6f701e9c2aaf4 Mon Sep 17 00:00:00 2001 From: seerge Date: Thu, 30 Mar 2023 00:00:20 +0200 Subject: [PATCH 4/4] Max fan RPM auto calibration --- app/AppConfig.cs | 2 ++ app/Fans.cs | 12 +++--------- app/HardwareMonitor.cs | 18 +++++++++++++++++- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/app/AppConfig.cs b/app/AppConfig.cs index 76f823cc9..463f68fcc 100644 --- a/app/AppConfig.cs +++ b/app/AppConfig.cs @@ -108,6 +108,8 @@ public string getParamName(int device, string paramName = "fan_profile") if (device == 1) name = "gpu"; + else if (device == 2) + name = "mid"; else name = "cpu"; diff --git a/app/Fans.cs b/app/Fans.cs index feae7c6ad..17e864d86 100644 --- a/app/Fans.cs +++ b/app/Fans.cs @@ -18,7 +18,7 @@ static string ChartPercToRPM(int percentage, string unit = "") { 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) @@ -89,14 +89,8 @@ public Fans() 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(); diff --git a/app/HardwareMonitor.cs b/app/HardwareMonitor.cs index 8726ad234..1efb90668 100644 --- a/app/HardwareMonitor.cs +++ b/app/HardwareMonitor.cs @@ -14,6 +14,19 @@ public static class HardwareMonitor 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 @@ -23,10 +36,13 @@ private static string FormatFan(int fan) 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(fan / 0.6), 100).ToString() + "%"; // relatively to 6000 rpm + return " Fan: " + Math.Min(Math.Round((float)fan/fanMax*100), 100).ToString() + "%"; // relatively to 6000 rpm } public static void ReadSensors()