forked from len0rd/rockbox
Auto-poweroff restarts the timeout when extracting the charger
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2428 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
76c613d8fb
commit
a05d2f490d
1 changed files with 14 additions and 4 deletions
|
|
@ -114,18 +114,28 @@ void set_poweroff_timeout(int timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We shut off in the following cases:
|
/* 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
|
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)
|
static void handle_auto_poweroff(void)
|
||||||
{
|
{
|
||||||
long timeout = poweroff_idle_timeout_value[poweroff_timeout]*60*HZ;
|
long timeout = poweroff_idle_timeout_value[poweroff_timeout]*60*HZ;
|
||||||
int mpeg_stat = mpeg_status();
|
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;
|
last_charge_time = current_tick;
|
||||||
|
}
|
||||||
|
charger_was_inserted = charger_is_inserted;
|
||||||
|
|
||||||
if(timeout &&
|
if(timeout &&
|
||||||
!usb_inserted() &&
|
!usb_inserted() &&
|
||||||
|
|
@ -134,7 +144,7 @@ static void handle_auto_poweroff(void)
|
||||||
{
|
{
|
||||||
if(TIME_AFTER(current_tick, last_keypress + timeout) &&
|
if(TIME_AFTER(current_tick, last_keypress + timeout) &&
|
||||||
TIME_AFTER(current_tick, last_disk_activity + 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();
|
power_off();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue