Index: firmware/powermgmt.c =================================================================== --- firmware/powermgmt.c (revision 24157) +++ firmware/powermgmt.c (working copy) @@ -283,9 +283,9 @@ #endif /* discharging: remaining running time */ if (battery_millivolts > percent_to_volt_discharge[0][0]) { - /* linear extrapolation */ + /* linear extrapolation. -1h to take into account fast drop below 3700 mV */ powermgmt_est_runningtime_min = (level + battery_percent)*60 - * battery_capacity / 200 / runcurrent(); + * battery_capacity / 200 / runcurrent() - 60; } if (0 > powermgmt_est_runningtime_min) { powermgmt_est_runningtime_min = 0; @@ -369,6 +369,8 @@ */ static int runcurrent(void) { +#if 0 + /* AB: old style */ int current; #if MEM == 8 && !(defined(ARCHOS_ONDIOSP) || defined(ARCHOS_ONDIOFM)) @@ -413,6 +415,25 @@ #endif /* BOOTLOADER */ return current; +#else + /* dynamic current estimation */ + static int i32current = CURRENT_NORMAL * 1024; /* initialize with uA */ + int i32mA; + +#ifdef IPOD_VIDEO + /* in uA */ + i32mA = (adc_read(ADC_4066_ISTAT) * 2400) / +#if MEM == 64 + (2); +#else + (3); +#endif /* MEM */ +#endif /* IPOD_VIDEO */ + + i32current = (i32current * 1023 + i32mA) / 1024; + + return (i32current/1024); +#endif }