aboutsummaryrefslogtreecommitdiffstats
path: root/BatteryMeter.c
diff options
context:
space:
mode:
Diffstat (limited to 'BatteryMeter.c')
-rw-r--r--BatteryMeter.c25
1 files changed, 14 insertions, 11 deletions
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 <math.h>
#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);

© 2014-2024 Faster IT GmbH | imprint | privacy policy