summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNils Wallménius <nils@rockbox.org>2008-04-12 07:14:13 +0000
committerNils Wallménius <nils@rockbox.org>2008-04-12 07:14:13 +0000
commit02eb1d83a79c265b0273e18630553efcf8b9196c (patch)
tree5b9564097240713f33613bae898036d786348708
parentef97db1011b57bb41946fe1e124d5b64a1320af3 (diff)
downloadrockbox-02eb1d83a79c265b0273e18630553efcf8b9196c.zip
rockbox-02eb1d83a79c265b0273e18630553efcf8b9196c.tar.gz
rockbox-02eb1d83a79c265b0273e18630553efcf8b9196c.tar.bz2
rockbox-02eb1d83a79c265b0273e18630553efcf8b9196c.tar.xz
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
-rw-r--r--docs/CREDITS1
-rw-r--r--firmware/powermgmt.c4
2 files changed, 5 insertions, 0 deletions
diff --git a/docs/CREDITS b/docs/CREDITS
index 9b4a02a..4809483 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 072a31f..69b0704 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;