[PATCH] battery charge indicator jumps
Stanislav Maslovski <[email protected]> Mon, 9 Aug 2010 12:58:21 +0400
| Newsgroups | gmane.comp.window-managers.icewm.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi,
The semantics of /sys/class/power_supply/*/charge_* files in recent
kernels seems to be the following:
1. charge_full_design keeps the design capacity of the battery, in my
laptop it is 5200000.
2. charge_full keeps the actual capacity as was measured by the
electronics in the battery during the last full discharge/charge
cicle. In my case: 3483000 (it is an old battery).
3. charge_now seems to have a more interesting meaning:
a) when the battery is fully charged and the laptop is on mains
charge_now == charge_full_design;
b) when working on battery
charge_now <= charge_full < charge_full_design;
c) when battery is finishing charging charge_now jumps from a value
close to charge_full up to charge_full_design.
With the current aapm.cc code this semantic produces an annoying
effect: when I disconnect the laptop from the mains the charge
indicator soon drops to (3483000/5200000)*100 = 66% and then decreases
further on discharge. If I later connect the mains, the indicator
jumps from 66% to 100% when the battery gets charged [in 1.2.37 it
actually jumped to a value _higher_ than 100% (133% in my case), so it
was even more annoying].
I think that a more reasonable logic is to simply show the percentage
relatively to charge_full, but not to charge_full_design, because that
is what an average user would expect: to see the percentage of his
battery charge relatively to the maximum _available_ charge.
The attached patch extracted from my 1.2.37 tree and ported to
1.3.7pre2 simply does this. Please consider for inclusion.
--
Stanislav
------------------------------------------------------------------------------
This SF.net email is sponsored by
Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev
_______________________________________________
Icewm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/icewm-devel
aapm-full-charge-fix
(text/plain, 1.4 KB)
Index: icewm-1.3.7~pre2/src/aapm.cc
===================================================================
--- icewm-1.3.7~pre2.orig/src/aapm.cc 2010-08-05 23:12:00.000000000 +0400
+++ icewm-1.3.7~pre2/src/aapm.cc 2010-08-05 23:20:16.000000000 +0400
@@ -434,8 +434,6 @@
}
}
fclose(fd);
- if (BATcapacity_remain > BATcapacity_full && BATcapacity_design > 0)
- BATcapacity_full = BATcapacity_design;
}
#else
union acpi_battery_ioctl_arg battio;
@@ -460,6 +458,9 @@
}
acpiBatteries[i]->present = BATpresent;
+ if (BATcapacity_remain > BATcapacity_full)
+ BATcapacity_remain = BATcapacity_full;
+
#ifdef __FreeBSD__
close(acpifd);
#endif
@@ -679,8 +680,6 @@
}
fclose(fd);
}
- if (BATcapacity_remain > BATcapacity_full && BATcapacity_design > 0)
- BATcapacity_full = BATcapacity_design;
acpiBatteries[i]->capacity_full = BATcapacity_full;
}
else {
@@ -689,6 +688,9 @@
}
acpiBatteries[i]->present = BATpresent;
+ if (BATcapacity_remain > BATcapacity_full)
+ BATcapacity_remain = BATcapacity_full;
+
// hatred: for ApmGraph
if (BATpresent == BAT_PRESENT &&
//did we parse the needed values successfully?