mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Merge branch 'main' of https://github.com/seerge/g-helper
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using CustomControls;
|
||||
using GHelper.Gpu;
|
||||
using Starlight.AnimeMatrix;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
@@ -7,6 +8,7 @@ using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text.Json;
|
||||
using System.Timers;
|
||||
using System.Windows.Forms;
|
||||
using Tools;
|
||||
|
||||
namespace GHelper
|
||||
@@ -140,7 +142,7 @@ namespace GHelper
|
||||
int trim = model.LastIndexOf("_");
|
||||
if (trim > 0) model = model.Substring(0, trim);
|
||||
|
||||
labelModel.Text = model;
|
||||
labelModel.Text = model+(Program.IsUserAdministrator()?".":"");
|
||||
|
||||
TopMost = Program.config.getConfig("topmost") == 1;
|
||||
|
||||
@@ -946,7 +948,7 @@ namespace GHelper
|
||||
SetGPUMode(ASUSWmi.GPUModeEco);
|
||||
}
|
||||
|
||||
public void RefreshSensors(bool force = false)
|
||||
public async void RefreshSensors(bool force = false)
|
||||
{
|
||||
|
||||
if (!force && Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastRefresh) < 2000) return;
|
||||
@@ -1043,11 +1045,14 @@ namespace GHelper
|
||||
|
||||
}
|
||||
|
||||
public void SetGPUPower()
|
||||
public void AutoGPUSettings(bool launchAsAdmin = false)
|
||||
{
|
||||
|
||||
int gpu_boost = Program.config.getConfig("gpu_boost");
|
||||
int gpu_temp = Program.config.getConfig("gpu_temp");
|
||||
int gpu_boost = Program.config.getConfigPerf("gpu_boost");
|
||||
int gpu_temp = Program.config.getConfigPerf("gpu_temp");
|
||||
|
||||
int gpu_core = Program.config.getConfigPerf("gpu_core");
|
||||
int gpu_memory = Program.config.getConfigPerf("gpu_memory");
|
||||
|
||||
if (gpu_boost < ASUSWmi.MinGPUBoost || gpu_boost > ASUSWmi.MaxGPUBoost ) return;
|
||||
if (gpu_temp < ASUSWmi.MinGPUTemp || gpu_temp > ASUSWmi.MaxGPUTemp) return;
|
||||
@@ -1062,6 +1067,23 @@ namespace GHelper
|
||||
Program.wmi.DeviceSet(ASUSWmi.PPT_GPUC2, gpu_temp, "PowerLimit C2");
|
||||
}
|
||||
|
||||
if (gpu_core == -1 && gpu_memory == -1) return;
|
||||
|
||||
if (HardwareControl.GpuControl is not null && HardwareControl.GpuControl.IsNvidia)
|
||||
{
|
||||
using NvidiaGpuControl nvControl = (NvidiaGpuControl)HardwareControl.GpuControl;
|
||||
try
|
||||
{
|
||||
int status = nvControl.SetClocks(gpu_core, gpu_memory);
|
||||
if (launchAsAdmin && status == -1) Program.RunAsAdmin("gpu");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected void LabelFansResult(string text)
|
||||
@@ -1136,14 +1158,12 @@ namespace GHelper
|
||||
timer.Stop();
|
||||
timer.Dispose();
|
||||
SetPower();
|
||||
SetGPUPower();
|
||||
};
|
||||
timer.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
SetPower();
|
||||
SetGPUPower();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1201,8 +1221,10 @@ namespace GHelper
|
||||
}
|
||||
|
||||
AutoFans();
|
||||
AutoGPUSettings();
|
||||
AutoPower(1000);
|
||||
|
||||
|
||||
if (Program.config.getConfigPerfString("scheme") is not null)
|
||||
NativeMethods.SetPowerScheme(Program.config.getConfigPerfString("scheme"));
|
||||
else
|
||||
@@ -1223,6 +1245,7 @@ namespace GHelper
|
||||
fans.InitFans();
|
||||
fans.InitPower();
|
||||
fans.InitBoost();
|
||||
fans.InitGPU();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1425,10 +1448,10 @@ namespace GHelper
|
||||
|
||||
labelGPU.Text = Properties.Strings.GPUMode + ": " + Properties.Strings.GPUChanging + " ...";
|
||||
|
||||
Thread t = new Thread(() =>
|
||||
{
|
||||
Thread.CurrentThread.IsBackground = true;
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
|
||||
if (eco == 1)
|
||||
{
|
||||
string[] tokill = { "EADesktop", "RadeonSoftware" };
|
||||
@@ -1438,18 +1461,18 @@ namespace GHelper
|
||||
|
||||
Program.wmi.SetGPUEco(eco);
|
||||
|
||||
if (eco == 0)
|
||||
HardwareControl.RecreateGpuControlWithDelay();
|
||||
|
||||
await Task.Delay(TimeSpan.FromSeconds(1));
|
||||
Program.settingsForm.BeginInvoke(delegate
|
||||
{
|
||||
Thread.Sleep(500);
|
||||
InitGPUMode();
|
||||
AutoScreen();
|
||||
});
|
||||
|
||||
if (eco == 0)
|
||||
HardwareControl.RecreateGpuControlWithDelay();
|
||||
|
||||
});
|
||||
|
||||
t.Start();
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user