[Epic 4G Android Development] nubecoder:
:[Disclaimer]:

Use this at your own risk!

:[Extra Disclaimer]:

This alters the way the Epic charges the battery.

Precaution has been taken to not exceed "normal" values, but when dealing with batteries (and their various sources and quality) there is always a chance something could go horribly wrong.

If you are in any way worried about this, then please move on, as this is not for you.

If you bought an extended battery off ebay and are worried your battery might explode, then please move on, as this is not for you.

This should be considered experimental, and only people who wish to experiment should use it.

There may come a time this will be incorporated into more (all?) kernels, but until then, you have been warned!

:[Requirements]:

Built for and tested on EB13 / EC05 EXT4.

:[Description]:

This is a tweak of the values that are used by the Epic to determine when the battery is at it's fully charged state, and when it should begin it's recharge state.

This is built on Bonsai 3.0.1

It includes the following: tun support, cifs support, 1.2GHz Overclock, autogroup scheduling, keyboard fix (thanks mkasick), video mode fix (thanks again mkasick), etc.

Thank you to all the devs who have contributed and I haven't listed (pm me).

I have also implemented nullghost's Idle timer from 2.6.34 thanks to ACS and nullghost.

[update]

I have also implemented the changes from the EC05 kernel, thanks to Rodderik.

And the scaling_available_frequencies sysfs interface thanks again to nullghost.

[update]

Attached source files for those who want them.

:[Features]:

Alters the "fully charged notification" to be more accurate.

Charges the battery to near full capacity.

Allows for less drain before the "recharge" kicks in.

Gives you a better chance at having a full charge when unplugging.

[update]

Provides over charge protection in the form of a max voltage cut-off.

Increased charge rates (mA) in both USB and AC modes.

There is a chance this change could cause fire or explosion!

Understand this is trial and error!

Even tho I've tested this for the past couple days, there is still a chance you will have a problem where I have not!

Especially if you use a charger other than a stock charger (rated at 0.7A)!

!!Again, you have been warned!!

Adjusted calculations for the fuel gauge (battery level percentage).

I have added a few kernel debug messages that can be seen using dmesg.

"OS Monitor" free in the market will allow you to view them (filter tag = [BATT).

:[What this does not do]:

This does not alter any of the following built in protections:

Max total charge time of 5 hours.

Max total recharge time of 2 hours.

Low battery voltage condition of 3400 (used for auto shutdown).

Low battery level condition of 0 (used for auto shutdown).​

This does not change the charge rate (current coming from the charger).

So no, it wont charge your phone faster (well technically it does, but only during the higher voltages where you would normally be "recharging" on a stock kernel).

:[Recommendations]:

Go download the free app "Battery Monitor Widget". Go into the settings and make sure that "Monitor without widget" is enabled (checked).

The app has a really nice history feature that I find useful, and can be used to help track things with this kernel.

:[Details]:

From the code (original and older values commented out)::

(Some line numbers might be a little off, as I have added some debug messages.)

[Full charge and Recharge adjustments]

Kernel/drivers/power/victory/s5pc110_battery.h: Line 166

#define BATT_RECHARGE_COUNT [COLOR="Blue"]15[/COLOR]//20

Kernel/drivers/power/victory/s5pc110_battery.h: Lines 170 ~ 173

#define OVER_CHARGE_COND_VOLTAGE [COLOR="Blue"]4210[/COLOR]// nubecoder
#define FULL_CHARGE_COND_VOLTAGE [COLOR="Blue"]4190[/COLOR]//4170//4000
#define RECHARGE_COND_VOLTAGE [COLOR="Blue"]4150[/COLOR]//4140//4110 // 2010.05.08.
#define RECHARGE_COND_VOLTAGE_BACKUP [COLOR="Blue"]4090[/COLOR]//4110//4000

Kernel/drivers/power/victory/s5pc110_battery.h: Lines 184 ~ 185

#define CURRENT_OF_FULL_CHG [COLOR="Blue"]60[/COLOR]//90//91	// 2010.05.08.
#define CHG_CURRENT_COUNT	[COLOR="Blue"]15[/COLOR]//20

Which means:

When voltage is greater than or equal to 4190(mV) and current is less than or equal to 60(mA), full charge has been achieved.

When voltage is below 4150(mV) or 4090(mV), recharge activates (what determines if "backup" is used a Samsung mystery).

The current and recharge count values are also somewhat of a mystery, I decreased them to have a bit more consistent charge behavior.

[Over charge protection]

Kernel/drivers/power/victory/s5pc110_battery.c: Lines 438 ~ 444 and 458 ~ 464

if (s3c_bat_info.bat_info.batt_vol >= OVER_CHARGE_COND_VOLTAGE) {
s3c_set_chg_en(0);//Set charge off
s3c_bat_info.bat_info.batt_is_full = 1;
force_update = 1;
}

Which means:

If voltage is greater than or equal to 4210mV stop charging.

[Increased charge rate]

Kernel/drivers/regulator/victory/max9889_function.c: Line 3092

reg_buff[0] = (0x0 <<5) |(0x3 << 3) | /*(0x5<<0)*/ [COLOR="Blue"](0x6<<0)[/COLOR] ; // CHG_TOPOFF_TH=10%, CHG_RST_HYS=Disable, AC_FCGH=600mA // ???mA

Kernel/drivers/regulator/victory/max9889_function.c: Line 3106

reg_buff[0] = (0x0 <<5) |(0x3 << 3) |/*(0x1<<0)*/ [COLOR="Blue"](0x3<<0)[/COLOR] ; // CHG_TOPOFF_TH=10%, CHG_RST_HYS=Disable, AC_FCGH=380mA // ???mA

Based on some rudimentary calculations this translates to:

AC: @320mA which translates to @704mA
USB: @249mA which translates to @548mA

Note:: This was tested with a stock cable and charger for AC, and a stock cable and a direct laptop port for USB.

For more information read this post.

[Adjusted fuel gauge (battery level percentage)]

Kernel/drivers/power/victory/fuel_gauge.c: Line 159

adj_soc = (((data[0]*10) - 15) * 100) / (/*950*/ [COLOR="Blue"]980[/COLOR] - 15);	// hanapark_Atlas

Which means:

Instead of rounding 95% up to 100% round 98% up to 100%.

:[WishList]:

Fixing the battery percentage output to be more accurate. (Partially done, we'll see how it goes.)

Adjusting the values to what I feel is the best charging experience (while still remaining "safe").

Possibly(?) increasing the charge rate to enable faster charging.

:[Testing]:

This has been tested on an Epic 4G running Bonsai 4.0.0b2 with a stock battery.

This build has not been tested on an extended battery (yet).

:[Feedback]:

Please post your feedback, I'd like to know some of the values reported when full charge occurs, when recharge starts / stops, if you've noticed your battery keeps charge longer / less, etc...

[Download HERE]

Download no longer available...

:[Special thanks]:

jaronow, for initial testing.

:[ChangeLog]:

v0.0.2 (03-22-2011)
Attached current source files to this post.

v0.0.2 (03-22-2011)
Added over charge protection cut-off of 4210mV.
Increased full charge voltage to 4190mV.
Increased recharge cond voltage to 4150mV.
Decreased recharge backup cond voltage to 4090mV.
Decreased full charge current condition to 60mA.
Decreased charge current count to 15.
Decreased recharge count to 15
Increased charge rate for AC from an estimated 600mA to @ 704mA.
Increased charge rate for USB from an estimated 380mA to @ 548mA.
Adjusted fuel gauge to be more accurate.

v0.0.1 (03-16-2011)
Initial Release

=]