Active Topics

 


Reply
Thread Tools
Posts: 310 | Thanked: 383 times | Joined on Jan 2010
#1
Hey everyone,

I searched around but haven't found an answer; does anyone how (in code) battery.reporting.design is calculated?

I'm trying to figure out a way to hardcode it to 2400mah for my Mugen battery. I presume HAL calls some binary which reads it from the kernel.
 
Posts: 915 | Thanked: 3,209 times | Joined on Jan 2011 @ Germany
#2
Sorry, I don't know how it works in Maemo, but not long ago I had a look at the code of LXDE's battery monitor. It relies indeed on virtual files provided by the kernel's acpi interface, and I guess that would be the most reasonable approach for any other battery monitor.
Unfortunately these pathes are hard-coded into LXDE's battery-monitor and I think it's the same for other monitors too. So you'd have to change the code and compile the monitor of your choice on your own instead of an easy way like just reassigning some environment variable.

btw: There is a way to export the battery status to the /sys filesystem if you use the power kernel, but I'd have to search for the link.
 
debernardis's Avatar
Posts: 2,142 | Thanked: 2,054 times | Joined on Dec 2006 @ Sicily
#3
Why don't code a battery monitor based on millivolts? Sorry if it is noobish but it's the only way I can estimate the residual charge of my Mugen. Presently, it is constrained between 4180 and 3531 mV (as read by the Batterygraph app). The lesser the voltage, the lower the charge. Or not?
 
Posts: 915 | Thanked: 3,209 times | Joined on Jan 2011 @ Germany
#4
I'm not an expert here, so I might be wrong, but afaik the voltage change is not linear. It stays pretty constant for a long time (70% or 80% of the discharge process?) and then drops relatively fast during the rest of the discharge process. At least this is what I see in my netbook.
Maybe the Mugen battery behaves differently, or maybe this non-linear function can be modeled easily, but it's not as trivial as looking at the charge.

Last edited by sulu; 2011-02-09 at 14:53.
 
debernardis's Avatar
Posts: 2,142 | Thanked: 2,054 times | Joined on Dec 2006 @ Sicily
#5
Well, non-linearity could be a problem if you were to estimate the time left to shutdown, but then that would depend on average use as well, so I think it would be too rough to be useful.
Also my battery graph charts don't have the shape you describe, and contrarily seem to decrease linearly from the very top. So a millivolt-based meter might be feasible to estimate charge level imho.
 
Posts: 701 | Thanked: 585 times | Joined on Sep 2010 @ London, England
#6
Originally Posted by debernardis View Post
Well, non-linearity could be a problem if you were to estimate the time left to shutdown, but then that would depend on average use as well, so I think it would be too rough to be useful.
Also my battery graph charts don't have the shape you describe, and contrarily seem to decrease linearly from the very top. So a millivolt-based meter might be feasible to estimate charge level imho.
The voltage also changes depending on how heavily the device is being used, although I imagine the fluctuation would be less on the Mugen compared to the normal battery. dr_frost_dk made a queen beacon script to convert voltage to a percentage and display it, you can find it in his Battery Mod thread. I took that script modified it to include date and the battery percentage the N900 reports itself and I run it periodically, here is some sample output from yesterday, note at the time of the first reading I was connected via 3G and I wasn't for the second and also I was constantly playing music for almost all of the two hours between the readings
Code:
$ ./batterypercent.sh 
Tue Feb  8 13:06:49 GMT 2011
3.965V - 76.5%
 battery.charge_level.percentage = 94 (0x5e) (int)
~ $ ./batterypercent.sh 
Tue Feb  8 15:05:38 GMT 2011
3.971V - 77.1%
 battery.charge_level.percentage = 77 (0x4d) (int)
So with his script based solely on the voltage my battery gain was 0.6% after two hours music playing, instead of the more realistic 17% decrease. You might still find it useful, but bear in mind that the voltage fluctuates a bit so it won't be terribly accurate.
 

The Following User Says Thank You to retsaw For This Useful Post:
dr_frost_dk's Avatar
Posts: 1,503 | Thanked: 2,688 times | Joined on Oct 2010 @ Denmark
#7
i have made a script based on real discharge graphs

it is based on idle voltage but it works really well

http://talk.maemo.org/showpost.php?p=872446&postcount=3
 
Posts: 310 | Thanked: 383 times | Joined on Jan 2010
#8
Oh hey guys.. Sorry I should have mentioned that the battery meters all work perfectly. This was purely so HAL would report the right capacity in my lshal | grep battery script.

It has no other value whatsoever..
 
Posts: 701 | Thanked: 585 times | Joined on Sep 2010 @ London, England
#9
Originally Posted by dr_frost_dk View Post
i have made a script based on real discharge graphs

it is based on idle voltage but it works really well

http://talk.maemo.org/showpost.php?p=872446&postcount=3
That's the script I mentioned in my previous post. Do you call showing a marginal increase after two hours music playing "working well"? Although it is useful when the battery is running low, the inbuilt reading seems to under-report when the battery is low.
 

The Following User Says Thank You to retsaw For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 10:32.