aboutsummaryrefslogtreecommitdiffstats
path: root/BatteryMeter.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2024-01-10 11:17:08 +0100
committerDaniel Lange <DLange@git.local>2024-01-10 11:17:08 +0100
commite7372d18a1a661d8c3dba9f51e1f17b5f94171a7 (patch)
treee8270dd60ec096bee8157dbadf029e15ed584592 /BatteryMeter.c
parent937052b231259a47d881d539ad5748245ef55b99 (diff)
downloaddebian_htop-e7372d18a1a661d8c3dba9f51e1f17b5f94171a7.tar.gz
debian_htop-e7372d18a1a661d8c3dba9f51e1f17b5f94171a7.tar.bz2
debian_htop-e7372d18a1a661d8c3dba9f51e1f17b5f94171a7.zip
New upstream version 3.3.0
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