Compare commits

...

7 Commits

Author SHA1 Message Date
Serge
4e6f55c24d Create LICENSE 2023-03-15 14:05:01 +01:00
Serge
c029df357a Update README.md 2023-03-15 12:45:49 +01:00
Serge
8d19b5f89c Update README.md 2023-03-15 12:24:54 +01:00
seerge
7683e68df3 Merge branch 'main' of https://github.com/seerge/g14-helper 2023-03-14 23:07:52 +01:00
seerge
e45bcdf8a5 Adjusted PPTs for 2021 model, added windows PowerModes 2023-03-14 23:07:49 +01:00
Serge
ab8d42c216 Update README.md 2023-03-14 17:55:25 +01:00
seerge
d248fcf384 Screenshot 2023-03-14 17:53:15 +01:00
9 changed files with 132 additions and 110 deletions

View File

@@ -27,12 +27,16 @@ public class ASUSWmi
public const uint DevsCPUFanCurve = 0x00110024;
public const uint DevsGPUFanCurve = 0x00110025;
public const int PPT_TotalA0 = 0x001200A0;
public const int PPT_TotalA1 = 0x001200A1;
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
public const int PPT_APUA3 = 0x001200A3; // APU PPT ON 2021, doesn't work on 2022
public const int PPT_CPUB0 = 0x001200B0;
public const int PPT_CPUB1 = 0x001200B1;
public const int PPT_CPUA2 = 0x001200A2;
public const int PPT_CPUB0 = 0x001200B0; // CPU PPT on 2022
public const int PPT_CPUB1 = 0x001200B1; // APU PPT on 2022
public const int PPT_APUC1 = 0x001200C1;
public const int PPT_APUC2 = 0x001200C2;
public const int PerformanceBalanced = 0;
public const int PerformanceTurbo = 1;
@@ -44,11 +48,11 @@ public class ASUSWmi
public const int MaxTotal = 150;
public const int MinTotal = 15;
public const int MinTotal = 5;
public const int DefaultTotal = 125;
public const int MaxCPU = 90;
public const int MinCPU = 15;
public const int MinCPU = 5;
public const int DefaultCPU = 80;

13
Fans.cs
View File

@@ -168,8 +168,17 @@ namespace GHelper
public void InitPower(bool changed = false)
{
panelPower.Visible = (Program.wmi.DeviceGet(ASUSWmi.PPT_TotalA0) >= 0);
panelCPU.Visible = (Program.wmi.DeviceGet(ASUSWmi.PPT_CPUB0) >= 0);
bool cpuBmode = (Program.wmi.DeviceGet(ASUSWmi.PPT_CPUB0) >= 0); // 2022 model +
bool cpuAmode = (Program.wmi.DeviceGet(ASUSWmi.PPT_TotalA0) >= 0); // 2021 model +
panelPower.Visible = cpuAmode;
panelCPU.Visible = cpuBmode;
// Yes, that's stupid, but Total slider on 2021 model actually adjusts CPU PPT
if (!cpuBmode)
{
label1.Text = "CPU SPPT";
}
int limit_total;
int limit_cpu;

View File

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

21
LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 Serge
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -458,6 +458,15 @@ public class NativeMethods
static readonly Guid GUID_CPU = new Guid("54533251-82be-4824-96c1-47b60b740d00");
static readonly Guid GUID_BOOST = new Guid("be337238-0d82-4146-a960-4f3749d470c7");
[DllImportAttribute("powrprof.dll", EntryPoint = "PowerGetActualOverlayScheme")]
public static extern uint PowerGetActualOverlayScheme(out Guid ActualOverlayGuid);
[DllImportAttribute("powrprof.dll", EntryPoint = "PowerGetEffectiveOverlayScheme")]
public static extern uint PowerGetEffectiveOverlayScheme(out Guid EffectiveOverlayGuid);
[DllImportAttribute("powrprof.dll", EntryPoint = "PowerSetActiveOverlayScheme")]
public static extern uint PowerSetActiveOverlayScheme(Guid OverlaySchemeGuid);
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct DEVMODE
{
@@ -666,4 +675,20 @@ public class NativeMethods
*/
}
public static void SetPowerScheme(int mode)
{
switch (mode)
{
case 0: // balanced
PowerSetActiveOverlayScheme(new Guid("00000000-0000-0000-0000-000000000000"));
break;
case 1: // turbo
PowerSetActiveOverlayScheme(new Guid("ded574b5-45a0-4f42-8737-46345c09c238"));
break;
case 2: //silent
PowerSetActiveOverlayScheme(new Guid("961cc777-2547-4f9d-8174-7d86181b8a7a"));
break;
}
}
}

View File

