I did some battery testing today...

/proc/driver/battery/sharpsl_main_battery_voltage can be converted to a true voltage by dividing by 51 (the MAX1111 A/D used is 8-bit with a 5V reference). A full battery will be at about 4.2V (214), with the AC attached too it will show max about 4.3V (221).

/proc/apm refuses to give a charge level with AC attached, so you can use sharpsl_main_battery_voltage to give you a vague idea of what point the charging is at without unplugging. I say *vague* because a LiIon cell will only be 70% charged when it first reaches the "full" voltage, and charging will continue at that voltage for the remaining 30%.

Anyway, with AC disconnected, the voltage will go down roughly linearly until about 3.65V (186), at which point there's only 17% runtime remaining; the voltage then plummets to reach 2.8V (143) at 0% runtime remaining. At that point the protection circuit in the battery cuts the power to the Z.

So to get a reasonable percentage value, at least for my battery:

volt = value from /proc/driver/battery/sharpsl_main_battery_voltage

if (volt >= 186)

{ percent = (volt*83 - 14843) / 35 }

else

{ percent = (volt*17 - 2431) / 43 }

I'll have to try this with the BL-08 and third-party batteries I have to see what difference age or capacity makes. I'm hoping it just changes runtime and not the shape of the curve, but without data I'm just wildly guessing at this point...

Edit: AUGH! Had 414 instead of 214, and used it instead of 221 in the original math. Fixed now (and made more integer-math friendly.)