PPCGeeks

PPCGeeks (http://forum.ppcgeeks.com/index.php)
-   Android On TP2 (http://forum.ppcgeeks.com/forumdisplay.php?f=179)
-   -   Battery Meter and Temp reading "Fix" (workaround) (6/22 Update) (http://forum.ppcgeeks.com/showthread.php?t=121614)

Unknownforce 05-18-2010 04:15 PM

Battery Meter and Temp reading "Fix" (workaround) (6/22 Update)
 
2 Attachment(s)
Just thought I'd share this here...

First and Foremost. This is NOT supported by the Devs... NOR am I a Dev... This is simply a modification of the code that generates the zImage file. (specifically the file htc_battery_smem.c)

Secondly... It's not dead accurate, it's using some of the calculations from the raphael's battery calculations... I have been told by one of the devs that the rhodium calculates battery life much differently, so I will say that this isn't supposed to be a REAL fix, just a temporary workaround.

OK, now that all that is out of the way... here's somewhat of a "fix" for the Battery meter for the SPRINT CDMA TP2 RHODIUM (At least that's all I've tested it on, I have heard that it also works with the Tilt 2 and other "rhodium" devices, but I can't confirm that)

It's the same zImage as all the others with just a single modified source file compiled in. So all you have to do is copy it over the zImage file you currently have and run android like normal.

6/4 UPDATE

As you may have noticed... when you plug your phone in the battery meter jumps WAY up... well I have done a slight modification to the code to have it show something a Little more accurate... (only slight testing done)

Basically what I did was make it check to see if it's charging, if it is, it does less of a calculation based on the mV reading...

It's not perfect, but it's much closer to accurate when charging now, And what I did was make it so that it's a few percent HIGHER than the actual reading, so hopefully (and I don't know for certain) it will think it's at 100% when it's more like 95 ish then it will stop charging the battery and it won't keep charging and possibly do damage... as I said, I've only done some slight testing with this... but I figured I'd post it and get some feedback... My next thing is to figure out how to stabilize the battery meter so that it doesn't fluctuate as much, As an example, the percentage should never go UP when the phone is not charging, and it does... and also when you're actually using the phone for something that's got a drain on the battery, the percentage drops a lot because the mV reading drops when it's under load, So I have to try to figure out how to add in some calculation to incorporate current load so that it doesn't drop dramatically when you're online or something...

But back to the fix at hand here... You'll notice that at first when you plug it in, the % drops a bit, this is because the mV reading does not increase immediately, give it a minute or so and you will notice it start to climb back up as the mV reading increases. The inverse is also the same, in that when you unplug it AFTER charging for a bit, the % will spike for a bit, the mV reading will start to drop and it will stabilize in a minute or so.

6/22 UPDATE

I added a tiny bit of stabilization code. It's not much, and it isn't changing any calculations, so no more "real" accuracy, but just more to stabilize the battery value when it's under different loads. What I did was give it a place to store a "previous" value, then compare it to the "current" value, and if it's more than 1 % different, stick with the previous value, but if it's more than 10% different, use the current value. (This is necessary for bootup and for charging times when it changes so dramatically that the previous value will always be used because it's more than 1% all the time)

This should hopefully stabilize it a little further, but might need to be tweaked a bit, consider this a "BETA" of this code. I'm probably going to incorporate a little more math into this, because this is quite basic right now, but perhaps averaging values and pulling a value using both the previous and current values... But I haven't the time to sit down and really think about this right now...

I have left the 6/17 up just in case it works better.

The next thing I'm going to do is to make it never INCREASE in percentage if the battery isn't charging, this is easy to do, but I am busy right now, and this is all I could come up with for now.

As with the last change, I also made the change apply to all devices (not just the rhodium) but I don't know that it's a problem on other devices, but figured it wouldn't hurt to add it as most people here are using the rhodium anyways...

I will gladly share the code if anyone wants to take a peek.

The zImage includes all zImage updates located here including the ones from 6/14/10

Enjoy!

sjs01 05-18-2010 05:26 PM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
I'm currently testing this right now, but so far it seems to be working! This is the biggest feature that was keeping me from using Android. I'm not sure if it's completely accurate or not, but it's at about the percent it was in Windows Mobile. Normally whenever I would boot into Android the battery meter would go right to red, and about 10% or so. Now it seems to actually be reading right. Again I'm not completely sure. I'm running it on a Sprint HTC Touch Pro 2. I'll try to run Android for the day and see if it's working, but so far so good!

