Skip to content

Commit

Permalink
Add EPP control functionality and UI integration
Browse files Browse the repository at this point in the history
  • Loading branch information
A7GoD committed Jan 19, 2025
1 parent abc4e9f commit ebdb0e7
Show file tree
Hide file tree
Showing 4 changed files with 202 additions and 8 deletions.
6 changes: 5 additions & 1 deletion app/AppConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ public static bool IsAnimeMatrix()
{
return ContainsModel("GA401") || ContainsModel("GA402") || ContainsModel("GU604V");
}

public static bool IsSlash()
{
return ContainsModel("GA403") || ContainsModel("GU605") || ContainsModel("GA605");
Expand Down Expand Up @@ -723,5 +723,9 @@ public static bool IsAutoStatusLed()
return Is("auto_status_led");
}

public static void SetEPP(int value)
{
PowerNative.SetEPP(value);
}

}
130 changes: 130 additions & 0 deletions app/Fans.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 25 additions & 6 deletions app/Fans.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,17 @@ public Fans()
comboPowerMode.DisplayMember = "Value";
comboPowerMode.ValueMember = "Key";

if (AppConfig.IsAlly())
{
sliderEPP.Value = PowerNative.GetEPP();
sliderEPP.Minimum = 0;
sliderEPP.Maximum = 100;
sliderEPP.Value = AppConfig.GetMode("epp_value", 0); // Default value is 0 if not set
sliderEPP.Scroll += SliderEPP_Scroll;
labelEPP.Text = $"EPP";
labelEPPSliderRight.Text = $"{sliderEPP.Value}%";
}

FillModes();
InitAll();
InitCPU();
Expand Down Expand Up @@ -408,7 +419,8 @@ private void VisualiseAdvanced()
panelAdvancedApply.Visible = false;
panelDownload.Visible = true;

} else
}
else
{
panelDownload.Visible = false;
}
Expand Down Expand Up @@ -828,7 +840,7 @@ public void InitPowerPlan()

comboPowerMode.Enabled = !batterySaver;

if (batterySaver)
if (batterySaver)
comboPowerMode.SelectedIndex = 0;
else
comboPowerMode.SelectedValue = powerMode;
Expand Down Expand Up @@ -933,7 +945,7 @@ public void InitPower()
labelLeftSlow.Text = "sPPT (CPU 2 min boost)";
labelLeftFast.Text = "fPPT (CPU 2 sec boost)";
panelFast.Visible = modeC1;

}
else
{
Expand All @@ -956,7 +968,7 @@ public void InitPower()

if (limit_cpu > AsusACPI.MaxCPU) limit_cpu = AsusACPI.MaxCPU;
if (limit_cpu < AsusACPI.MinCPU) limit_cpu = AsusACPI.MinCPU;

if (limit_slow > AsusACPI.MaxTotal) limit_slow = AsusACPI.MaxTotal;
if (limit_slow < AsusACPI.MinTotal) limit_slow = AsusACPI.MinTotal;

Expand Down Expand Up @@ -1157,13 +1169,13 @@ private void ButtonReset_Click(object? sender, EventArgs e)
trackGPUClockLimit.Value = NvidiaGpuControl.MaxClockLimit;
trackGPUCore.Value = 0;
trackGPUMemory.Value = 0;

trackGPUBoost.Value = AsusACPI.MaxGPUBoost;
trackGPUTemp.Value = AsusACPI.MaxGPUTemp;

//AppConfig.SetMode("gpu_boost", trackGPUBoost.Value);
//AppConfig.SetMode("gpu_temp", trackGPUTemp.Value);

AppConfig.RemoveMode("gpu_boost");
AppConfig.RemoveMode("gpu_temp");

Expand Down Expand Up @@ -1370,6 +1382,13 @@ private void AdjustAllLevels(int index, double curXVal, double curYVal, Series s
}
}

private void SliderEPP_Scroll(object? sender, EventArgs e)
{
AppConfig.SetMode("epp_value", sliderEPP.Value);
labelEPPSliderRight.Text = $"{sliderEPP.Value}%";
AppConfig.SetEPP(sliderEPP.Value);
}

}

}
43 changes: 42 additions & 1 deletion app/Mode/PowerNative.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Runtime.InteropServices;

namespace GHelper.Mode
{
Expand Down Expand Up @@ -57,6 +58,10 @@ static extern UInt32 PowerSetActiveScheme(IntPtr RootPowerKey,
static readonly Guid GUID_CPU = new Guid("54533251-82be-4824-96c1-47b60b740d00");
static readonly Guid GUID_BOOST = new Guid("be337238-0d82-4146-a960-4f3749d470c7");

static readonly Guid GUID_SUB_PROCESSOR = new Guid("54533251-82be-4824-96c1-47b60b740d00");
static readonly Guid GUID_PERFEPP = new Guid("36687f9e-e3a5-4dbf-b1dc-15eb381c6863");
static readonly Guid GUID_PERFEPP1 = new Guid("36687f9e-e3a5-4dbf-b1dc-15eb381c6864");

private static Guid GUID_SLEEP_SUBGROUP = new Guid("238c9fa8-0aad-41ed-83f4-97be242c8f20");
private static Guid GUID_HIBERNATEIDLE = new Guid("9d7815a6-7ee4-497e-8888-515a05f02364");

Expand Down Expand Up @@ -141,6 +146,42 @@ public static void SetCPUBoost(int boost = 0)
Logger.WriteLine("Boost " + boost);
}

public static int GetEPP()
{
IntPtr AcValueIndex;
Guid activeSchemeGuid = GetActiveScheme();
Guid subGroupOfPowerSettingsGuid = GUID_SUB_PROCESSOR;
Guid perfEPPGuid = GUID_PERFEPP;

UInt32 value = PowerReadACValueIndex(IntPtr.Zero,
activeSchemeGuid,
subGroupOfPowerSettingsGuid,
perfEPPGuid,
out AcValueIndex);

Logger.WriteLine("EPP: " + AcValueIndex.ToInt32());
return AcValueIndex.ToInt32();
}

public static void SetEPP(int value)
{
Guid activeSchemeGuid = GetActiveScheme();
Guid subGroupOfPowerSettingsGuid = GUID_SUB_PROCESSOR;
Guid PerfEPPGuid = GUID_PERFEPP;
Guid PerfEPP1Guid = GUID_PERFEPP1;

PowerWriteACValueIndex(IntPtr.Zero, activeSchemeGuid, subGroupOfPowerSettingsGuid, PerfEPPGuid, value);
PowerWriteACValueIndex(IntPtr.Zero, activeSchemeGuid, subGroupOfPowerSettingsGuid, PerfEPP1Guid, value);

PowerWriteDCValueIndex(IntPtr.Zero, activeSchemeGuid, subGroupOfPowerSettingsGuid, PerfEPPGuid, value);
PowerWriteDCValueIndex(IntPtr.Zero, activeSchemeGuid, subGroupOfPowerSettingsGuid, PerfEPP1Guid, value);

// Apply the active power scheme
PowerSetActiveScheme(IntPtr.Zero, activeSchemeGuid);

Logger.WriteLine("EPP set to " + value);
}

public static string GetPowerMode()
{
if (GetActiveScheme().ToString() == PLAN_HIGH_PERFORMANCE) return PLAN_HIGH_PERFORMANCE;
Expand Down

0 comments on commit ebdb0e7

Please sign in to comment.