Skip to content

Commit 6ee7a78

Browse files
committed
Revert "The issue of battery sensor disappearance when switching power modes has been fixed."
This reverts commit 769e117.
1 parent 769e117 commit 6ee7a78

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

OpenHardwareMonitorLib/Hardware/Battery/Battery.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@ public Battery
139139

140140
public float? Voltage => _voltage.Value;
141141

142+
private void ActivateSensorIfValueNotNull(ISensor sensor)
143+
{
144+
if (sensor.Value != null)
145+
ActivateSensor(sensor);
146+
else
147+
DeactivateSensor(sensor);
148+
}
149+
142150
public override void Update()
143151
{
144152
Kernel32.BATTERY_WAIT_STATUS bws = default;
@@ -262,6 +270,15 @@ public override void Update()
262270
{
263271
_cycleCount.Value = null;
264272
}
273+
274+
ActivateSensorIfValueNotNull(_remainingCapacity);
275+
ActivateSensorIfValueNotNull(_chargeLevel);
276+
ActivateSensorIfValueNotNull(_voltage);
277+
ActivateSensorIfValueNotNull(_chargeDischargeCurrent);
278+
ActivateSensorIfValueNotNull(_chargeDischargeRate);
279+
ActivateSensorIfValueNotNull(_remainingTime);
280+
ActivateSensorIfValueNotNull(_temperature);
281+
ActivateSensorIfValueNotNull(_cycleCount);
265282
}
266283

267284
public override void Close()

0 commit comments

Comments
 (0)