projects
/
sysstatus.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ea0de65
)
Clean up battery status, fix wrong time estimate
author
norly
<ny-git@enpas.org>
Tue, 27 Nov 2012 18:38:24 +0000
(18:38 +0000)
committer
norly
<ny-git@enpas.org>
Tue, 27 Nov 2012 18:38:24 +0000
(18:38 +0000)
statuses/battery.c
patch
|
blob
|
history
sysstatus.c
patch
|
blob
|
history
diff --git
a/statuses/battery.c
b/statuses/battery.c
index 96e1ddd6d435aaa6204f14d5525c5714bffd5a60..4c3599922cc7019aff65b2d842da44f3df6f6e88 100644
(file)
--- a/
statuses/battery.c
+++ b/
statuses/battery.c
@@
-17,14
+17,12
@@
void status_battery(char *batname)
char stline[16];
ssize_t stlen;
char stline[16];
ssize_t stlen;
- int batt_now = 0;
- int batt_full = -1;
- int batt_percent = -1;
- int batt_current = 1;
- int batt_power = 1;
- int batt_voltage = 0;
- float batt_time = -1;
- float batt_watts = -1;
+ int chargeNow = 0;
+ int chargeFull = -1;
+ int chargePercent = -1;
+ int battW = 1;
+ int battV = 0;
+ float battTime = -1;
// Prepare path
// Prepare path
@@
-52,33
+50,33
@@
void status_battery(char *batname)
strcpy(&batpath[batpathlen], "/energy_now");
stlen = fileRead(stline, sizeof(stline), batpath);
if (stlen > 0)
strcpy(&batpath[batpathlen], "/energy_now");
stlen = fileRead(stline, sizeof(stline), batpath);
if (stlen > 0)
-
batt_n
ow = atoi(stline);
+
chargeN
ow = atoi(stline);
strcpy(&batpath[batpathlen], "/energy_full");
stlen = fileRead(stline, sizeof(stline), batpath);
if (stlen > 0)
strcpy(&batpath[batpathlen], "/energy_full");
stlen = fileRead(stline, sizeof(stline), batpath);
if (stlen > 0)
-
batt_f
ull = atoi(stline);
+
chargeF
ull = atoi(stline);
strcpy(&batpath[batpathlen], "/power_now");
stlen = fileRead(stline, sizeof(stline), batpath);
if (stlen > 0)
strcpy(&batpath[batpathlen], "/power_now");
stlen = fileRead(stline, sizeof(stline), batpath);
if (stlen > 0)
- batt
_power
= atoi(stline);
+ batt
W
= atoi(stline);
strcpy(&batpath[batpathlen], "/voltage_now");
stlen = fileRead(stline, sizeof(stline), batpath);
if (stlen > 0)
strcpy(&batpath[batpathlen], "/voltage_now");
stlen = fileRead(stline, sizeof(stline), batpath);
if (stlen > 0)
- batt
_voltage
= atoi(stline);
+ batt
V
= atoi(stline);
// Prettyprint
// Prettyprint
- if (
batt_f
ull > 0)
-
batt_percent = batt_now / (batt_f
ull / 100);
+ if (
chargeF
ull > 0)
+
chargePercent = chargeNow / (chargeF
ull / 100);
- if (
batt_p
ercent <= 40) // 40
+ if (
chargeP
ercent <= 40) // 40
{
{
- if (
batt_p
ercent <= 25) // 25
+ if (
chargeP
ercent <= 25) // 25
{
{
- if (
batt_p
ercent <= 10) // 10
+ if (
chargeP
ercent <= 10) // 10
fputs("^fg(red)", stdout);
else // 11-25%
fputs("^fg(orange)", stdout);
fputs("^fg(red)", stdout);
else // 11-25%
fputs("^fg(orange)", stdout);
@@
-88,19
+86,18
@@
void status_battery(char *batname)
}
else
{
}
else
{
- if (
batt_p
ercent > 70) // 70
+ if (
chargeP
ercent > 70) // 70
fputs("^fg(white)", stdout);
else // 41-70%
fputs("^fg(green)", stdout);
}
fputs("^fg(white)", stdout);
else // 41-70%
fputs("^fg(green)", stdout);
}
- batt_current = ((float)batt_power * 100) / ((float)batt_voltage / 100000);
- batt_time = (float)batt_now / (float)batt_current;
- batt_watts = ((float)batt_power / 1000000);
+ battTime = (float)chargeNow / (float)battW;
- if (batt_watts == 0) // fully charged and not in use
- printf(" %s: %d%% _ _ ", batname, batt_percent);
+ if (battW == 0) // fully charged and not in use
+ printf(" %s: %d%% _ _ ",
+ batname, chargePercent);
else
printf(" %s: %d%% %.1fh %.1fW ",
else
printf(" %s: %d%% %.1fh %.1fW ",
- batname,
batt_percent, batt_time, batt_watts
);
+ batname,
chargePercent, battTime, (float)battW / 1000000.0
);
}
}
diff --git
a/sysstatus.c
b/sysstatus.c
index 9433da101a42957cea812ad11b220f2e8e892190..aed988c2fba5c6c91f7a4a33e828b6d66eea0f99 100644
(file)
--- a/
sysstatus.c
+++ b/
sysstatus.c
@@
-28,6
+28,7
@@
void updatestatus()
//status_netif("eth2");
status_netif("wlan0");
//status_netif("wlan1");
//status_netif("eth2");
status_netif("wlan0");
//status_netif("wlan1");
+ status_netif("wlan2");
//status_netif("usb0");
status_netif("ppp0");
//status_netif("usb0");
status_netif("ppp0");