Unknownforce 05-18-2010 06:05 PM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
Well as I said, it's not going to be dead accurate, because I don't know (noone knows for that matter, other than the real devs of the phone software) the correct calculations the rhodium "battery.dll" uses to calculate the exact battery life for windows mobile. I tried doing some reversing on it, but it's just a little over my head, I don't know asm well enough to follow and find the proper calculations, so I just started messing with numbers until it came out about right... and this seems to work.

It's more so that it at least reads "close" to what it should be... but I found it to be pretty damn close. When I talked to the dev, he discouraged my using the raphael calculations, but I figure... it's WAY better than it was before what with starting at like 40% and mostly being at 10% all the time...

mxl180 05-18-2010 06:41 PM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
well..I can say 100% Batt on Windows = 100% Batt on Andriod for me

and after 15 minute use, the battery meeter also drops a bit.... so far so GREAT.

gTen 05-18-2010 07:14 PM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
Wait so if what you say works but only the battery is the issue..can't we use the calculation nue2chem has for nuebattery2 for the TP2?

Reefermattness 05-18-2010 10:05 PM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
Battery workaround works pretty good man!! Nice job. Only problem I see so far is that I lose my WiFi if i use that zimage. GSM Tilt2(Rhod300) :) Battery works VERY close though.

gface2k 05-18-2010 10:53 PM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
Great job! I do have other things to worry about than keeping track of the battery level on my phone 4 my phone.

I can not turn on wifi after using this zimage.

Tested on a Sprint Touch Pro 2


Now if only some one could get sound to work I would totally ditch WinMo.

lioncat55 05-18-2010 11:53 PM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
it works much better than other ones using UScell TP2 i can say that wifi dose not work and that the battery will bounce around 10% but it still works much much better

coolsilver 05-19-2010 12:13 AM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
I'm glad this works at least mostly right.

I have a extended battery for my RHOD500. I wonder if that calculates ok.

The only other thing I worry about is charging still not stopping when at 100% or phone keeps from fully discharging causing power on and as some had on xda boot issues.

hackbenjamin 05-19-2010 07:56 AM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
the battery meter seems to work...do we know why the gps doesnt? how bout gettting this battery "fix" added to the standard package? also how about the fix for the gps from the gps thread? cuz i assume im correct currently we lose these fixes everytime we update?

Unknownforce 05-19-2010 08:59 AM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
This includes every update to the zImage including the one from yesterday, as to why certain things are not working with it, I don't know why that would be because I compile it with the latest update with only that battery modification. Everything on my device works just as it did and the only thing that changes is the battery meter when I change the zImage file...

I suggest trying to re-setup android from scratch.

If it will make a difference, I can post the modules file that compile with it as well, but it doesn't use the modules if you simply update the zImage file, if you watch the text when it boots it ignores that file because it's "already installed."

Damionix 05-19-2010 09:41 AM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
Quote:

Originally Posted by Unknownforce (Post 1761479)
This includes every update to the zImage including the one from yesterday, as to why certain things are not working with it, I don't know why that would be because I compile it with the latest update with only that battery modification. Everything on my device works just as it did and the only thing that changes is the battery meter when I change the zImage file...

I suggest trying to re-setup android from scratch.

If it will make a difference, I can post the modules file that compile with it as well, but it doesn't use the modules if you simply update the zImage file, if you watch the text when it boots it ignores that file because it's "already installed."

Thanks a lot. It's not as accurate, but it's definitely a step in the right direction. This is much appreciated. Thanks a Million

gofawkurself 05-20-2010 12:31 PM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
Hey, Wow! great F@$%ing Job! Impressive! works wonderfully one mine. No more low battery warning pop up every 2 minutes. http://webpages.charter.net/yospiff/...ute_smiley.gif

dunebuggydude11 05-20-2010 04:38 PM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
thank you very much for the temporary battery fix. i was hoping something like this would come out! unfortunately, now gps doesn't work for me (freezes android everytime i try to get my location), but having a battery indicator is much more important for me so whatever.

gTen 05-20-2010 04:56 PM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
Quote:

Originally Posted by dunebuggydude11 (Post 1764420)
thank you very much for the temporary battery fix. i was hoping something like this would come out! unfortunately, now gps doesn't work for me (freezes android everytime i try to get my location), but having a battery indicator is much more important for me so whatever.

