Originally Posted by TechniSol
Since regulated voltage should remain constant, it's probably sufficient to just account for uptime for each power state in a variable and multiply each of those by the respective amperage draw for that operation mode on a per uptime basis and subtract that from the total estimated capacity when first starting the device. Later as the battery was cycled you'd re-evaluate that total estimated capacity and replace it with measured capacity based on the method espoused above.
No wonder these devices are running short of power -- if they have to do the above then 90% of their power usage is calculating battery capacity left. [Just joking -- but still...].