battery: Fix power rate checks for amount < 1W

Fix the power rate check, energy_rate is a float, and abs() handles ints,
so any rate under 1W would have been truncated to 0.
This commit is contained in:
Bastien Nocera 2023-04-15 12:24:18 +02:00
parent 5db1bce65f
commit b773285d5e

View file

@ -155,7 +155,7 @@ up_device_battery_estimate_power (UpDeviceBattery *self, UpBatteryValues *cur)
*/
if (cur->state == UP_DEVICE_STATE_UNKNOWN) {
/* Consider a rate of 0.5W as "no change", otherwise set CHARGING/DISCHARGING */
if (abs(energy_rate) < 0.5)
if (ABS(energy_rate) < 0.5)
return;
else if (energy_rate < 0.0)
cur->state = UP_DEVICE_STATE_DISCHARGING;