aboutsummaryrefslogtreecommitdiffstats
path: root/BatteryMeter.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2020-12-07 10:26:01 +0100
committerDaniel Lange <DLange@git.local>2020-12-07 10:26:01 +0100
commit65357c8c46154de4e4eca14075bfe5523bb5fc14 (patch)
tree8f430ee5a0d5de377c4e7c94e47842a27c70d7e8 /BatteryMeter.c
parentf80394a20254938142011855f2954b3f63fe5909 (diff)
downloaddebian_htop-65357c8c46154de4e4eca14075bfe5523bb5fc14.tar.gz
debian_htop-65357c8c46154de4e4eca14075bfe5523bb5fc14.tar.bz2
debian_htop-65357c8c46154de4e4eca14075bfe5523bb5fc14.zip
New upstream version 3.0.3upstream/3.0.3
Diffstat (limited to 'BatteryMeter.c')
-rw-r--r--BatteryMeter.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/BatteryMeter.c b/BatteryMeter.c
index 859df9d..4836809 100644
--- a/BatteryMeter.c
+++ b/BatteryMeter.c
@@ -1,7 +1,7 @@
/*
htop - BatteryMeter.c
(C) 2004-2011 Hisham H. Muhammad
-Released under the GNU GPL, see the COPYING file
+Released under the GNU GPLv2, see the COPYING file
in the source distribution for its full text.
This meter written by Ian P. Hands (iphands@gmail.com, ihands@redhat.com).
@@ -9,29 +9,27 @@ This meter written by Ian P. Hands (iphands@gmail.com, ihands@redhat.com).
#include "BatteryMeter.h"
-#include "Battery.h"
-#include "ProcessList.h"
+#include <math.h>
+
#include "CRT.h"
-#include "StringUtils.h"
+#include "Object.h"
#include "Platform.h"
-
-#include <string.h>
-#include <stdlib.h>
+#include "XUtils.h"
-int BatteryMeter_attributes[] = {
+static const int BatteryMeter_attributes[] = {
BATTERY
};
-static void BatteryMeter_updateValues(Meter * this, char *buffer, int len) {
+static void BatteryMeter_updateValues(Meter* this, char* buffer, size_t len) {
ACPresence isOnAC;
double percent;
- Battery_getData(&percent, &isOnAC);
+ Platform_getBattery(&percent, &isOnAC);
- if (percent == -1) {
- this->values[0] = 0;
- xSnprintf(buffer, len, "n/a");
+ if (isnan(percent)) {
+ this->values[0] = NAN;
+ xSnprintf(buffer, len, "N/A");
return;
}
@@ -55,11 +53,9 @@ static void BatteryMeter_updateValues(Meter * this, char *buffer, int len) {
} else {
xSnprintf(buffer, len, unknownText, percent);
}
-
- return;
}
-MeterClass BatteryMeter_class = {
+const MeterClass BatteryMeter_class = {
.super = {
.extends = Class(Meter),
.delete = Meter_delete

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