diff options
author | Benny Baumann <BenBE@geshi.org> | 2020-09-07 11:52:42 +0200 |
---|---|---|
committer | cgzones <cgzones@googlemail.com> | 2020-09-24 18:06:36 +0200 |
commit | 47e2cefe02dffe00369e5630eb1e3f54174f20af (patch) | |
tree | f517c3f21b226cda4520ed27686af7130f2d0531 /BatteryMeter.c | |
parent | f80509358954a39234b136466c4c6a77187744e9 (diff) |
Update battery API to use NAN on error
Diffstat (limited to 'BatteryMeter.c')
-rw-r--r-- | BatteryMeter.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/BatteryMeter.c b/BatteryMeter.c index 859df9d7..0ae2834c 100644 --- a/BatteryMeter.c +++ b/BatteryMeter.c @@ -15,6 +15,7 @@ This meter written by Ian P. Hands (iphands@gmail.com, ihands@redhat.com). #include "StringUtils.h" #include "Platform.h" +#include <math.h> #include <string.h> #include <stdlib.h> @@ -29,8 +30,8 @@ static void BatteryMeter_updateValues(Meter * this, char *buffer, int len) { Battery_getData(&percent, &isOnAC); - if (percent == -1) { - this->values[0] = 0; + if (isnan(percent)) { + this->values[0] = NAN; xSnprintf(buffer, len, "n/a"); return; } |