projects
/
sysstatus.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
2375638
)
battery: Fix for coreboot
author
norly
<ny-git@enpas.org>
Thu, 3 Feb 2022 06:29:38 +0000
(07:29 +0100)
committer
norly
<ny-git@enpas.org>
Thu, 3 Feb 2022 06:29:38 +0000
(07:29 +0100)
src/status/battery.c
patch
|
blob
|
history
diff --git
a/src/status/battery.c
b/src/status/battery.c
index 329e5310805051fcdc7c53b7342628379678e75c..5ce9b04dbfb78bbbe31d32dcb4bc415bceb55f65 100644
(file)
--- a/
src/status/battery.c
+++ b/
src/status/battery.c
@@
-25,7
+25,8
@@
void status_battery(GlobalData *g, char *batname)
int chargeNow = 0;
int chargeFull = -1;
int chargePercent = -1;
int chargeNow = 0;
int chargeFull = -1;
int chargePercent = -1;
- int battW = 1;
+ int currentNow = 1;
+ int voltageNow = 0;
float battTime = -1;
float battTime = -1;
@@
-52,22
+53,28
@@
void status_battery(GlobalData *g, char *batname)
/* Get info */
/* Get info */
- strcpy(&batpath[batpathlen], "/
energy
_now");
+ strcpy(&batpath[batpathlen], "/
charge
_now");
stlen = fileRead(stline, sizeof(stline), batpath);
if (stlen > 0) {
chargeNow = atoi(stline);
}
stlen = fileRead(stline, sizeof(stline), batpath);
if (stlen > 0) {
chargeNow = atoi(stline);
}
- strcpy(&batpath[batpathlen], "/
energy
_full");
+ strcpy(&batpath[batpathlen], "/
charge
_full");
stlen = fileRead(stline, sizeof(stline), batpath);
if (stlen > 0) {
chargeFull = atoi(stline);
}
stlen = fileRead(stline, sizeof(stline), batpath);
if (stlen > 0) {
chargeFull = atoi(stline);
}
- strcpy(&batpath[batpathlen], "/
power
_now");
+ strcpy(&batpath[batpathlen], "/
current
_now");
stlen = fileRead(stline, sizeof(stline), batpath);
if (stlen > 0) {
stlen = fileRead(stline, sizeof(stline), batpath);
if (stlen > 0) {
- battW = atoi(stline);
+ currentNow = atoi(stline);
+ }
+
+ strcpy(&batpath[batpathlen], "/voltage_now");
+ stlen = fileRead(stline, sizeof(stline), batpath);
+ if (stlen > 0) {
+ voltageNow = atoi(stline);
}
}
@@
-97,15
+104,15
@@
void status_battery(GlobalData *g, char *batname)
}
}
}
}
- battTime = (float)chargeNow / (float)
battW
;
+ battTime = (float)chargeNow / (float)
currentNow
;
- if (
battW
== 0) {
+ if (
currentNow
== 0) {
// fully charged and not in use
snprintf(text, sizeof(text), "%s: %d%% _ _",
batname, chargePercent);
} else {
snprintf(text, sizeof(text), "%s: %d%% %.1fh %.1fW",
// fully charged and not in use
snprintf(text, sizeof(text), "%s: %d%% _ _",
batname, chargePercent);
} else {
snprintf(text, sizeof(text), "%s: %d%% %.1fh %.1fW",
- batname, chargePercent, battTime, (float)
battW
/ 1000000.0);
+ batname, chargePercent, battTime, (float)
voltageNow * (float)currentNow
/ 1000000.0);
}
line_append_item(g, &s);
}
line_append_item(g, &s);