From e7372d18a1a661d8c3dba9f51e1f17b5f94171a7 Mon Sep 17 00:00:00 2001 From: Daniel Lange Date: Wed, 10 Jan 2024 11:17:08 +0100 Subject: New upstream version 3.3.0 --- BatteryMeter.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'BatteryMeter.c') diff --git a/BatteryMeter.c b/BatteryMeter.c index 33d17b7..dad7754 100644 --- a/BatteryMeter.c +++ b/BatteryMeter.c @@ -7,11 +7,14 @@ in the source distribution for its full text. This meter written by Ian P. Hands (iphands@gmail.com, ihands@redhat.com). */ +#include "config.h" // IWYU pragma: keep + #include "BatteryMeter.h" #include #include "CRT.h" +#include "Macros.h" #include "Object.h" #include "Platform.h" #include "XUtils.h" @@ -27,7 +30,7 @@ static void BatteryMeter_updateValues(Meter* this) { Platform_getBattery(&percent, &isOnAC); - if (isnan(percent)) { + if (!isNonnegative(percent)) { this->values[0] = NAN; xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "N/A"); return; @@ -37,16 +40,16 @@ static void BatteryMeter_updateValues(Meter* this) { const char* text; switch (isOnAC) { - case AC_PRESENT: - text = this->mode == TEXT_METERMODE ? " (Running on A/C)" : "(A/C)"; - break; - case AC_ABSENT: - text = this->mode == TEXT_METERMODE ? " (Running on battery)" : "(bat)"; - break; - case AC_ERROR: - default: - text = ""; - break; + case AC_PRESENT: + text = this->mode == TEXT_METERMODE ? " (Running on A/C)" : "(A/C)"; + break; + case AC_ABSENT: + text = this->mode == TEXT_METERMODE ? " (Running on battery)" : "(bat)"; + break; + case AC_ERROR: + default: + text = ""; + break; } xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "%.1f%%%s", percent, text); -- cgit v1.2.3