yashsingh1/xdaforums huggingface dataset:
[Nexus One Android Development] dvgrhl:
We have an update ready. This version actually sets the full 40 value from the text field on the Learn Prep tab. You can only set values between 1200-3700mAh right now, we'll evaluate if we need a wider range later on. Also, you get prompted twice for super-user permission right now when you change the full40 value, that has to do with the fact that the value is stored in 2 registers so it's 2 different commands to set the value. I'll work on making it so once you give the app root access, it doesn't prompt you each time after that.

Here is the new version: http://jonrichards.net/xda/BatteryApp20101203.zip. Pending feedback here, we'll probably have 1 or 2 more thread only releases before we shift to the market (free and open source of course). That way everyone can just update automatically from their phones rather than downloading each time from my server.

We still have to write up some good instructions for those who are new to this. They are coming, but we're still in development mode so bear with us a bit while we're (somewhat) on a roll.
[Nexus One Android Development] pukemon:
here's an update from me. my battery came 43% charged. it's been on the charger almost 2 hours now. I WANT MY WIRELESS FREEDOM ALREADY DAMMIT!! :mad:it's only up to 68% right now. so far so good, but the downside, bigger battery takes longer to charge.:D
[Nexus One Android Development] dyussen:
Nexus cyan nightly..

I've tried everything and my phone still will not get to a learn cycle. It powers off at 3680 mv. I tried running gps, bluetooth, nav, music/pandora, nothing seems to take it down to 3416.

I haven't modified any of the registers but set age to full from 94%.

Suggestions?
[Nexus One Android Development] pukemon:
voltage 4162

current 4.556 mah

percent 100

full40 3560

emptyvolt 3.006

capacity 3544

i went and did this than and the other and phone was about 77% and capacity was about 2720 mah. about 10 mins later i come back to the results posted above. i will update with each charge/cycle but that is current status for now. will be interesting to see what happens. and mon-fri is when i get a better standard for long term results. my weekend usage is anywhere from hard to light usage and with a charger on if i want to walk away from where ever i am with a high charge. mon-fri in a downtown metropolis, i fight for signal, qos, and light to heavy hspa data usage. later.

forgot to mention i know i need to cycle 3-5 times to get broke-in. hopefully not broken.
[Nexus One Android Development] myakove:
echo 66 a4 > setreg

Or you can use the new version of the battery app
[Nexus One Android Development] RogerPodacter:
what battery are you using? sounds like you are using an after market battery with an incorrectly programmed full40 value. post your full40 value and we'll see about changing it if that's the problem.
[Nexus One Android Development] RogerPodacter:
thanks and awesome work:D. yeah i'm so busy with changes its hard to actually write up the instructions! anyway i made some more changes to the UI tonight, and i thought it was funny. i added in a few more parameters to the first tab, one of which is AEcurrent. and all this time my AEcurrent has been set to 93mA (i must have set this more than a month ago!). so all this time testing i've been hitting learn mode easily while you guys are struggling with 200mA setting! i changed it back to stock value and will see how it goes...

anyway like dvgrhl said we are getting close to a version 1 release, get it into the market, then take it from there. i added a settings menu tonight as well as other updates, so we'll get it out soon as we can...laters fellas.
[Nexus One Android Development] houzuoguo:
I'm using the latest app with Pershoot's latest kernel. found no issue so far, the apps works very well :D

on "Learn Prep" page this time I'm able to set both age to max and Full40 value, before the release I could only set age to max.

by the way, may I ask a question please :)

I'm using Nexus One OEM battery, what Full40 value would you suggest to use?

Also, recently my phone powers off before learn flag goes on, voltage was at around 3.42v, is this normal?
[Nexus One Android Development] BaGRoS:
Me too Htc Desire stock battery. full40 = 1452 mAh. Power off phone ~3659 mV.

----------------------------------------------------------------

Wysłane z mojego Desire za pomocą TapaTalk,

Pozdrawiam

BaGRoS
[Nexus One Android Development] RogerPodacter:
Awesome the desire works, I assume you're using stock cyanogen ROM or similar? Anyway that's very strange you guys are shutting down at such an early voltage. Set age to 100% and then drain to empty, as its draining take dmesg logs down near the bottom and post them (really should go in the other thread). You likely are running out of mAh capacity, but I'm not sure why so post some logs. We should be able to tweak you guys to get extra capacity out of your battery, and even more by lowering empty volt.
[Nexus One Android Development] chowlala:
I've inserted your method into the OP over at the brainstorm thread. hope ya don't mind. =) good work bro. =))
[Nexus One Android Development] mtw4991:
not a bit, I'll do a proper write-up/instruction if it's still needed???
[Nexus One Android Development] RogerPodacter:
Yeah its actually needed and would even be nice to have some type of instructions placed inside the app which I was gonna work on pretty soon here...
[Nexus One Android Development] mtw4991:
Roger/Chow, I updated the post that Chow quoted with easier to understand instructions/reasons. Here is the updated version:

