mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c0d84b65b |
@@ -42,6 +42,15 @@ public class ASUSWmi
|
|||||||
public const int GPUModeUltimate = 2;
|
public const int GPUModeUltimate = 2;
|
||||||
|
|
||||||
|
|
||||||
|
public const int MaxTotal = 150;
|
||||||
|
public const int MinTotal = 15;
|
||||||
|
public const int DefaultTotal = 125;
|
||||||
|
|
||||||
|
public const int MaxCPU = 90;
|
||||||
|
public const int MinCPU = 15;
|
||||||
|
public const int DefaultCPU = 80;
|
||||||
|
|
||||||
|
|
||||||
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||||
private static extern IntPtr CreateFile(
|
private static extern IntPtr CreateFile(
|
||||||
string lpFileName,
|
string lpFileName,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
using Starlight.Communication;
|
using Starlight.Communication;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Management;
|
||||||
|
|
||||||
namespace Starlight.AnimeMatrix
|
namespace Starlight.AnimeMatrix
|
||||||
{
|
{
|
||||||
@@ -75,11 +76,32 @@ namespace Starlight.AnimeMatrix
|
|||||||
private byte[] _displayBuffer = new byte[UpdatePageLength * 3];
|
private byte[] _displayBuffer = new byte[UpdatePageLength * 3];
|
||||||
private List<byte[]> frames = new List<byte[]>();
|
private List<byte[]> frames = new List<byte[]>();
|
||||||
|
|
||||||
|
private int pages = 3;
|
||||||
|
|
||||||
private int frameIndex = 0;
|
private int frameIndex = 0;
|
||||||
|
|
||||||
public AnimeMatrixDevice()
|
public AnimeMatrixDevice()
|
||||||
: base(0x0B05, 0x193B, 640)
|
: base(0x0B05, 0x193B, 640)
|
||||||
{
|
{
|
||||||
|
string model = GetModel();
|
||||||
|
Debug.WriteLine(model);
|
||||||
|
if (model is not null && model.Contains("401"))
|
||||||
|
{
|
||||||
|
pages = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public string GetModel()
|
||||||
|
{
|
||||||
|
using (var searcher = new ManagementObjectSearcher(@"Select * from Win32_ComputerSystem"))
|
||||||
|
{
|
||||||
|
foreach (var process in searcher.Get())
|
||||||
|
return process["Model"].ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] GetBuffer()
|
public byte[] GetBuffer()
|
||||||
@@ -183,6 +205,7 @@ namespace Starlight.AnimeMatrix
|
|||||||
|
|
||||||
public void Present()
|
public void Present()
|
||||||
{
|
{
|
||||||
|
|
||||||
Set(Packet<AnimeMatrixPacket>(0xC0, 0x02)
|
Set(Packet<AnimeMatrixPacket>(0xC0, 0x02)
|
||||||
.AppendData(BitConverter.GetBytes((ushort)(UpdatePageLength * 0 + 1)))
|
.AppendData(BitConverter.GetBytes((ushort)(UpdatePageLength * 0 + 1)))
|
||||||
.AppendData(BitConverter.GetBytes((ushort)UpdatePageLength))
|
.AppendData(BitConverter.GetBytes((ushort)UpdatePageLength))
|
||||||
@@ -195,12 +218,13 @@ namespace Starlight.AnimeMatrix
|
|||||||
.AppendData(_displayBuffer[(UpdatePageLength * 1)..(UpdatePageLength * 2)])
|
.AppendData(_displayBuffer[(UpdatePageLength * 1)..(UpdatePageLength * 2)])
|
||||||
);
|
);
|
||||||
|
|
||||||
Set(Packet<AnimeMatrixPacket>(0xC0, 0x02)
|
if (pages > 2)
|
||||||
.AppendData(BitConverter.GetBytes((ushort)(UpdatePageLength * 2 + 1)))
|
Set(Packet<AnimeMatrixPacket>(0xC0, 0x02)
|
||||||
.AppendData(BitConverter.GetBytes((ushort)(LedCount - UpdatePageLength * 2)))
|
.AppendData(BitConverter.GetBytes((ushort)(UpdatePageLength * 2 + 1)))
|
||||||
.AppendData(
|
.AppendData(BitConverter.GetBytes((ushort)(LedCount - UpdatePageLength * 2)))
|
||||||
_displayBuffer[(UpdatePageLength * 2)..(UpdatePageLength * 2 + (LedCount - UpdatePageLength * 2))])
|
.AppendData(
|
||||||
);
|
_displayBuffer[(UpdatePageLength * 2)..(UpdatePageLength * 2 + (LedCount - UpdatePageLength * 2))])
|
||||||
|
);
|
||||||
|
|
||||||
Set(Packet<AnimeMatrixPacket>(0xC0, 0x03));
|
Set(Packet<AnimeMatrixPacket>(0xC0, 0x03));
|
||||||
}
|
}
|
||||||
|
|||||||
28
Fans.cs
28
Fans.cs
@@ -11,14 +11,6 @@ namespace GHelper
|
|||||||
Series seriesCPU;
|
Series seriesCPU;
|
||||||
Series seriesGPU;
|
Series seriesGPU;
|
||||||
|
|
||||||
const int MaxTotal = 150;
|
|
||||||
const int MinTotal = 15;
|
|
||||||
const int DefaultTotal = 125;
|
|
||||||
|
|
||||||
const int MaxCPU = 90;
|
|
||||||
const int MinCPU = 15;
|
|
||||||
const int DefaultCPU = 80;
|
|
||||||
|
|
||||||
void SetChart(Chart chart, int device)
|
void SetChart(Chart chart, int device)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -91,11 +83,11 @@ namespace GHelper
|
|||||||
buttonReset.Click += ButtonReset_Click;
|
buttonReset.Click += ButtonReset_Click;
|
||||||
buttonApply.Click += ButtonApply_Click;
|
buttonApply.Click += ButtonApply_Click;
|
||||||
|
|
||||||
trackTotal.Maximum = MaxTotal;
|
trackTotal.Maximum = ASUSWmi.MaxTotal;
|
||||||
trackTotal.Minimum = MinTotal;
|
trackTotal.Minimum = ASUSWmi.MinTotal;
|
||||||
|
|
||||||
trackCPU.Maximum = MaxCPU;
|
trackCPU.Maximum = ASUSWmi.MaxCPU;
|
||||||
trackCPU.Minimum = MinCPU;
|
trackCPU.Minimum = ASUSWmi.MinCPU;
|
||||||
|
|
||||||
trackCPU.Scroll += TrackCPU_Scroll;
|
trackCPU.Scroll += TrackCPU_Scroll;
|
||||||
trackTotal.Scroll += TrackTotal_Scroll;
|
trackTotal.Scroll += TrackTotal_Scroll;
|
||||||
@@ -167,13 +159,13 @@ namespace GHelper
|
|||||||
ApplyLabel(apply);
|
ApplyLabel(apply);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (limit_total < 0) limit_total = DefaultTotal;
|
if (limit_total < 0) limit_total = ASUSWmi.DefaultTotal;
|
||||||
if (limit_total > MaxTotal) limit_total = MaxTotal;
|
if (limit_total > ASUSWmi.MaxTotal) limit_total = ASUSWmi.MaxTotal;
|
||||||
if (limit_total < MinTotal) limit_total = MinTotal;
|
if (limit_total < ASUSWmi.MinTotal) limit_total = ASUSWmi.MinTotal;
|
||||||
|
|
||||||
if (limit_cpu < 0) limit_cpu = DefaultCPU;
|
if (limit_cpu < 0) limit_cpu = ASUSWmi.DefaultCPU;
|
||||||
if (limit_cpu > MaxCPU) limit_cpu = MaxCPU;
|
if (limit_cpu > ASUSWmi.MaxCPU) limit_cpu = ASUSWmi.MaxCPU;
|
||||||
if (limit_cpu < MinCPU) limit_cpu = MinCPU;
|
if (limit_cpu < ASUSWmi.MinCPU) limit_cpu = ASUSWmi.MinCPU;
|
||||||
if (limit_cpu > limit_total) limit_cpu = limit_total;
|
if (limit_cpu > limit_total) limit_cpu = limit_total;
|
||||||
|
|
||||||
trackTotal.Value = limit_total;
|
trackTotal.Value = limit_total;
|
||||||
|
|||||||
@@ -254,20 +254,27 @@ public class NativeMethods
|
|||||||
deviceNum = 0;
|
deviceNum = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
counter = 0;
|
|
||||||
for (uint id = 0; EnumDisplayDevicesA(null, id, ref d, 0); id++)
|
|
||||||
{
|
|
||||||
if ((d.StateFlags & DisplayDeviceStateFlags.AttachedToDesktop) != 0)
|
|
||||||
{
|
|
||||||
//Debug.WriteLine(d.DeviceID);
|
|
||||||
//Debug.WriteLine(d.DeviceName);
|
|
||||||
if (counter == deviceNum)
|
|
||||||
{
|
|
||||||
laptopScreen = d.DeviceName;
|
|
||||||
}
|
|
||||||
counter++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
counter = 0;
|
||||||
|
for (uint id = 0; EnumDisplayDevicesA(null, id, ref d, 0); id++)
|
||||||
|
{
|
||||||
|
if ((d.StateFlags & DisplayDeviceStateFlags.AttachedToDesktop) != 0)
|
||||||
|
{
|
||||||
|
//Debug.WriteLine(d.DeviceID);
|
||||||
|
//Debug.WriteLine(d.DeviceName);
|
||||||
|
if (counter == deviceNum)
|
||||||
|
{
|
||||||
|
laptopScreen = d.DeviceName;
|
||||||
|
}
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} catch
|
||||||
|
{
|
||||||
|
Debug.WriteLine("Failed to enumerate displays");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mismatch between active screens and enumerated screens, fallback to old method
|
// Mismatch between active screens and enumerated screens, fallback to old method
|
||||||
|
|||||||
@@ -693,6 +693,12 @@ namespace GHelper
|
|||||||
int limit_total = Program.config.getConfigPerf("limit_total");
|
int limit_total = Program.config.getConfigPerf("limit_total");
|
||||||
int limit_cpu = Program.config.getConfigPerf("limit_cpu");
|
int limit_cpu = Program.config.getConfigPerf("limit_cpu");
|
||||||
|
|
||||||
|
if (limit_total > ASUSWmi.MaxTotal) return;
|
||||||
|
if (limit_total < ASUSWmi.MinTotal) return;
|
||||||
|
|
||||||
|
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_TotalA0, limit_total);
|
||||||
Program.wmi.DeviceSet(ASUSWmi.PPT_TotalA1, limit_total);
|
Program.wmi.DeviceSet(ASUSWmi.PPT_TotalA1, limit_total);
|
||||||
Program.wmi.DeviceSet(ASUSWmi.PPT_CPUB0, limit_cpu);
|
Program.wmi.DeviceSet(ASUSWmi.PPT_CPUB0, limit_cpu);
|
||||||
|
|||||||
Reference in New Issue
Block a user