mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
AutoTDP toggle
This commit is contained in:
@@ -42,11 +42,14 @@ namespace GHelper.Ally
|
||||
static ControllerMode _applyMode = ControllerMode.Mouse;
|
||||
|
||||
static int _autoCount = 0;
|
||||
static int _upCount = 0, _downCount = 0;
|
||||
static int _upCount = 0;
|
||||
static int _downCount = 0;
|
||||
|
||||
static int minTDP = 6;
|
||||
static int maxTDP = 25;
|
||||
static int autoTDP = -1;
|
||||
static int tdpMin = 6;
|
||||
static int tdpMax = 25;
|
||||
static int tdpCurrent = -1;
|
||||
|
||||
static bool autoTDP = false;
|
||||
|
||||
static int fpsLimit = -1;
|
||||
|
||||
@@ -291,7 +294,7 @@ namespace GHelper.Ally
|
||||
|
||||
settings = settingsForm;
|
||||
|
||||
timer = new System.Timers.Timer(300);
|
||||
timer = new System.Timers.Timer(200);
|
||||
timer.Elapsed += Timer_Elapsed;
|
||||
|
||||
}
|
||||
@@ -313,31 +316,35 @@ namespace GHelper.Ally
|
||||
|
||||
private int GetTDP()
|
||||
{
|
||||
if (autoTDP < 0) autoTDP = GetMaxTDP();
|
||||
return autoTDP;
|
||||
if (tdpCurrent < 0) tdpCurrent = GetMaxTDP();
|
||||
return tdpCurrent;
|
||||
}
|
||||
|
||||
private void SetTDP(int tdp, string log)
|
||||
{
|
||||
if (tdp < minTDP) tdp = minTDP;
|
||||
if (tdp > maxTDP) tdp = maxTDP;
|
||||
if (tdp < tdpMin) tdp = tdpMin;
|
||||
if (tdp > tdpMax) tdp = tdpMax;
|
||||
|
||||
if (tdp == autoTDP) return;
|
||||
if (tdp == tdpCurrent) return;
|
||||
if (!autoTDP) return;
|
||||
|
||||
Program.acpi.DeviceSet(AsusACPI.PPT_APUA0, tdp, log);
|
||||
Program.acpi.DeviceSet(AsusACPI.PPT_APUA3, tdp, null);
|
||||
Program.acpi.DeviceSet(AsusACPI.PPT_APUC1, tdp, null);
|
||||
autoTDP = tdp;
|
||||
Program.acpi.DeviceSet(AsusACPI.PPT_APUC1, (int)(tdp * 1.2), null);
|
||||
|
||||
tdpCurrent = tdp;
|
||||
}
|
||||
|
||||
private void Timer_Elapsed(object? sender, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
float fps = amdControl.GetFPS();
|
||||
|
||||
if (fpsLimit <= 120)
|
||||
if (autoTDP)
|
||||
{
|
||||
if (fpsLimit < 0 || fpsLimit > 120) fpsLimit = 120;
|
||||
|
||||
if (fps < fpsLimit - 5) _upCount++;
|
||||
if (fps >= fpsLimit) _downCount++;
|
||||
if (fps > fpsLimit - 1) _downCount++;
|
||||
|
||||
if (_upCount > 2)
|
||||
{
|
||||
@@ -346,7 +353,7 @@ namespace GHelper.Ally
|
||||
SetTDP(GetTDP() + 1, $"AutoTDP+ {fps}");
|
||||
}
|
||||
|
||||
if (_downCount > 8)
|
||||
if (_downCount > 10)
|
||||
{
|
||||
SetTDP(GetTDP() - 1, $"AutoTDP- {fps}");
|
||||
_upCount = 0;
|
||||
@@ -361,7 +368,7 @@ namespace GHelper.Ally
|
||||
|
||||
if (_mode != ControllerMode.Auto) return;
|
||||
|
||||
if (_autoCount > 2)
|
||||
if (_autoCount >= 5)
|
||||
{
|
||||
_autoCount = 0;
|
||||
ApplyMode(newMode);
|
||||
@@ -370,6 +377,20 @@ namespace GHelper.Ally
|
||||
|
||||
}
|
||||
|
||||
public void ToggleAutoTDP()
|
||||
{
|
||||
autoTDP = !autoTDP;
|
||||
tdpCurrent = -1;
|
||||
|
||||
if (!autoTDP)
|
||||
{
|
||||
Program.modeControl.SetPerformanceMode();
|
||||
}
|
||||
|
||||
settings.VisualiseAutoTDP(autoTDP);
|
||||
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
if (AppConfig.IsAlly()) settings.VisualiseAlly(true);
|
||||
@@ -382,6 +403,9 @@ namespace GHelper.Ally
|
||||
fpsLimit = amdControl.GetFPSLimit();
|
||||
settings.VisualiseFPSLimit(fpsLimit);
|
||||
|
||||
autoTDP = AppConfig.Is("auto_tdp");
|
||||
settings.VisualiseAutoTDP(autoTDP);
|
||||
|
||||
}
|
||||
|
||||
public void ToggleFPSLimit()
|
||||
|
||||
25
app/Settings.Designer.cs
generated
25
app/Settings.Designer.cs
generated
@@ -134,6 +134,7 @@ namespace GHelper
|
||||
labelGamma = new Label();
|
||||
pictureGamma = new PictureBox();
|
||||
labelGammaTitle = new Label();
|
||||
buttonAutoTDP = new RButton();
|
||||
panelMatrix.SuspendLayout();
|
||||
panelMatrixAuto.SuspendLayout();
|
||||
tableLayoutMatrix.SuspendLayout();
|
||||
@@ -765,6 +766,7 @@ namespace GHelper
|
||||
tableAMD.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33F));
|
||||
tableAMD.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33F));
|
||||
tableAMD.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33F));
|
||||
tableAMD.Controls.Add(buttonAutoTDP, 0, 0);
|
||||
tableAMD.Controls.Add(buttonOverlay, 0, 0);
|
||||
tableAMD.Controls.Add(buttonFPS, 0, 0);
|
||||
tableAMD.Dock = DockStyle.Top;
|
||||
@@ -1870,6 +1872,28 @@ namespace GHelper
|
||||
labelGammaTitle.TabIndex = 37;
|
||||
labelGammaTitle.Text = "Flicker-free Dimming";
|
||||
//
|
||||
// buttonAutoTDP
|
||||
//
|
||||
buttonAutoTDP.Activated = false;
|
||||
buttonAutoTDP.BackColor = SystemColors.ControlLightLight;
|
||||
buttonAutoTDP.BorderColor = Color.Transparent;
|
||||
buttonAutoTDP.BorderRadius = 5;
|
||||
buttonAutoTDP.Dock = DockStyle.Fill;
|
||||
buttonAutoTDP.FlatAppearance.BorderSize = 0;
|
||||
buttonAutoTDP.FlatStyle = FlatStyle.Flat;
|
||||
buttonAutoTDP.ForeColor = SystemColors.ControlText;
|
||||
buttonAutoTDP.Image = Properties.Resources.icons8_gauge_32;
|
||||
buttonAutoTDP.ImageAlign = ContentAlignment.MiddleRight;
|
||||
buttonAutoTDP.Location = new Point(528, 4);
|
||||
buttonAutoTDP.Margin = new Padding(4);
|
||||
buttonAutoTDP.Name = "buttonAutoTDP";
|
||||
buttonAutoTDP.Secondary = false;
|
||||
buttonAutoTDP.Size = new Size(255, 72);
|
||||
buttonAutoTDP.TabIndex = 13;
|
||||
buttonAutoTDP.Text = "AutoTDP";
|
||||
buttonAutoTDP.TextImageRelation = TextImageRelation.ImageBeforeText;
|
||||
buttonAutoTDP.UseVisualStyleBackColor = false;
|
||||
//
|
||||
// SettingsForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(192F, 192F);
|
||||
@@ -2071,5 +2095,6 @@ namespace GHelper
|
||||
private RComboBox comboColorTemp;
|
||||
private RButton buttonInstallColor;
|
||||
private Label labelVisual;
|
||||
private RButton buttonAutoTDP;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,6 +245,9 @@ namespace GHelper
|
||||
|
||||
buttonFPS.Click += ButtonFPS_Click;
|
||||
buttonOverlay.Click += ButtonOverlay_Click;
|
||||
|
||||
buttonAutoTDP.Click += ButtonAutoTDP_Click;
|
||||
buttonAutoTDP.BorderColor = colorTurbo;
|
||||
|
||||
Text = "G-Helper " + (ProcessHelper.IsUserAdministrator() ? "—" : "-") + " " + AppConfig.GetModelShort();
|
||||
TopMost = AppConfig.Is("topmost");
|
||||
@@ -263,6 +266,11 @@ namespace GHelper
|
||||
InitVisual();
|
||||
}
|
||||
|
||||
private void ButtonAutoTDP_Click(object? sender, EventArgs e)
|
||||
{
|
||||
allyControl.ToggleAutoTDP();
|
||||
}
|
||||
|
||||
private void LabelCharge_Click(object? sender, EventArgs e)
|
||||
{
|
||||
BatteryControl.BatteryReport();
|
||||
@@ -487,6 +495,12 @@ namespace GHelper
|
||||
buttonFPS.Text = "FPS Limit " + ((limit > 0 && limit <= 120) ? limit : "OFF");
|
||||
}
|
||||
|
||||
public void VisualiseAutoTDP(bool status)
|
||||
{
|
||||
Logger.WriteLine($"Auto TDP: {status}");
|
||||
buttonAutoTDP.Activated = status;
|
||||
}
|
||||
|
||||
private void SettingsForm_LostFocus(object? sender, EventArgs e)
|
||||
{
|
||||
lastLostFocus = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||
|
||||
Reference in New Issue
Block a user