From 02eb1d83a79c265b0273e18630553efcf8b9196c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20Wallm=C3=A9nius?= Date: Sat, 12 Apr 2008 07:14:13 +0000 Subject: [PATCH] FS#8871 by Tomasz Wasilczyk, avoid negative runtime estimation (that would later be cast to an unsigned giving huge values git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17080 a1c6a512-1295-4272-9138-f99709370657 --- docs/CREDITS | 1 + firmware/powermgmt.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/docs/CREDITS b/docs/CREDITS index 9b4a02abf4..48094834c8 100644 --- a/docs/CREDITS +++ b/docs/CREDITS @@ -386,6 +386,7 @@ Andreas Müller Christopher Williams Martin Ritter Justin Hannigan +Tomasz Wasilczyk The libmad team diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c index 072a31fa3f..69b0704bc2 100644 --- a/firmware/powermgmt.c +++ b/firmware/powermgmt.c @@ -478,6 +478,10 @@ static void battery_status_update(void) if ((battery_millivolts + 20) > percent_to_volt_discharge[0][0]) powermgmt_est_runningtime_min = (level + battery_percent) * 60 * battery_capacity / 200 / runcurrent(); + + else if (battery_millivolts <= battery_level_shutoff[0]) + powermgmt_est_runningtime_min = 0; + else powermgmt_est_runningtime_min = (battery_millivolts - battery_level_shutoff[0]) / 2;