mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Battery Discharge reader
This commit is contained in:
@@ -58,6 +58,8 @@ public class AsusACPI
|
|||||||
public const uint GPU_Fan = 0x00110014;
|
public const uint GPU_Fan = 0x00110014;
|
||||||
public const uint Mid_Fan = 0x00110031;
|
public const uint Mid_Fan = 0x00110031;
|
||||||
|
|
||||||
|
public const uint BatteryDischarge = 0x0012005A;
|
||||||
|
|
||||||
public const uint PerformanceMode = 0x00120075; // Performance modes
|
public const uint PerformanceMode = 0x00120075; // Performance modes
|
||||||
public const uint VivoBookMode = 0x00110019; // Vivobook performance modes
|
public const uint VivoBookMode = 0x00110019; // Vivobook performance modes
|
||||||
|
|
||||||
@@ -372,6 +374,23 @@ public class AsusACPI
|
|||||||
return CallMethod(DSTS, args);
|
return CallMethod(DSTS, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public decimal? GetBatteryDischarge()
|
||||||
|
{
|
||||||
|
var buffer = DeviceGetBuffer(BatteryDischarge);
|
||||||
|
|
||||||
|
if (buffer[2] > 0)
|
||||||
|
{
|
||||||
|
buffer[2] = 0;
|
||||||
|
return (decimal)BitConverter.ToInt16(buffer, 0) / 100;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
public int SetGPUEco(int eco)
|
public int SetGPUEco(int eco)
|
||||||
{
|
{
|
||||||
int ecoFlag = DeviceGet(GPUEco);
|
int ecoFlag = DeviceGet(GPUEco);
|
||||||
@@ -412,6 +431,7 @@ public class AsusACPI
|
|||||||
return fan;
|
return fan;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int SetFanRange(AsusFan device, byte[] curve)
|
public int SetFanRange(AsusFan device, byte[] curve)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -180,10 +180,10 @@ public class NvidiaGpuControl : IGpuControl
|
|||||||
if (core < MinCoreOffset || core > MaxCoreOffset) return 0;
|
if (core < MinCoreOffset || core > MaxCoreOffset) return 0;
|
||||||
if (memory < MinMemoryOffset || memory > MaxMemoryOffset) return 0;
|
if (memory < MinMemoryOffset || memory > MaxMemoryOffset) return 0;
|
||||||
|
|
||||||
if (GetClocks(out int currentCore, out int currentMemory))
|
GetClocks(out int currentCore, out int currentMemory);
|
||||||
{
|
|
||||||
if (Math.Abs(core - currentCore) < 5 && Math.Abs(memory - currentMemory) < 5) return 0;
|
// Nothing to set
|
||||||
}
|
if (Math.Abs(core - currentCore) < 5 && Math.Abs(memory - currentMemory) < 5) return 0;
|
||||||
|
|
||||||
PhysicalGPU internalGpu = _internalGpu!;
|
PhysicalGPU internalGpu = _internalGpu!;
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
using GHelper;
|
using GHelper;
|
||||||
|
using GHelper.Battery;
|
||||||
using GHelper.Fan;
|
using GHelper.Fan;
|
||||||
using GHelper.Gpu;
|
using GHelper.Gpu;
|
||||||
using GHelper.Gpu.NVidia;
|
|
||||||
using GHelper.Gpu.AMD;
|
using GHelper.Gpu.AMD;
|
||||||
|
using GHelper.Gpu.NVidia;
|
||||||
using GHelper.Helpers;
|
using GHelper.Helpers;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Management;
|
using System.Management;
|
||||||
using GHelper.Battery;
|
|
||||||
|
|
||||||
public static class HardwareControl
|
public static class HardwareControl
|
||||||
{
|
{
|
||||||
@@ -68,9 +67,16 @@ public static class HardwareControl
|
|||||||
|
|
||||||
chargeCapacity = Convert.ToDecimal(obj["RemainingCapacity"]);
|
chargeCapacity = Convert.ToDecimal(obj["RemainingCapacity"]);
|
||||||
|
|
||||||
|
decimal? discharge = Program.acpi.GetBatteryDischarge();
|
||||||
|
if (discharge is not null)
|
||||||
|
{
|
||||||
|
batteryRate = discharge;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
decimal chargeRate = Convert.ToDecimal(obj["ChargeRate"]);
|
decimal chargeRate = Convert.ToDecimal(obj["ChargeRate"]);
|
||||||
decimal dischargeRate = Convert.ToDecimal(obj["DischargeRate"]);
|
decimal dischargeRate = Convert.ToDecimal(obj["DischargeRate"]);
|
||||||
|
|
||||||
if (chargeRate > 0)
|
if (chargeRate > 0)
|
||||||
batteryRate = chargeRate / 1000;
|
batteryRate = chargeRate / 1000;
|
||||||
else
|
else
|
||||||
@@ -155,7 +161,8 @@ public static class HardwareControl
|
|||||||
return health;
|
return health;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float? GetCPUTemp() {
|
public static float? GetCPUTemp()
|
||||||
|
{
|
||||||
|
|
||||||
var last = DateTimeOffset.Now.ToUnixTimeSeconds();
|
var last = DateTimeOffset.Now.ToUnixTimeSeconds();
|
||||||
if (Math.Abs(last - lastUpdate) < 2) return cpuTemp;
|
if (Math.Abs(last - lastUpdate) < 2) return cpuTemp;
|
||||||
@@ -255,7 +262,7 @@ public static class HardwareControl
|
|||||||
GpuControl?.Dispose();
|
GpuControl?.Dispose();
|
||||||
|
|
||||||
IGpuControl _gpuControl = new NvidiaGpuControl();
|
IGpuControl _gpuControl = new NvidiaGpuControl();
|
||||||
|
|
||||||
if (_gpuControl.IsValid)
|
if (_gpuControl.IsValid)
|
||||||
{
|
{
|
||||||
GpuControl = _gpuControl;
|
GpuControl = _gpuControl;
|
||||||
|
|||||||
Reference in New Issue
Block a user