From 9b5e2acf90708de44bda58316ac16eda4de8939e Mon Sep 17 00:00:00 2001 From: Serge <5920850+seerge@users.noreply.github.com> Date: Fri, 11 Oct 2024 15:14:36 +0200 Subject: [PATCH] Show remaining battery charge in Wh https://github.com/seerge/g-helper/issues/3246 --- app/HardwareControl.cs | 5 +++-- app/Settings.cs | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/HardwareControl.cs b/app/HardwareControl.cs index f8688ea2f..f0d450b79 100644 --- a/app/HardwareControl.cs +++ b/app/HardwareControl.cs @@ -24,7 +24,7 @@ public static class HardwareControl public static decimal? fullCapacity; public static decimal? chargeCapacity; - + public static string? batteryCharge; public static string? cpuFan; public static string? gpuFan; @@ -226,7 +226,8 @@ public static void ReadSensors() if (fullCapacity > 0 && chargeCapacity > 0) { - batteryCapacity = Math.Min(100, ((decimal)chargeCapacity / (decimal)fullCapacity) * 100); + batteryCapacity = Math.Min(100, (decimal)chargeCapacity / (decimal)fullCapacity * 100); + batteryCharge = Math.Round((decimal)chargeCapacity / 1000, 1).ToString() + "Wh" + " " + Math.Round(batteryCapacity, 1) + "%"; if (batteryCapacity > 99) BatteryControl.UnSetBatteryLimitFull(); } diff --git a/app/Settings.cs b/app/Settings.cs index 4a223711b..229fe5293 100644 --- a/app/Settings.cs +++ b/app/Settings.cs @@ -1420,7 +1420,9 @@ public async void RefreshSensors(bool force = false) cpuTemp = ": " + Math.Round((decimal)HardwareControl.cpuTemp).ToString() + "°C"; if (HardwareControl.batteryCapacity > 0) - charge = Properties.Strings.BatteryCharge + ": " + Math.Round(HardwareControl.batteryCapacity, 1) + "% "; + { + charge = Properties.Strings.BatteryCharge + ": " + HardwareControl.batteryCharge; + } if (HardwareControl.batteryRate < 0) battery = Properties.Strings.Discharging + ": " + Math.Round(-(decimal)HardwareControl.batteryRate, 1).ToString() + "W";