Battery Discharge reader

This commit is contained in:
Serge
2024-01-18 15:08:13 +01:00
parent 6479079212
commit dedb2123f0
3 changed files with 37 additions and 10 deletions

View File

@@ -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)
{ {

View File

@@ -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);
{
// Nothing to set
if (Math.Abs(core - currentCore) < 5 && Math.Abs(memory - currentMemory) < 5) return 0; if (Math.Abs(core - currentCore) < 5 && Math.Abs(memory - currentMemory) < 5) return 0;
}
PhysicalGPU internalGpu = _internalGpu!; PhysicalGPU internalGpu = _internalGpu!;

View File

@@ -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,6 +67,13 @@ 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"]);
@@ -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;