5,598,297 Members 47,949 Now Online
XDA Developers Android and Mobile Development Forum

[MOD][KERNEL] Battery Life eXtender (BLX)

Tip us?
 
Ezekeel
Old
(Last edited by Ezekeel; 7th November 2011 at 06:28 PM.)
#1  
Ezekeel's Avatar
Recognized Developer - OP
Thanks Meter 1700
Posts: 715
Join Date: Jun 2011
Default [MOD][KERNEL] Battery Life eXtender (BLX)

Older types of rechargable batteries exhibited a 'memory effect' which made it neccessary to completely charge/discharge the battery when using to prevent degradation of the capacity. Modern Lithium-Ion batteries like in the Nexus S do not show this problem and thus it is not necessary to use the battery in complete (dis)charge cycles. In fact on the contrary, it is commonly accepted that both very low and very high charge states accelerate the degradation of the battery capacity (that is why you should store Li-Ion batteries at around 40% charge).

While a low charge state can be simply avoided by charging the device more often, the battery in the Nexus S by default is charged to around 95% capacity and I could not find any app or tweak to stop the charging at a lower capacity. Thus the only way was to use the manual override and pull the cable which is annoying since one had to monitor the charge state.

So I implemented a simple tweak I called Battery Life eXtender (BLX) which can be used to set a limit for the capacity to which the battery will be charged by passing a value between 0 and 101 to 'charging_limit' in '/sys/class/misc/batterylifeextender' (101 by default).


Changes to the source code: http://www.pastie.org/2516542


BUGFIX:

The battery status is set to 'full' once the user defined charging limit is reached.

Bug fix: http://www.pastie.org/2534319


BUGFIX #2:

The charging limit is set to 96 by default which will mimic the behaviour of the stock kernel. Also, the maximum value accepted by 'charging_limit' is set to 96.

Bug fix: http://www.pastie.org/2560599


BUGFIX #3:

1. Made BLX compatible with the 100% charging 'fix'.
2. If the charging limit is set to the maximum charging limit, charging will not be stopped until the interrupt signal is received from the MAX8998 chip.

Bugfix: http://www.pastie.org/2751140


No further patches will be published here. I have set up a git repo for all my tweaks. Each mod has its own branch to keep the tweaks cleanly separated and one can simply pull the latest patches from the corresponding branch.

https://github.com/Ezekeel/GLaDOS-nexus-s/tree/blx



I do not accept donations and since I reached my 50GB limit of free space on SpiderOak, thanks to all of you kind people who got an account using my referral link, I could not ask for more.
Instead if you really want to donate your hard earned money to someone who deserves and needs it, consider donating to the Free Software Foundation at fsf.org: These guys are at the frontline when it comes to keeping Linux free and fighting these greedy bastards who think they are entitled to collect royalties and other fees from Linux users due to some silly patents - and if Linux falls, Android will be next.
The Following 77 Users Say Thank You to Ezekeel For This Useful Post: [ Click to Expand ]
 
king23adrianc
Old
#2  
Senior Member
Thanks Meter 139
Posts: 614
Join Date: Sep 2010
Location: Toronto

 
DONATE TO ME
Can't wait for Trinity to include this!

Sent from my Nexus S using XDA App
The Following 2 Users Say Thank You to king23adrianc For This Useful Post: [ Click to Expand ]
 
simms22
Old
#3  
simms22's Avatar
Recognized Contributor
Thanks Meter 18005
Posts: 22,606
Join Date: Jun 2009
Location: BROOKLYN!
i charge my ns to 100% all the time, i wish that i could charge it even more. lol!
Google+ Profile
Twitter Simms22
DerKernel For Trinity kernels and more!
 
window7
Old
#4  
window7's Avatar
Senior Member
Thanks Meter 292
Posts: 737
Join Date: Sep 2010
Wow! I am waiting for this for long time!

Sent from my Google Nexus S using XDA Premium App
"Remembers the day when blackberry and apple were just fruit."
 
