diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2002-09-26 22:34:35 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2002-09-26 22:34:35 +0000 |
commit | a05d2f490d2eaaa5da6578a37a9873b7f4946275 (patch) | |
tree | 13e32b7b96ab88e05d24e2bd19d95e1164a5b69d /firmware | |
parent | 76c613d8fbb44916bb31c3c42db95428c37b7683 (diff) | |
download | rockbox-a05d2f490d2eaaa5da6578a37a9873b7f4946275.tar.gz rockbox-a05d2f490d2eaaa5da6578a37a9873b7f4946275.zip |
Auto-poweroff restarts the timeout when extracting the charger
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2428 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/powermgmt.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c index 0af7d63a26..93d3192904 100644 --- a/firmware/powermgmt.c +++ b/firmware/powermgmt.c | |||
@@ -114,18 +114,28 @@ void set_poweroff_timeout(int timeout) | |||
114 | } | 114 | } |
115 | 115 | ||
116 | /* We shut off in the following cases: | 116 | /* We shut off in the following cases: |
117 | 1) The unit is not playing music | 117 | 1) The unit is idle, not playing music |
118 | 2) The unit is playing music, but is paused | 118 | 2) The unit is playing music, but is paused |
119 | 119 | ||
120 | We do not shut off if the unit is recording, but paused | 120 | We do not shut off in the following cases: |
121 | 1) The USB is connected | ||
122 | 2) The charger is connected | ||
123 | 3) We are recording, or recording with pause | ||
121 | */ | 124 | */ |
122 | static void handle_auto_poweroff(void) | 125 | static void handle_auto_poweroff(void) |
123 | { | 126 | { |
124 | long timeout = poweroff_idle_timeout_value[poweroff_timeout]*60*HZ; | 127 | long timeout = poweroff_idle_timeout_value[poweroff_timeout]*60*HZ; |
125 | int mpeg_stat = mpeg_status(); | 128 | int mpeg_stat = mpeg_status(); |
129 | bool charger_is_inserted = charger_inserted(); | ||
130 | static bool charger_was_inserted = false; | ||
126 | 131 | ||
127 | if(charger_inserted()) | 132 | /* The was_inserted thing prevents the unit to shut down immediately |
133 | when the charger is extracted */ | ||
134 | if(charger_is_inserted || charger_was_inserted) | ||
135 | { | ||
128 | last_charge_time = current_tick; | 136 | last_charge_time = current_tick; |
137 | } | ||
138 | charger_was_inserted = charger_is_inserted; | ||
129 | 139 | ||
130 | if(timeout && | 140 | if(timeout && |
131 | !usb_inserted() && | 141 | !usb_inserted() && |
@@ -134,7 +144,7 @@ static void handle_auto_poweroff(void) | |||
134 | { | 144 | { |
135 | if(TIME_AFTER(current_tick, last_keypress + timeout) && | 145 | if(TIME_AFTER(current_tick, last_keypress + timeout) && |
136 | TIME_AFTER(current_tick, last_disk_activity + timeout) && | 146 | TIME_AFTER(current_tick, last_disk_activity + timeout) && |
137 | TIME_AFTER(current_tick, last_charge_time)) | 147 | TIME_AFTER(current_tick, last_charge_time + timeout)) |
138 | power_off(); | 148 | power_off(); |
139 | } | 149 | } |
140 | } | 150 | } |