From 4f6de3c6a3ce2bfd1a7117a0a630a728e1aab219 Mon Sep 17 00:00:00 2001 From: Serge <5920850+seerge@users.noreply.github.com> Date: Mon, 14 Aug 2023 16:48:16 +0200 Subject: [PATCH] GPU Mode Backlight --- app/AppConfig.cs | 2 +- app/AsusUSB.cs | 40 ++++++++++++++++++++++++++++++++++----- app/Extra.cs | 14 ++++---------- app/Gpu/GPUModeControl.cs | 4 ++-- app/Mode/ModeControl.cs | 2 ++ app/Settings.cs | 8 ++++++++ 6 files changed, 52 insertions(+), 18 deletions(-) diff --git a/app/AppConfig.cs b/app/AppConfig.cs index e1e1c844..8b92509c 100644 --- a/app/AppConfig.cs +++ b/app/AppConfig.cs @@ -364,7 +364,7 @@ public static class AppConfig public static bool IsGPUFixNeeded() { - return ContainsModel("GA402X") || ContainsModel("GV302") || ContainsModel("FX506"); + return ContainsModel("GA402X") || ContainsModel("GV302") || ContainsModel("FX506") || ContainsModel("GU603V"); } public static bool IsGPUFix() diff --git a/app/AsusUSB.cs b/app/AsusUSB.cs index ed5aaf77..ba000f31 100644 --- a/app/AsusUSB.cs +++ b/app/AsusUSB.cs @@ -1,5 +1,8 @@ -using GHelper.Helpers; +using GHelper.Gpu; +using GHelper.Helpers; using HidLibrary; +using NAudio.Gui; +using System.Drawing; using System.Text; namespace GHelper @@ -37,6 +40,7 @@ namespace GHelper public static class AsusUSB { public const int HEATMAP = 20; + public const int GPUMODE = 21; public const int ASUS_ID = 0x0b05; @@ -161,7 +165,8 @@ namespace GHelper { 2, Properties.Strings.AuraColorCycle }, { 3, Properties.Strings.AuraRainbow }, { 10, Properties.Strings.AuraStrobe }, - { HEATMAP, "Heatmap"} + { HEATMAP, "Heatmap"}, + { GPUMODE, "GPU Mode" } }; static Dictionary _modesStrix = new Dictionary @@ -194,6 +199,7 @@ namespace GHelper _modes.Remove(2); _modes.Remove(3); _modes.Remove(HEATMAP); + _modes.Remove(GPUMODE); } if (AppConfig.IsAdvantageEdition()) @@ -531,6 +537,25 @@ namespace GHelper } + public static void ApplyGPUColor() + { + if (AppConfig.Get("aura_mode") != GPUMODE) return; + + switch (GPUModeControl.GpuMode) + { + case AsusACPI.GPUModeUltimate: + ApplyColor(Color.Red, true); + break; + case AsusACPI.GPUModeEco: + ApplyColor(Color.Green, true); + break; + default: + ApplyColor(Color.Yellow, true); + break; + } + } + + public static void ApplyAura() { @@ -539,17 +564,22 @@ namespace GHelper SetColor(AppConfig.Get("aura_color")); SetColor2(AppConfig.Get("aura_color2")); + timer.Enabled = false; + if (Mode == HEATMAP) { SetHeatmap(true); timer.Enabled = true; return; - } - else + } + + if (Mode == GPUMODE) { - timer.Enabled = false; + ApplyGPUColor(); + return; } + Task.Run(async () => { diff --git a/app/Extra.cs b/app/Extra.cs index a402e806..103740e4 100644 --- a/app/Extra.cs +++ b/app/Extra.cs @@ -331,16 +331,10 @@ namespace GHelper { try { - Task.Run(() => - { - int hibernate = PowerNative.GetHibernateAfter(); - if (hibernate < 0 || hibernate > numericHibernateAfter.Maximum) hibernate = 0; - BeginInvoke(delegate - { - numericHibernateAfter.Value = hibernate; - numericHibernateAfter.ValueChanged += NumericHibernateAfter_ValueChanged; - }); - }); + int hibernate = PowerNative.GetHibernateAfter(); + if (hibernate < 0 || hibernate > numericHibernateAfter.Maximum) hibernate = 0; + numericHibernateAfter.Value = hibernate; + numericHibernateAfter.ValueChanged += NumericHibernateAfter_ValueChanged; } catch (Exception ex) diff --git a/app/Gpu/GPUModeControl.cs b/app/Gpu/GPUModeControl.cs index 7b25db8e..8ec42adb 100644 --- a/app/Gpu/GPUModeControl.cs +++ b/app/Gpu/GPUModeControl.cs @@ -10,6 +10,8 @@ namespace GHelper.Gpu SettingsForm settings; ScreenControl screenControl = new ScreenControl(); + public static int GpuMode; + public GPUModeControl(SettingsForm settingsForm) { settings = settingsForm; @@ -23,8 +25,6 @@ namespace GHelper.Gpu Logger.WriteLine("Eco flag : " + eco); Logger.WriteLine("Mux flag : " + mux); - int GpuMode; - if (mux == 0) { GpuMode = AsusACPI.GPUModeUltimate; diff --git a/app/Mode/ModeControl.cs b/app/Mode/ModeControl.cs index 23d9e77a..88c22870 100644 --- a/app/Mode/ModeControl.cs +++ b/app/Mode/ModeControl.cs @@ -314,6 +314,8 @@ namespace GHelper.Mode { Logger.WriteLine(ex.ToString()); } + + settings.GPUInit(); }); } diff --git a/app/Settings.cs b/app/Settings.cs index 8a65c637..d24e1300 100644 --- a/app/Settings.cs +++ b/app/Settings.cs @@ -582,6 +582,14 @@ namespace GHelper }); } + public void GPUInit() + { + Invoke(delegate + { + if (fans != null && fans.Text != "") fans.InitGPU(); + }); + } + public void FansToggle(int index = 0) { if (fans == null || fans.Text == "")