This may be your problem:

http://sites.google.com/site/android...lockcrashfixed

drynaps 05-21-2010 01:36 PM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
Quote:

Originally Posted by Unknownforce (Post 1760416)
...
It's the same zImage as all the others with just a single modified source file compiled in. So all you have to do is copy it over the zImage file you currently have and run android like normal.

The zImage includes all zImage updates including the one from today ( 5/18/10 )
...

First of all thank you for doing this. I have tested it and it works really well.

I also noticed that there is a new zImage and modules from today (5/21/2010).

Is there any way you could make a new build of your zImage with the battery fix for today's build?

Thank you!

Unknownforce 05-21-2010 02:33 PM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
Done, same link, I moved the previous zImage to the old folder in there, just in case the new ones cause problems.

Tilde88 05-21-2010 06:10 PM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
Quote:

Originally Posted by Unknownforce (Post 1766162)
Done, same link, I moved the previous zImage to the old folder in there, just in case the new ones cause problems.

lmao youre the shit! ive been avoiding my Android OS cuz the new zimage doesnt have the semi-fix... back to the good stuff! thanks:headbang::headbang:

drynaps 05-22-2010 02:11 AM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
Quote:

Originally Posted by Unknownforce (Post 1766162)
Done, same link, I moved the previous zImage to the old folder in there, just in case the new ones cause problems.

Thank you very much.

Have you contacted PHHuson to see if he can include your patch as part of the next commit?

I think everyone would benefit from it even if it isn't perfect yet.

You are the man :headbang:

Reefermattness 05-22-2010 02:48 PM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
Quote:

Originally Posted by drynaps (Post 1767100)
Thank you very much.

Have you contacted PHHuson to see if he can include your patch as part of the next commit?

I think everyone would benefit from it even if it isn't perfect yet.

You are the man :headbang:

He is just waiting for some feedback on it, and then may add it as a temp fix until the real fix is completed. ;) He will also have to track if this workaround breaks the WiFi, or if its just an unlucky coincidence.

sarcigon 05-22-2010 09:14 PM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
Does anyone here know how to get rid of the LED light from being on all the time?
Someone I can't remember posted this code on the startup file: "htc_battery_smem.fake=1"
This turned off the LED light, but it causes the battery meter to always be on charging mode even though it is not plugged in.
Is there a way to turn off the LED indicator without side effects?

CloudStrife7 05-23-2010 01:16 PM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
Battery fix works great on my US Cell Touch Pro 2. WiFi is not working now (it was before I changed to this rootfs), but that's no biggie for me and it seems you're already that might be a side effect. Thanks!

Reefermattness 05-23-2010 01:47 PM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
Quote:

Originally Posted by sarcigon (Post 1768099)
Does anyone here know how to get rid of the LED light from being on all the time?
Someone I can't remember posted this code on the startup file: "htc_battery_smem.fake=1"
This turned off the LED light, but it causes the battery meter to always be on charging mode even though it is not plugged in.
Is there a way to turn off the LED indicator without side effects?

This code does not "turn off the LED".

It makes the phone think that it is constantly charging, which does not allow the phone to sleep deeply. Since the LED, as stated in multiple places, is a debug tool for the sleep mode, it does not turn on, since the phone does not sleep.

sarcigon 05-23-2010 02:35 PM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
Quote:

Originally Posted by Reefermattness (Post 1768958)
This code does not "turn off the LED".

It makes the phone think that it is constantly charging, which does not allow the phone to sleep deeply. Since the LED, as stated in multiple places, is a debug tool for the sleep mode, it does not turn on, since the phone does not sleep.

Thanks Reef, but my question has not been answered, yet.

Reefermattness 05-23-2010 03:03 PM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
Quote:

Originally Posted by sarcigon (Post 1769037)
Thanks Reef, but my question has not been answered, yet.

Not yet, :)