link:http://xdaforums.com/showpost.php?p=9583271&postcount=340

This is what I do to achieve learn mode and calibrate my battery & it works every time....

1. Use the battery app v.0.8.7 to do the following:

a. set your age to 100% using the battery app under the Learn Prep tab

b. set your full40 to 1452 using the app in the same tab (i.e. stock capacity of OEM battery)

2. Navigate to sys>devices>platform>ds2784-battery>setreg>long press>open in text editor, then:

a. set your aEvolts to 3201 (type 0x66 a4 in setreg & save/exit)

b. set your stop charging current to <20mA (type 0x65 06 in setreg & save/exit)

c. if mAh drops to near empty prior to 3201mV being reached, the app will raise capacity by 200mV so phone doesn't auto-shutdown prior to reaching 3201mV

3. Achieving Learn Mode with the app:

a. NOTE: to hit learn mode you must keep your current mA above -200mA draw! Turn on some apps but make sure the current (mA) is >200mA in Learn Mode tab

b. turn learn mode on in Learn Mode tab

c. wait for mV to drop to <3201mV (learn popup will appear & learnf button will light up)

d. insert charger QUICKLY! (You will see a message saying Learn Mode is active on Learn Mode tab.)

e. turn off and close any open apps.

f. put phone into airplane mode so that you don’t get unexpected current draw near the full point.

g. set setcpu profile to disable overclocking. (set min/max to the same value, ie. 998\998max)

h. charge to full 4hrs.(0x81 will show in battery status register when current drops below <20mA)

i. unplug and reboot, your new age should be set automatically. Learn is now complete and your phone should now charge to 100% and die at 0-1%.

4. Learn Failure:

If your new age shows 94% upon rebooting, then learn mode failed and you need to do it again, paying close attention as charging nears 80% and above. This is where learn mode can be lost by rogue apps, auto-updates, calls, etc pulling the current down below the minimum prematurely.

Note: As current gets close to <50-60mA don't touch the phone or you may artifically increase the current draw pulling it below 20mA and it will end the learn cycle prematurely. Airplane mode helps prevent calls/texts/twitters etc that can show up...happened to me @ 27mA! Also, expect it to take 3.5-4 hours to fully charge and complete the learn cycle. Patience peoples...don’t touch prior to 3.5 hrs minimum!

If I've left anything out guys, please add to it.

Note2: Learn mode cannot be achieve with the phone off. Leave the phone on until learn is complete and the battery status register shows 0x81. Done!

Note3: Some have reported having to manually power down/power up with the new app to have age reset by the application. Currently being looked into.
[Nexus One Android Development] j3di:
If any assistance is needed with the graphical design side of things with the Battery App, maybe we should contact this guy?

http://xdaforums.com/showthread.php?t=856515
[Nexus One Android Development] houzuoguo:
thanks a lot!

gonna do the process step by step now..

Edit:

full40 is now 1452, empty volt is 3.201, chg current is 20.

now i'm at 3.762v, 456mAh left

later i'll try to do a learn cycle, hopefully this time learnflag will active :)
[Nexus One Android Development] dvgrhl:
Thanks, that's exactly the help we need. Roger and I were just lamenting our poor design abilities (you'll see in a bit with the latest beta version), so this will be good if it works out.
[Nexus One Android Development] pukemon:
22 hours later and i'm at 47% juice left. been using my nexus almost heavy since 12pm today. the mugen 3200 mah battery seems to be a beast so far.
[Nexus One Android Development] triciopa:
Please ignore this post
[Nexus One Android Development] RogerPodacter:
yeah dude i think you have a good battery there. what voltage are you at?
[Nexus One Android Development] pukemon:
voltage 3762 right now. mah cap. 1609 and i'm at 45% now.
[Nexus One Android Development] makelegs:
Sooo....lemme see if I'm understanding this correctly.

I set the age to 100% and drained the battery. I hit the learn flag, plugged in, and charged on airplane mode. When it finally turned off learn flag, the status register showed capacity of 1195. I think that means that my age is actually just 82%, even though battery register still says age 100%. I guess the goal is to get the actual capacity as close to 1452 as possible? (in which case I apparently failed)