Ezekeel
Old
#5  
Ezekeel's Avatar
Recognized Developer - OP
Thanks Meter 1700
Posts: 715
Join Date: Jun 2011
Quote:
Originally Posted by simms22 View Post
i charge my ns to 100% all the time, i wish that i could charge it even more. lol!
Yeah, the drawback of course is the shorter battery runtime. If even a fully charged battery still is not enough for you to get over the day, this tweak is not for you. However, I mostly use the Nexus for internet, email and music and for me a fully charged battery last for about 3 days. So in my case when setting the charging limit to let's say 80% that is still plenty of reserves.

Before I wrote this tweak I thought about if it actually makes sense to try and prolong the lifetime of these batteries because they can be easily replaced and are also pretty cheap. However it seemed like a good idea purely from an environmental point of view (even if there is no climate change like Rick PArry totally has convinced me).
The Following 5 Users Say Thank You to Ezekeel For This Useful Post: [ Click to Expand ]
 
simms22
Old
#6  
simms22's Avatar
Recognized Contributor
Thanks Meter 18005
Posts: 22,606
Join Date: Jun 2009
Location: BROOKLYN!
Quote:
Originally Posted by Ezekeel View Post
Yeah, the drawback of course is the shorter battery runtime. If even a fully charged battery still is not enough for you to get over the day, this tweak is not for you. However, I mostly use the Nexus for internet, email and music and for me a fully charged battery last for about 3 days. So in my case when setting the charging limit to let's say 80% that is still plenty of reserves.

Before I wrote this tweak I thought about if it actually makes sense to try and prolong the lifetime of these batteries because they can be easily replaced and are also pretty cheap. However it seemed like a good idea purely from an environmental point of view (even if there is no climate change like Rick PArry totally has convinced me).
i thought about the need to prolong the batterys life too. i thought about how long id be using my phone as a primary device before i get a new one vs the actual life of the battery. i figured id replace the phone before the battery actually died. of course, there is that odd random chance that the battery will die much quicker than expected. my original g1 battery from 2008 is still good, and i abused that phone for a long time. but, there is something else that i didnt think about. there are lots of people in the world that are less fortunate than i am. and they need their devices to last them as long as the devices can because they cant afford getting new ones. and that includes the battery too. they would appreciate something like this. of course, there is that envirenmental thing that you touched upon. less crap destroying our wonderful planet
Google+ Profile
Twitter Simms22
DerKernel For Trinity kernels and more!
 
Borky_16
Old
#7  
Borky_16's Avatar
Recognized Developer
Thanks Meter 116
Posts: 540
Join Date: Jun 2010
Location: Salzburg
Quote:
Originally Posted by Ezekeel View Post
Yeah, the drawback of course is the shorter battery runtime. If even a fully charged battery still is not enough for you to get over the day, this tweak is not for you. However, I mostly use the Nexus for internet, email and music and for me a fully charged battery last for about 3 days. So in my case when setting the charging limit to let's say 80% that is still plenty of reserves.

Before I wrote this tweak I thought about if it actually makes sense to try and prolong the lifetime of these batteries because they can be easily replaced and are also pretty cheap. However it seemed like a good idea purely from an environmental point of view (even if there is no climate change like Rick PArry totally has convinced me).
so it is not for hardcore user? I have to recharge the phone every evening *argh* !

Sent from my Google Nexus S using xda premium
I got medecine for your Droid!




Tantr Development Site - All my projects
 
dario3040
Old
#8  
dario3040's Avatar
Senior Member
Thanks Meter 157
Posts: 1,581
Join Date: Feb 2010
Location: Oslo
Sounds like Simms is waiting for the Nexus Prime?
____________________________________________



Delete System32
 
dinuvali
Old
#9  
Senior Member
Thanks Meter 39
Posts: 233
Join Date: Aug 2011
Quote:
Originally Posted by simms22 View Post
i charge my ns to 100% all the time, i wish that i could charge it even more. lol!
Sry for the noob question, but how do u charge it to 100%?
 
brainmaster
Old
#10  
brainmaster's Avatar
Recognized Developer
Thanks Meter 4422
Posts: 3,873
Join Date: Dec 2006

 
DONATE TO ME
I appreciate your work Ezekeel.

I have one suggestion: Can you make one thread with all your MODs included so that it is not fragmented all over the Android Development forum?

That would be very kind of you.


Buy me a Coffee - here for US and here for EU.

The Following 3 Users Say Thank You to brainmaster For This Useful Post: [ Click to Expand ]
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes