Rate guessing code

Richard Hughes hughsient at gmail.com
Wed Nov 2 11:46:25 PST 2005


On Wed, 2005-11-02 at 20:33 +0100, Søren Hansen wrote:
> ons, 02 11 2005 kl. 19:25 +0000, skrev Richard Hughes: 
> > > I've discussed this a bit with DannyK on IRC today. Please take a peek
> > > at it and comment.
> > What does it do, and how does it work? Thanks.
> 
> Oh, right. :-)
> 
> Some laptops don't provide the rate information, but that's not reason
> for HAL not to provide it. That's what this change does. The first time
> around it stores the chargeLevel. On each subsequent run it uses the
> chargeLevel from the previous run to determine the rate at which it
> drops (during discharge) or rises (during charge).. That info is passed
> on to the time calculation code and voila!

Clever, I like it.

> It stores the info about each battery in a hashmap with the udi as key,
> so it also supports multiple batteries.

Cool. You might want to add a multi-line comment in the code to explain
to mere mortals what you're doing.

Something like this (taken from your email)

/* 
 * Some laptops don't provide the rate information, but that's no
 * reason for HAL not to provide it. The first time around it stores
 * the chargeLevel. On each subsequent run it uses the
 * chargeLevel from the previous run to determine the rate at which it
 * drops (during discharge) or rises (during charge).
 */

would explain very clearly to somebody what you are doing with a
hashtable and time. :-)

Other than that the patch looks good. I'll give it a try (i will nobble
my rate reporting..) sometime tonight.

Richard.




More information about the hal mailing list