bummer...?? :(
[Nexus One Android Development] mtw4991:
Just make sure that current is above -200mA and you are looking good! I turn everything on that can use power to stay above that threshold but pandora, torch and hotspot usually do the job
[Nexus One Android Development] dvgrhl:
So I won't get into exactly how I found this out (hint, the last additions to the code I was testing didn't work like I intended!), but I have found that the Nexus One will stay alive all the way down to 2.5 volts or so. It was an interesting ride at least. It even somehow prevented the OS from tying to shut down automatically, just died.
[Nexus One Android Development] mtw4991:
No you didn't fail, you need to reboot for the app to reset the values. Your age is 82 and upon reboot it should set itself. Good job!

When learn completed, did the status register show 0x81?

Edit: guys the overriding goal is to get our batteries to reliably go from 0-100% and back to zero without dying at 10-15%. Extra juice is a bonus!
[Nexus One Android Development] makelegs:
I don't remember if it said 0x81 immediately upon completion, but, as of now, following a reboot, it says 0x83 (whatever that means!? ) ;)

So.....is it "done"??? or is there something left to do? Does resetting to age 100, at this point, make any difference at all???
[Nexus One Android Development] mtw4991:
What does age say in the app? If it's 82% then you are done. If it says 94%, do-ovet
[Nexus One Android Development] makelegs:
Ya...it actually says 83%. Soooo....DISCO, I guess!

Is there a consensus on how often the process, by these means, is suggested?
[Nexus One Android Development] triciopa:
Hey why my phone turns off just the second the learn flag pops on and I plug my charger? I followed the step by step guide and changed the values to the ones on the guide. It's getting quite annoying
[Nexus One Android Development] pukemon:
so if my 3200mah battery from mugen pans out, which is looking good so far, do i need to do any thing with the battery app or just let it ride?
[Nexus One Android Development] mtw4991:
Well, according to roger and login, it can get out of sorts sometimes but now that you know your age, you can manually reset it with the app and be confident that you can make it down to 1% before dying. I recommend trying to let it go to 0% and see far it goes to know for sure, but it's pretty damn close!
[Nexus One Android Development] makelegs:
Love it!

Much obliged
[Nexus One Android Development] theloginwithnoname:
Top post, I have added this as a HOW-TO in the 3rd post of this thread, and linked to your post from the 1st post!
[Nexus One Android Development] theloginwithnoname:
Perhaps worth setting up some HTML files in your github, so that authors of help/guides/HOW-TOs/FAQs etc can fork and send pull requests when they have updated?

If they need to be in a "resource file" (don't know what Android/APK terminology is!), a build script could pull in the various (specified) HTML files during compilation?
[Nexus One Android Development] jlevy73:
Could you also put a link to the battery app in the OP? Thanks.
[Nexus One Android Development] theloginwithnoname:
I just posted this in the other thread:
[Nexus One Android Development] mtw4991:
Thanks for the credit, Login:-)
[Nexus One Android Development] zdiamant:
So I've done everything listed here (thanks to all of you for the hard work), and am able to get into learn mode easily every time... however, while charging (airplane mode on), I get time-outs and am never able to complete the full learn cycle..ie my age goes to 94% everytime. Any ideas?
[Nexus One Android Development] chowlala:
Did you try the fix pointed out in the first OP link?
[Nexus One Android Development] mtw4991:
Got down to <1%@3223mV and 7mAh before shutdown this time...almost perfect!
[Nexus One Android Development] dvgrhl:
I turned on directory listing for this folder on my server: http://jonrichards.net/xda/battery_calibrator/. I just want people to keep in mind that these are still very much beta so patience and feedback are appreciated.

As far as instructions for the app, they should probably go in the README file on github, and then we can take from there and put that in the app. That way they are always in sync. The github repo is here https://github.com/dvgrhl/BatteryCalibrator for those interested.
[Nexus One Android Development] triciopa:
Hown to keep my phone from auto shutting down when the learn flag goes on? I have already changed the values in setreg
[Nexus One Android Development] kalinusa:
So I tried your instructions. I had everything set:

full40: 1452

aEvolts: 3201

mini charging current: 20

temp. cap. value

I had Torch (is this what you mean by flashlight) + Xiia Live playing + basically things were drawing power

I had the Learn Detect ON

And here is where the instructions are merky:

1. Do we turn off all those power drawing apps BEFORE we hit the 3200mV. Because I got down to 3200mV and I had NO pop-up or actually I might have had one but the phone went into SHUT DOWN MODE immediately because I was drawing tons of power and it must have passed by the 3200 really fast. So phone shut down.

