summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2002-09-26 22:34:35 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2002-09-26 22:34:35 +0000
commita05d2f490d2eaaa5da6578a37a9873b7f4946275 (patch)
tree13e32b7b96ab88e05d24e2bd19d95e1164a5b69d
parent76c613d8fbb44916bb31c3c42db95428c37b7683 (diff)
downloadrockbox-a05d2f490d2eaaa5da6578a37a9873b7f4946275.zip
rockbox-a05d2f490d2eaaa5da6578a37a9873b7f4946275.tar.gz
rockbox-a05d2f490d2eaaa5da6578a37a9873b7f4946275.tar.bz2
rockbox-a05d2f490d2eaaa5da6578a37a9873b7f4946275.tar.xz
Auto-poweroff restarts the timeout when extracting the charger
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2428 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/powermgmt.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c
index 0af7d63..93d3192 100644
--- a/firmware/powermgmt.c
+++ b/firmware/powermgmt.c
@@ -114,18 +114,28 @@ void set_poweroff_timeout(int timeout)
}
/* We shut off in the following cases:
- 1) The unit is not playing music
+ 1) The unit is idle, not playing music
2) The unit is playing music, but is paused
- We do not shut off if the unit is recording, but paused
+ We do not shut off in the following cases:
+ 1) The USB is connected
+ 2) The charger is connected
+ 3) We are recording, or recording with pause
*/
static void handle_auto_poweroff(void)
{
long timeout = poweroff_idle_timeout_value[poweroff_timeout]*60*HZ;
int mpeg_stat = mpeg_status();
+ bool charger_is_inserted = charger_inserted();
+ static bool charger_was_inserted = false;
- if(charger_inserted())
+ /* The was_inserted thing prevents the unit to shut down immediately
+ when the charger is extracted */
+ if(charger_is_inserted || charger_was_inserted)
+ {
last_charge_time = current_tick;
+ }
+ charger_was_inserted = charger_is_inserted;
if(timeout &&
!usb_inserted() &&
@@ -134,7 +144,7 @@ static void handle_auto_poweroff(void)
{
if(TIME_AFTER(current_tick, last_keypress + timeout) &&
TIME_AFTER(current_tick, last_disk_activity + timeout) &&
- TIME_AFTER(current_tick, last_charge_time))
+ TIME_AFTER(current_tick, last_charge_time + timeout))
power_off();
}
}