@@ -21,10 +21,7 @@ public static class Logger
w.WriteLine($"{DateTime.Now}: {logMessage}");
w.Close();
}
} catch
{
}
} catch { }
if (new Random().Next(100) == 1) Cleanup();
@@ -33,9 +30,12 @@ public static class Logger
public static void Cleanup()
{
var file = File.ReadAllLines(logFile);
int skip = Math.Max(0, file.Count() - 500);
File.WriteAllLines(logFile,file.Skip(skip).ToArray());
try
{
var file = File.ReadAllLines(logFile);
int skip = Math.Max(0, file.Count() - 500);
File.WriteAllLines(logFile, file.Skip(skip).ToArray());
} catch { }
}
}
@@ -46,31 +46,6 @@ namespace GHelper
{
// Native methods for sleep detection
[DllImport("Powrprof.dll", SetLastError = true)]
static extern uint PowerRegisterSuspendResumeNotification(uint flags, ref DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS receipient, ref IntPtr registrationHandle);
private const int WM_POWERBROADCAST = 536; // (0x218)
private const int PBT_APMPOWERSTATUSCHANGE = 10; // (0xA) - Power status has changed.
private const int PBT_APMRESUMEAUTOMATIC = 18; // (0x12) - Operation is resuming automatically from a low-power state.This message is sent every time the system resumes.
private const int PBT_APMRESUMESUSPEND = 7; // (0x7) - Operation is resuming from a low-power state.This message is sent after PBT_APMRESUMEAUTOMATIC if the resume is triggered by user input, such as pressing a key.
private const int PBT_APMSUSPEND = 4; // (0x4) - System is suspending operation.
private const int PBT_POWERSETTINGCHANGE = 32787; // (0x8013) - A power setting change event has been received.
private const int DEVICE_NOTIFY_CALLBACK = 2;
[StructLayout(LayoutKind.Sequential)]
struct DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS
{
public DeviceNotifyCallbackRoutine Callback;
public IntPtr Context;
}
public delegate int DeviceNotifyCallbackRoutine(IntPtr context, int type, IntPtr setting);
//
public static NotifyIcon trayIcon = new NotifyIcon
{
Text = "G-Helper",
@@ -128,20 +103,6 @@ namespace GHelper
SetAutoModes();
HardwareMonitor.RecreateGpuTemperatureProvider();
// Subscribing for native power change events
/*
IntPtr registrationHandle = new IntPtr();
DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS recipient = new DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS();
recipient.Callback = new DeviceNotifyCallbackRoutine(DeviceNotifyCallback);
recipient.Context = IntPtr.Zero;
IntPtr pRecipient = Marshal.AllocHGlobal(Marshal.SizeOf(recipient));
Marshal.StructureToPtr(recipient, pRecipient, false);
uint result = PowerRegisterSuspendResumeNotification(DEVICE_NOTIFY_CALLBACK, ref recipient, ref registrationHandle);
*/
// Subscribing for monitor power on events
var settingGuid = new NativeMethods.PowerSettingGuid();
unRegPowerNotify = NativeMethods.RegisterPowerSettingNotification(ds, settingGuid.ConsoleDisplayState, NativeMethods.DEVICE_NOTIFY_WINDOW_HANDLE);
@@ -149,29 +110,11 @@ namespace GHelper
// Subscribing for system power change events
SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
CheckForUpdates();
Application.Run();
}
private static int DeviceNotifyCallback(IntPtr context, int type, IntPtr setting)
{
Logger.WriteLine($"Power callback {type}");
switch (type)
{
case PBT_APMRESUMEAUTOMATIC:
settingsForm.BeginInvoke(delegate
{
SetAutoModes();
});
break;
}
return 0;
}
static async void CheckForUpdates()
{

View File

@@ -1,43 +1,48 @@
# G-Helper / GHelper
# G-Helper | GHelper
## For Asus ROG Zephyrus G14, G15, Flow X13, Flow X16, and other models
## Open source Armory Crate alternative for Asus ROG Zephyrus G14, G15, Flow X13, Flow X16, and other models
A small utility that allows you do almost everyting you could do with Armory Crate but without extra bloat and unnecessary services.
A small utility that allows you to do almost everything you could do with Armory Crate but without extra bloat and unnecessary services.
### [Download latest release](https://github.com/seerge/g-helper/releases)
## Main advantages
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
## [Download latest release](https://github.com/seerge/g-helper/releases)
![Screenshot](https://raw.githubusercontent.com/seerge/g-helper/main/screenshot.png)
## NEW (and experimental) features
1. Set Power limits (PPT) for Total (APU + dGPU) and CPU.
2. Anime matrix control thanks to [Starlight](https://github.com/vddCore/Starlight) + some tweaks from my side
## Main features
1. Switch between built-in system **Performance modes** Silent / Balanced / Turbo and apply default fan curves
2. Switch between Eco / Standard or Ultimate **GPU modes**
3. Change laptop screen refresh rate - 60hz or your maximum (120hz, 144hz, etc depending on the model) with display overdrive (OD)
4. View default fan profiles for every mode and **auto apply** custom ones
5. Control keyboard backlit animation and colors
6. Set battery charge limit to preserve battery health
7. Monitor CPU temperature, fan speeds and battery discharge rate
8. **Automatically switch to Eco(iGPU)/60hz on battery** and back to Standard(GPU)/120hz modes when plugged
9. Support for FN+F5 to cycle through performance modes (with OSD notification) and FN+F4 to cycle through keeyboard animation modes
10. Basic keybindings for M3 and M4 keys
11. Turn cpu turbo boost on/off with one checkbox to keep temps cooler
1. Built-in **Performance modes**: Silent - Balanced - Turbo (with default fan curves)
2. **GPU modes**: Eco -Standard - Ultimate
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 urbo boost 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 to cycle through performance modes (with OSD notification) and FN+F4 to cycle through keyboard animation modes
10. Keybindings for M3 and M4 keys
11. Battery charge limit to preserve battery health
12. Monitor CPU / GPU temperature, fan speeds and battery discharge rate
Designed and developed for Asus Zephyrus G14 2022 (with AMD Radeon iGPU and dGPU). But could and should potentially work for G14 of 2021 and 2020, G15, X FLOW, and other ROG models for relevant and supported features.
## Automatic switching of modes when on battery or plugged in
- Performance modes
- GPU modes
- Screen refresh rate
To keep autoswitching and hotkeys work app needs to stay in running in tray. It doesn't consume any resources.
To keep auto switching and hotkeys working the app needs to stay in running in the tray. It doesn't consume any resources.
## Performance Profile switching
## Performance Modes
Profiles are **same** as in Armory Crate (as they are stored in bios), including default fan curves
Modes are **same** as in Armory Crate (as they are stored in bios), including default fan curves
1. Silent (minimal or no fans, 70W PPT total, up to 45W PPT to CPU)
2. Balanced (balanced fans, 100W PPT total, up to 45W PPT to CPU)
3. Turbo (intense fans, 125W PPT total, up to 80W PPT to CPU)
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
3. Turbo (intense fans, 125W PPT total, up to 80W PPT to CPU) + Best performance setting in windows
PPTs are shown for G14 2022, for other models PPTs will be different as they are set in bios.
@@ -53,18 +58,24 @@ PPTs are shown for G14 2022, for other models PPTs will be different as they are
2. Unzip to a folder of your choice
3. Run **GHelper.exe**
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).
### Dependencies
I recommend to keep "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 an running even after MyASUS uninstall. It's part of [Asus System Controll Interface](https://www.asus.com/support/FAQ/1047338/). You can install it, and later disable / remove unnecesarily services by running [this bat file](https://raw.githubusercontent.com/seerge/g-helper/main/stop-asus-sv.bat) as admin.
- 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).
Note: Uses low level ASUS ACPI commands and doens't require Armory Crate to be installed at all! 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. 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/stop-asus-sv.bat) as admin.
I don`t have Microsoft certificate to sign app yet, so if you get a warning from Windows Defender on launch (Windows Protected your PC), click More Info -> Run anyway. Alternatively you can compile and run project by yourself using Visual Studio :)
- It's not recommended to use an app in combination with Armory 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.
Note: Doesn't need administrator privileges to run!
-------------------------------
Designed and developed for Asus Zephyrus G14 2022 (with AMD Radeon iGPU and dGPU). But could and should potentially work for G14 of 2021 and 2020, G15, X FLOW, and other ROG models for relevant and supported features.
I don't have a Microsoft certificate to sign the app yet, so if you get a warning from Windows Defender on launch (Windows Protected your PC), click More Info -> Run anyway. Alternatively you can compile and run project by yourself using Visual Studio :)
Settings file is stored at %AppData%\GHelper
P.S.: It's not recommended to use app in combination with Armory Crate, cause they adjust same settings.
------------------
Debloating helps to save your battery and keep laptop a bit cooler

View File

@@ -741,9 +741,11 @@ namespace GHelper
if (limit_cpu > ASUSWmi.MaxCPU) return;
if (limit_cpu < ASUSWmi.MinCPU) return;
Program.wmi.DeviceSet(ASUSWmi.PPT_TotalA0, limit_total);
Program.wmi.DeviceSet(ASUSWmi.PPT_TotalA1, limit_total);
Program.wmi.DeviceSet(ASUSWmi.PPT_CPUB0, limit_cpu);
if (Program.wmi.DeviceGet(ASUSWmi.PPT_TotalA0) >= 0)
Program.wmi.DeviceSet(ASUSWmi.PPT_TotalA0, limit_total);
if (Program.wmi.DeviceGet(ASUSWmi.PPT_CPUB0) >= 0)
Program.wmi.DeviceSet(ASUSWmi.PPT_CPUB0, limit_cpu);
Logger.WriteLine("PowerLimits " + limit_total.ToString() + ", " + limit_cpu.ToString());
@@ -819,6 +821,13 @@ namespace GHelper
AutoFansAndPower();
NativeMethods.SetPowerScheme(PerformanceMode);
if (NativeMethods.PowerGetEffectiveOverlayScheme(out Guid activeScheme) == 0)
{
Debug.WriteLine("Effective :" + activeScheme);
}
if (fans != null && fans.Text != "")
{
fans.InitFans();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 MiB

After

Width:  |  Height:  |  Size: 3.4 MiB