2. Also, I recharged my phone never the less, the age got rest to 94%, so my full mAh is 1355, then 1355/1452 = is almost 93=94%, Do I have to chnage my age or am I just lucky?

3. do we have to restore the minimum charging current to 80 after we are done messing around

4. When you say "keep your current above -200mA draw" I can achieve this by simply running 1 little app. I dont have to run heavy duty stuff.

Will try again, without running so many things around 3200mV. Why do we have to run so man things?

Ok will report back.
[Nexus One Android Development] dvgrhl:
Right now the only way to keep it from shutting down when learn mode is detected is to plug in the charger immediately. There is only a small window of time unfortunately to do this or else the phone shuts down.

The ideal situation would be to have the app disable charging when plugged in and then when learn mode is detected, instantly enable charging. This is something Roger and I have discussed in the past, and others have even mentioned it here. Once we get this app to a better place, I think we'll look into it.
[Nexus One Android Development] triciopa:
Lol thanks, will have to tune up my ninja skills and plug it faster :)
[Nexus One Android Development] RogerPodacter:
The time out bug was fixed in the last release from pershoots kernel, so you may have to upgrade. The time out poll was bumped up to 3 hours so it won't stop a learn cycle.
[Nexus One Android Development] jlevy73:
Thanks a lot!
[Nexus One Android Development] dwang:
what about wildmonks kernel, has this bug been fixed there?
[Nexus One Android Development] theloginwithnoname:
would doubt it as its still considered experimental.

simple solution: fastboot a kernel that contains it, on reboot your usual kernel will return.

alternatively, flash kernel for calib, flash preferrred back after!
[Nexus One Android Development] RogerPodacter:
ugh, there are 2 different memory blocks. the first one Block 0 is 256-byte linear memory, where our driver reads/writes all the data from (the values in the code i just posted above). the second memory Block 1 is the EEPROM which overlays with shadow RAM. the read/write functions (what is used in the driver) only access shadow RAM. in order to modify EEPROM data (which is where our full40, age scalar, is located), the copy data and recall data functions much be used.

so my above code might not work. it will work if google's reads ALL the registers when it first grabs battery data. if not, then copy and recall functions will have to be added to the driver code. it can never be easy.

best best is to try that out first to see. if it doesnt work, good luck adding the subsequent code to copy the EEPROM data to shadow RAM. that crap is way over my head.

read page 29 of the data sheet :(

who knows, the palm pre thread seemed easy, so maybe upon power up, all EEPROM data is copied to the shadow RAM, which means the above code should work to at least grab the info. writing it back is another thing...
[Nexus One Android Development] RogerPodacter:
to get the aging capacity, it should be similar. this is the file i'm using by the way:

http://android.git.kernel.org/?p=ke...54cfa3b22c61dd50eae;hb=android-msm-2.6.35-wip

add lines 50-51, 224-229, and 325, 331-332.

48 int current_avg_uA;
49 int charge_uAh;
50 int full40_uAh /*This variable added*/
51 int age_capa /*This variable added*/

221 /* RAAC is in units of 1.6mAh */
222 s->charge_uAh = ((raw[DS2784_REG_RAAC_MSB] << 8) |
223 raw[DS2784_REG_RAAC_LSB]) * 1600;

224 /* full40 has same conversion units of 1.6mAh */
225 s->full40_uAh = ((raw[DS2784_REG_FULL_40_MSB] << 8) |
226 raw[DS2784_REG_FULL_40_LSB]) * 1600;

227 /* Convert to percent*/
228 s->age_capa = ((raw[DS2784_REG_AGE_CAPA_MSB] << 8) |
229 raw[DS2784_REG_AGE_CAPA_LSB]) * 100;

ds2784_parse_data(di->raw, &di->status);
324
325 pr_info("batt: %3d%%, %d mV, %d mA (%d avg), %d.%d C, %d mAh, %d full40 mAh, %3d%% Aged\n",
326 di->status.percentage,
327 di->status.voltage_uV / 1000, di->status.current_uA / 1000,
328 di->status.current_avg_uA / 1000,
329 di->status.temp_C / 10, di->status.temp_C % 10,
330 di->status.charge_uAh / 1000,
331 di->status.full40_uAh / 1000, /*Added to dmesg log*/
332 di->status.age_capa); /*Added to dmesg log*/
333 return 0;
334 }

i'm sure i missed something, like the significant bits might be less than we need to see. but this should get us going hopefully.

