Skip to content

Commit

Permalink
Show remaining battery charge in Wh #3246
Browse files Browse the repository at this point in the history
  • Loading branch information
seerge committed Oct 11, 2024
1 parent 3fafe63 commit 9b5e2ac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions app/HardwareControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}

Expand Down
4 changes: 3 additions & 1 deletion app/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 9b5e2ac

Please sign in to comment.