Hi,
this should make /proc/apm
a) display the remaining time until the battery is fully charged and
b) when the system is on AC but the battery is not getting charged 0 is
displayed as remaining time.
Please comment/apply,
Soeren
--
"They that can give up essential liberty to obtain a little temporary
safety deserve neither liberty nor safety." Benjamin Franklin
On Sun, 2004-10-10 at 06:11, Soeren Sonnenburg wrote:
> Hi,
>
> this should make /proc/apm
>
> a) display the remaining time until the battery is fully charged and
> b) when the system is on AC but the battery is not getting charged 0 is
> displayed as remaining time.
>
> Please comment/apply,
> Soeren
if (amperage < 0) {
+ /* when less than 100mA are used the machine must be on AC and as it is
+ not charging the battery is only slightly self decharging and thus full be definition */
+ if (amperage < 100) {
There must be something wrong in the above...
+ time_units = (charge * 59) / (amperage * -1);
+ else
+ time_units = (charge * 16440) / (amperage * -60);
Can you make sure also that amperage is never 0 ?
Ben.
On Sun, 2004-10-10 at 10:09 +1000, Benjamin Herrenschmidt wrote:
> On Sun, 2004-10-10 at 06:11, Soeren Sonnenburg wrote:
[...]
> if (amperage < 0) {
> + /* when less than 100mA are used the machine must be on AC and as it is
> + not charging the battery is only slightly self decharging and thus full be definition */
> + if (amperage < 100) {
>
> There must be something wrong in the above...
Yes you are right, I check for amperage < 0 first and then for
amperage < 100. It should of course be amperage < -100 and is meant for
the case where one is on AC, battery was fully charged and which is now
slightly decharging by less than 100mA/min leading to a remaining time
being displayed of more than 700 hours left.
/proc/apm output with that patch (but wrong check amperage < 100):
0.5 1.1 0x00 0x01 0x00 0x01 99% 92276 min
/proc/apm output with new patch:
0.5 1.1 0x00 0x01 0x00 0x01 99% 0 min
This is the /proc/pmu/battery_0 equivalent.
flags : 00000011
charge : 3130
max_charge : 3148
current : -2
voltage : 16629
time rem. : 5634000
Well it is a special case to be dealt with... one could aswell change
the flags from 'high battery' status to 'charging' or return -1 as the
remaining time... However the battery is fully charged but as the system
is on AC it is simply idling messing up the remaining time.
> + time_units = (charge * 59) / (amperage * -1);
> + else
> + time_units = (charge * 16440) / (amperage * -60);
>
> Can you make sure also that amperage is never 0 ?
actually that is dealt with already as there is a check for both
amperage < 0 and for amperage > 0.
Soeren.
--
Sometimes, there's a moment as you're waking, when you become aware of
the real world around you, but you're still dreaming.