battery_level() would sometimes return wrong value

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1375 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Björn Stenberg 2002-07-17 11:13:56 +00:00
parent ad7de31660
commit 208cb91192

View file

@ -38,14 +38,14 @@ int battery_level(void)
{
int level;
level = adc_read(ADC_UNREG_POWER) - BATTERY_LEVEL_SHUTDOWN;
level = adc_read(ADC_UNREG_POWER);
if(level < 0)
level = 0;
if(level > BATTERY_LEVEL_FULL)
level = BATTERY_LEVEL_FULL;
return (level * 100) / BATTERY_RANGE;
return ((level-BATTERY_LEVEL_SHUTDOWN) * 100) / BATTERY_RANGE;
}
void charger_enable(bool on)