mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Performance tweaks
This commit is contained in:
@@ -75,8 +75,11 @@ namespace GHelper
|
||||
public static Color Color1 = Color.White;
|
||||
public static Color Color2 = Color.Black;
|
||||
|
||||
static bool isTuf = AppConfig.ContainsModel("Tuf");
|
||||
static bool isStrix = AppConfig.ContainsModel("Strix");
|
||||
|
||||
static System.Timers.Timer timer = new System.Timers.Timer(1000);
|
||||
|
||||
static System.Timers.Timer timer = new System.Timers.Timer(2000);
|
||||
static HidDevice? auraDevice = null;
|
||||
|
||||
static AsusUSB()
|
||||
@@ -141,7 +144,7 @@ namespace GHelper
|
||||
|
||||
public static Dictionary<int, string> GetModes()
|
||||
{
|
||||
if (AppConfig.ContainsModel("TUF"))
|
||||
if (isTuf)
|
||||
{
|
||||
_modes.Remove(3);
|
||||
}
|
||||
@@ -185,7 +188,7 @@ namespace GHelper
|
||||
|
||||
public static bool HasSecondColor()
|
||||
{
|
||||
return (mode == 1 && !AppConfig.ContainsModel("TUF"));
|
||||
return (mode == 1 && !isTuf);
|
||||
}
|
||||
|
||||
public static int Speed
|
||||
@@ -289,8 +292,7 @@ namespace GHelper
|
||||
Task.Run(async () =>
|
||||
{
|
||||
|
||||
if (AppConfig.ContainsModel("TUF"))
|
||||
Program.acpi.TUFKeyboardBrightness(brightness);
|
||||
if (isTuf) Program.acpi.TUFKeyboardBrightness(brightness);
|
||||
|
||||
byte[] msg = { AURA_HID_ID, 0xba, 0xc5, 0xc4, (byte)brightness };
|
||||
byte[] msgBackup = { INPUT_HID_ID, 0xba, 0xc5, 0xc4, (byte)brightness };
|
||||
@@ -390,7 +392,7 @@ namespace GHelper
|
||||
device.CloseDevice();
|
||||
}
|
||||
|
||||
if (AppConfig.ContainsModel("TUF"))
|
||||
if (isTuf)
|
||||
Program.acpi.TUFKeyboardPower(
|
||||
flags.Contains(AuraDev19b6.AwakeKeyb),
|
||||
flags.Contains(AuraDev19b6.BootKeyb),
|
||||
@@ -410,6 +412,7 @@ namespace GHelper
|
||||
device.OpenDevice();
|
||||
if (device.ReadFeatureData(out byte[] data, AURA_HID_ID))
|
||||
{
|
||||
Logger.WriteLine("Aura Device:" + device.DevicePath);
|
||||
auraDevice = device;
|
||||
return;
|
||||
}
|
||||
@@ -422,9 +425,7 @@ namespace GHelper
|
||||
|
||||
public static void ApplyColor(Color color)
|
||||
{
|
||||
Task.Run(async () =>
|
||||
{
|
||||
if (AppConfig.ContainsModel("TUF"))
|
||||
if (isTuf)
|
||||
{
|
||||
Program.acpi.TUFKeyboardRGB(0, color, 0);
|
||||
return;
|
||||
@@ -437,10 +438,10 @@ namespace GHelper
|
||||
int start = 9;
|
||||
|
||||
msg[0] = AURA_HID_ID;
|
||||
msg[1] = 0xBC;
|
||||
msg[1] = 0xbc;
|
||||
msg[2] = 1;
|
||||
msg[3] = 1;
|
||||
msg[4] = 0;
|
||||
msg[4] = isStrix ? (byte)4 : (byte)0;
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
@@ -450,8 +451,7 @@ namespace GHelper
|
||||
}
|
||||
|
||||
//Logger.WriteLine(BitConverter.ToString(msg));
|
||||
auraDevice.WriteFeatureData(msg);
|
||||
});
|
||||
//auraDevice.Write(msg);
|
||||
}
|
||||
|
||||
|
||||
@@ -561,7 +561,7 @@ namespace GHelper
|
||||
|
||||
if (AsusACPI.IsInvalidCurve(curve)) return -1;
|
||||
|
||||
InitXGM();
|
||||
//InitXGM();
|
||||
|
||||
byte[] msg = new byte[19];
|
||||
Array.Copy(new byte[] { 0x5e, 0xd1, 0x01 }, msg, 3);
|
||||
|
||||
@@ -174,22 +174,12 @@ public static class HardwareControl
|
||||
|
||||
public static float? GetCPUTemp() {
|
||||
|
||||
if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastUpdate) < 1000) return cpuTemp;
|
||||
lastUpdate = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||
var last = DateTimeOffset.Now.ToUnixTimeSeconds();
|
||||
if (Math.Abs(last - lastUpdate) < 2) return cpuTemp;
|
||||
lastUpdate = last;
|
||||
|
||||
cpuTemp = Program.acpi.DeviceGet(AsusACPI.Temp_CPU);
|
||||
|
||||
if (cpuTemp < 0) try
|
||||
{
|
||||
using (var ct = new PerformanceCounter("Thermal Zone Information", "Temperature", @"\_TZ.THRM", true))
|
||||
{
|
||||
cpuTemp = ct.NextValue() - 273;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("Failed reading CPU temp :" + ex.Message);
|
||||
}
|
||||
//Debug.WriteLine(cpuTemp);
|
||||
|
||||
return cpuTemp;
|
||||
}
|
||||
|
||||
@@ -139,6 +139,7 @@ namespace GHelper.Peripherals
|
||||
DetectMouse(new ChakramXWired());
|
||||
DetectMouse(new GladiusIII());
|
||||
DetectMouse(new GladiusIIIWired());
|
||||
UpdateSettingsView();
|
||||
}
|
||||
|
||||
public static void DetectMouse(AsusMouse am)
|
||||
|
||||
1
app/Settings.Designer.cs
generated
1
app/Settings.Designer.cs
generated
@@ -1207,6 +1207,7 @@ namespace GHelper
|
||||
panelPeripherals.Padding = new Padding(20, 20, 20, 10);
|
||||
panelPeripherals.Size = new Size(827, 198);
|
||||
panelPeripherals.TabIndex = 4;
|
||||
panelPeripherals.Visible = false;
|
||||
//
|
||||
// tableLayoutPeripherals
|
||||
//
|
||||
|
||||
@@ -236,6 +236,7 @@ namespace GHelper
|
||||
{
|
||||
screenControl.InitScreen();
|
||||
gpuControl.InitXGM();
|
||||
PeripheralsProvider.RefreshBatteryForAllDevices();
|
||||
updateControl.CheckForUpdates();
|
||||
}
|
||||
}
|
||||
@@ -823,14 +824,11 @@ namespace GHelper
|
||||
battery = Properties.Strings.Charging + ": " + Math.Round((decimal)HardwareControl.batteryRate, 1).ToString() + "W";
|
||||
|
||||
|
||||
|
||||
if (HardwareControl.gpuTemp > 0)
|
||||
{
|
||||
gpuTemp = $": {HardwareControl.gpuTemp}°C";
|
||||
}
|
||||
|
||||
PeripheralsProvider.RefreshBatteryForAllDevices();
|
||||
|
||||
Program.settingsForm.BeginInvoke(delegate
|
||||
{
|
||||
labelCPUFan.Text = "CPU" + cpuTemp + " " + HardwareControl.cpuFan;
|
||||
@@ -839,7 +837,6 @@ namespace GHelper
|
||||
labelMidFan.Text = "Mid " + HardwareControl.midFan;
|
||||
|
||||
if (!batteryMouseOver) labelBattery.Text = battery;
|
||||
VisualizePeripherals();
|
||||
});
|
||||
|
||||
string trayTip = "CPU" + cpuTemp + " " + HardwareControl.cpuFan;
|
||||
|
||||
Reference in New Issue
Block a user