I haven't begun to look through the code as others have but does anyone find it surprising that they are looking at voltage to determine remaining capacity? The only batteries that I have worked with are in medical devices and I thought all modern electronics use some form of coulomb counting to determine remaining capacity (
http://en.wikipedia.org/wiki/Smart_Battery_System). We were using COTS laptop batteries as an external power source (which supported the SMBus-based system) and it's just odd that as advanced as cell phones are, we're still looking at voltage curves.
Interesting nonetheless...
Voltage is the only true way to measure a battery.. you CAN NOT measure current (amps).. Notice on that wiki article they say "estimate".. the moment does have that feature through the battery calibration.. but for the purpose of these meters it is using direct voltage reading..
Basically it comes down to.. inorder to measure current, the meter has to be installed in series.. which then requires a 0 resistance inorder to be accurate.. 0 resistance is almost impossible.. voltage on the other hand is wired in parallel, thus has to have a resistance close to infinite.. this is simple to accomplish..
Noticed a logic bug in my previous posting...anyone with that flashed may notice the battery meter jump around a bit. Sorry.

The attached file should result in the following measures: (I didn't need to modify the header)
For the sake of learning (so i can learn how to get around the header issue) how did you get the new groups to work without header values?
Edit: Nevermind.. i see how you did it
TBone:
Using microsoft wordpad so can't give line number but check
if (bat_vol > (batt_medium + temp))
/* bat_level = 40; */
/*
bat_level = 60;
else
bat_level = 50;
/* bat_level = 30; */
bat_level = 50;
Looks like you have bat_level = 50; in there twice.. one of those should be removed correct?