ugh i think i used the wrong one. age scalar is in the first block 0. well actually we can use both. age capacity is the rated full capacity of brand new battery. age scalar is the percent our battery has reduced or aged. so i need to edit the above code to remove the percentage calculation.
[Nexus One Android Development] dvgrhl:
I can compile kernels, so no need to try to bother someone else to do this. I can add in those changes to the battery log fairly easily. I'll do that tonight when I get home from work. I might just get my laptop set up to compile too so I can compile changes on the bus or even at work. For this type of testing, I think the zimages will work well since you just reboot to go back to your standard kernel. Sound good?
[Nexus One Android Development] RogerPodacter:
Yeah zimage would be fine. I just wish someone could tell me if that code would work, and I think we need one more value added. Oh well, that should be fine to at least see if it works. Thanks:-)
[Nexus One Android Development] dvgrhl:
I'm looking it over now. Do you care if I leave it as stock Cyanogen kernel as opposed to bringing in pershoot's changes? Just a few less steps that way.
[Nexus One Android Development] RogerPodacter:
That's fine don't even worry about pershoot's changes. We'll just test it for the new functions for now. Feel free to edit it first if I did something wrong.
[Nexus One Android Development] dvgrhl:
OK, I'm compiling now. I'll post a link when it's done. I might have to step out for a few minutes, but it should be up in 20 minutes or so.

edit: and we errored out on ds2784_battery.c. I'll look through the code closer and see what happened. I just slapped it in real fast and compiled.

edit 2: Here it is http://jonrichards.net/kernels/test1.zip
[Nexus One Android Development] uoY_redruM:
I don't have the slightest idea what you guys are doing but I've been following this thread since day 1 very closely lol.
[Nexus One Android Development] RogerPodacter:
I'll try it in a bit when I'm at my computer. What was the compile error if any?

There's no way to use terminal I bet is there... needs fastboot.
[Nexus One Android Development] dvgrhl:
I meant to say that I had a typo in the code when I pasted it in.
[Nexus One Android Development] RogerPodacter:
You didn't happen to remove the percent calculation did you? That shouldn't have been applied to that variable and I never took it out. If not maybe it'll still work just multiplied by factor of 100 lol:-)
[Nexus One Android Development] dvgrhl:
Hah, sorry I didn't really peer review your code like I should have. I was trying to just compile it quickly and get it up for testing out. Your preserving enthusiasm for this topic got to me. :)
[Nexus One Android Development] RogerPodacter:
Yeah battery life is my one and only issue with this phone and it baffles me why the iPhone 4 gets far superior battery life. Something is seriously flawed. Plus I'm bored:-)
[Nexus One Android Development] RogerPodacter:
that kernel hangs my phone on the colored X screen. not sure if its cause of the code, or the zImage.
[Nexus One Android Development] RogerPodacter:
added the last one in for the hell of it. nonamelogin maybe will come back and mess with it.

48 int current_avg_uA;
49 int charge_uAh;
50 int full40_uAh /*This variable added*/
51 int age_capa /*This variable added*/
52 int age_scalar /*This variable added*/
53 int rated_capa /* This variable added*/

221 /* RAAC is in units of 1.6mAh */
222 s->charge_uAh = ((raw[DS2784_REG_RAAC_MSB] << 8) |
223 raw[DS2784_REG_RAAC_LSB]) * 1600;

224 /* No conversion, raw value */
225 s->full40_uAh = ((raw[DS2784_REG_FULL_40_MSB] << 8) |
226 raw[DS2784_REG_FULL_40_LSB]);

227 /* Pull raw value, no conversion*/
228 s->age_capa = ((raw[DS2784_REG_AGE_CAPA_MSB] << 8) |
229 raw[DS2784_REG_AGE_CAPA_LSB]);

230 /* No conversion for now*/
231 s->age_scalar = raw[DS2784_REG_AGE_SCALAR];

232 /* No conversion for now*/
233 s->rated_capa = raw[DS2784_RATED_CAPACITY];

ds2784_parse_data(di->raw, &di->status);
324
325 pr_info("batt: %3d%%, %d mV, %d mA (%d avg), %d.%d C, %d mAh, %d full40 mAh, %d aged capa, %d scalar, %d rated\n",
326 di->status.percentage,
327 di->status.voltage_uV / 1000, di->status.current_uA / 1000,
328 di->status.current_avg_uA / 1000,
329 di->status.temp_C / 10, di->status.temp_C % 10,
330 di->status.charge_uAh / 1000,
331 di->status.full40_uAh / 1000, /*Added to dmesg log*/
332 di->status.age_capa / 1000, /*Added to dmesg log*/
333 di->status.age_scalar, /*Added to dmesg log*/
334 di->status.rated_capa / 1000); /*Added to dmesg log*/
335 return 0;
336 }