Once they debug sleep completely they will enable it to work as normal. (that's the plan anyways) There is actually a fancy app for android that will allow you to change the way the notification light acts depending on the notification (flickers for phone calls, long blinks, short blinks, diff colors, etc.)

sarcigon 05-28-2010 07:22 PM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
How do i get rid of that annoying debug led??????

badger.packer.fan 05-29-2010 12:04 AM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
Basically you can't turn off the LED as there is no functionality programmed into these Android builds. The LED is only a debug tool.

Quote:

Originally Posted by sarcigon (Post 1779900)
How do i get rid of that annoying debug led??????


sarcigon 05-29-2010 12:20 AM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
Quote:

Originally Posted by badger.packer.fan (Post 1780236)
basically you can't turn off the led as there is no functionality programmed into these android builds. The led is only a debug tool.

shit.

Tilde88 05-31-2010 07:44 PM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
:( no more updates... like the rest of em... oh well... my evo android is 100%

obrienmd 06-01-2010 09:35 AM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
Unknown - looks like it's working, can you update to latest zImage? Do you turn off debug, like the balsat.hopto.org zImages? These non-debug kernels improve speed for me.

Unknownforce 06-01-2010 11:45 PM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
Quote:

Originally Posted by obrienmd (Post 1784812)
Unknown - looks like it's working, can you update to latest zImage? Do you turn off debug, like the balsat.hopto.org zImages? These non-debug kernels improve speed for me.

I haven't changed anything in my builds other than what I specified already, so unless it's disabled by default, then no it's not off. I can look into turning it off, but right now, I don't have the time. I at least updated to the latest zImage for now.

sovereignty03 06-02-2010 02:04 PM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
Quote:

Originally Posted by Unknownforce (Post 1760416)
Just thought I'd share this here...

First and Foremost. This is NOT supported by the Devs... NOR am I a Dev... This is simply a modification of the code that generates the zImage file. (specifically the file htc_battery_smem.c)

Secondly... This has ONLY been tested on MY OWN Sprint Touch Pro 2... I cannot guarantee it will work on ANY other device including other sprint tp2's.. I just know that it works on MY device... so I figured I'd share it...

Thirdly... It's not dead accurate, it's using some of the calculations from the raphael's battery calculations... I have been told by one of the devs that the rhodium calculates battery life much differently, so I will say that this isn't supposed to be a REAL fix, just a temporary workaround.

OK, now that all that is out of the way... here's somewhat of a "fix" for the Battery meter for the SPRINT CDMA TP2 RHODIUM (At least that's all I've tested it on)

It's the same zImage as all the others with just a single modified source file compiled in. So all you have to do is copy it over the zImage file you currently have and run android like normal.

The zImage includes all zImage updates including the one from today ( 5/29/10 )

Here's the link:

http://www.mediafire.com/?sharekey=2...ecd7d091ba63d2

Where does one get the source htc_battery_smem.c for the calculations? Where is it located in the tree while in android? I was curious about the calculations to see where the accuracy problem is. Does it have to do with temperature compensation? That right there would probably be different than the Raphael... I am using the latest stuff from Reefermattness along with your workaround and it is working so far, just not accurate.

Using Tilt2...

EDIT: Just tried a find in Terminal Emulator and didn't get a result

Unknownforce 06-02-2010 03:28 PM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
Quote:

Originally Posted by bhuggins (Post 1787314)
Where does one get the source htc_battery_smem.c for the calculations? Where is it located in the tree while in android? I was curious about the calculations to see where the accuracy problem is. Does it have to do with temperature compensation? That right there would probably be different than the Raphael... I am using the latest stuff from Reefermattness along with your workaround and it is working so far, just not accurate.

Using Tilt2...

EDIT: Just tried a find in Terminal Emulator and didn't get a result

The source is here: http://gitorious.org/linux-on-qualco...battery_smem.c

What I changed is the static int function called htc_rhod_batt_corr here: http://pastie.org/989450

All I really did was use a little common sense, when the topaz fix was released, I looked at the code that was changed, and basically just did a little testing. I set it to think that it was a topaz, which made the battery report 100 all the time, Then I noticed that the mV readings were way off, so I just adjusted the numbers to get it to show that number to be a little closer to accurate, and in doing this, I discovered that the battery level would also show somewhat close to accurate because apparently the current code seems to directly relate the two (battery % and mV readings) As such, when you plug your phone in, the %age jumps WAY up because the mV readings increase dramatically. I've been thinking about writing some kind of stabilization code to lower the % reading based on status of charging and the increase in mV readings to help stabilize the %age number, but it's been so long since I've done any type of these kinds of Mathematics, I have to do much testing in order to get a proper table in which to write some formula to correctly stabilize it...

Something like if charging = 1 and mV = a certain range, than adjust the % reading to xyz.. But this would only be a "workaround" for another workaround. what we really need are the exact calculations from the battery driver itself. I'm slowly learning ARM ASM to accomplish this, but I've been working 2 jobs, so when I get in the "groove" so-to-speak, it gets interrupted and I have to re-start my train of thought from the beginning... it's very frustrating...

sovereignty03 06-02-2010 06:43 PM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
Quote:

Originally Posted by Unknownforce (Post 1787463)
The source is here: http://gitorious.org/linux-on-qualco...battery_smem.c

What I changed is the static int function called htc_rhod_batt_corr here: http://pastie.org/989450

All I really did was use a little common sense, when the topaz fix was released, I looked at the code that was changed, and basically just did a little testing. I set it to think that it was a topaz, which made the battery report 100 all the time, Then I noticed that the mV readings were way off, so I just adjusted the numbers to get it to show that number to be a little closer to accurate, and in doing this, I discovered that the battery level would also show somewhat close to accurate because apparently the current code seems to directly relate the two (battery % and mV readings) As such, when you plug your phone in, the %age jumps WAY up because the mV readings increase dramatically. I've been thinking about writing some kind of stabilization code to lower the % reading based on status of charging and the increase in mV readings to help stabilize the %age number, but it's been so long since I've done any type of these kinds of Mathematics, I have to do much testing in order to get a proper table in which to write some formula to correctly stabilize it...

Something like if charging = 1 and mV = a certain range, than adjust the % reading to xyz.. But this would only be a "workaround" for another workaround. what we really need are the exact calculations from the battery driver itself. I'm slowly learning ARM ASM to accomplish this, but I've been working 2 jobs, so when I get in the "groove" so-to-speak, it gets interrupted and I have to re-start my train of thought from the beginning... it's very frustrating...

Did you do any tweaking in the function "GetBatteryDischargeLevel"? It looks like this is where the accuracy might be corrected...still looking through the code, though

Unknownforce 06-03-2010 12:07 AM

Re: Battery Meter and Temp reading "Fix" (workaround)
 
I changed nothing else other than the function I mentioned.

Unknownforce 06-04-2010 05:43 PM

Re: Battery Meter and Temp reading "Fix" (workaround) (6/4 Update)
 
Updated today with a charging meter reading "fix." Same link, see first post for details and explanation.

sovereignty03 06-04-2010 06:43 PM

Re: Battery Meter and Temp reading "Fix" (workaround) (6/4 Update)
 
Quote:

Originally Posted by Unknownforce (Post 1792353)
Updated today with a charging meter reading "fix." Same link, see first post for details and explanation.

Hey man, I've been looking into the source, but haven't had time to set my system up to compile and test on my phone. If you don't mind, please try this: Look in htc_battery_smem.c for the line that reads "If ( av_index > 1347 )". Try changing that to "If ( av_index > 1500 )". The next line needs to be changed from "av_index = 1347" to "av_index = 1500". Just see what it does. The Raphael has a 1340mAh battery and the Rhodium has a 1500mAh battery. This is only a start as I see there also needs to be some changes in the scaling. When I have a chance, I am going to try to figure out some of the mV values that need to be put into "GetBatteryDischargeLevel". Just for test on the Rhodium, those values can be changed, but it will break the Raphael side. If the values are found to be good, then there needs to be some other stuff done to add the extra batt_vendor...

I'm gonna try your new stuff ASAP...

EDIT: later realized this is not what av_index is for...

sovereignty03 06-04-2010 06:44 PM

Re: Battery Meter and Temp reading "Fix" (workaround) (6/4 Update)
 
Oh, and sorry about the name change. I was bhuggins. I didn't want that showing so I asked the admins to change it to what I usually use, which is sovereignty

dunebuggydude11 06-04-2010 07:45 PM

Re: Battery Meter and Temp reading "Fix" (workaround) (6/4 Update)
 
what is the "1.0" file for? it says it is a "0 File (.0)" is it supposed to be the modules.....file? thx

samjer111 06-05-2010 12:23 AM

Re: Battery Meter and Temp reading "Fix" (workaround) (6/4 Update)
 
Thanks man. Keep up the Great work.


All times are GMT -4. The time now is 09:09 AM.

Powered by vBulletin® ©2000 - 2025, Jelsoft Enterprises Ltd.
©2012 - PPCGeeks.com


Content Relevant URLs by vBSEO 3.6.0