Move sleep timer code outside of PLATFORM_NATIVE ifdef so RaaA can access it

Also remove redundant RaaA stubs for it.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29467 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Thomas Jarosch 2011-02-28 23:05:00 +00:00
parent 3bcfd5c106
commit 2647d11354
4 changed files with 51 additions and 66 deletions

View file

@ -164,6 +164,7 @@ void set_battery_type(int type); /* set local battery type */
void set_sleep_timer(int seconds);
int get_sleep_timer(void);
void handle_sleep_timer(void);
void set_car_adapter_mode(bool setting);
void reset_poweroff_timer(void);
void cancel_shutdown(void);

View file

@ -106,9 +106,6 @@ static const char power_thread_name[] = "power";
static int poweroff_timeout = 0;
static int powermgmt_est_runningtime_min = -1;
static bool sleeptimer_active = false;
static long sleeptimer_endtick;
static long last_event_tick;
static int voltage_to_battery_level(int battery_millivolts);
@ -204,26 +201,6 @@ void set_poweroff_timeout(int timeout)
poweroff_timeout = timeout;
}
void set_sleep_timer(int seconds)
{
if (seconds) {
sleeptimer_active = true;
sleeptimer_endtick = current_tick + seconds * HZ;
}
else {
sleeptimer_active = false;
sleeptimer_endtick = 0;
}
}
int get_sleep_timer(void)
{
if (sleeptimer_active && (sleeptimer_endtick >= current_tick))
return (sleeptimer_endtick - current_tick) / HZ;
else
return 0;
}
/* look into the percent_to_volt_* table and get a realistic battery level */
static int voltage_to_percent(int voltage, const short* table)
{
@ -350,27 +327,8 @@ static void handle_auto_poweroff(void)
TIME_AFTER(tick, storage_last_disk_activity() + timeout)) {
sys_poweroff();
}
}
else if (sleeptimer_active) {
/* Handle sleeptimer */
if (TIME_AFTER(tick, sleeptimer_endtick)) {
audio_stop();
if (usb_inserted()
#if CONFIG_CHARGING && !defined(HAVE_POWEROFF_WHILE_CHARGING)
|| charger_input_state != NO_CHARGER
#endif
) {
DEBUGF("Sleep timer timeout. Stopping...\n");
set_sleep_timer(0);
backlight_off(); /* Nighty, nighty... */
}
else {
DEBUGF("Sleep timer timeout. Shutting off...\n");
sys_poweroff();
}
}
}
} else
handle_sleep_timer();
}
#ifdef CURRENT_NORMAL /*check that we have a current defined in a config file*/
@ -853,3 +811,51 @@ void send_battery_level_event(void)
level++;
}
}
static bool sleeptimer_active = false;
static long sleeptimer_endtick;
void set_sleep_timer(int seconds)
{
if (seconds) {
sleeptimer_active = true;
sleeptimer_endtick = current_tick + seconds * HZ;
}
else {
sleeptimer_active = false;
sleeptimer_endtick = 0;
}
}
int get_sleep_timer(void)
{
if (sleeptimer_active && (sleeptimer_endtick >= current_tick))
return (sleeptimer_endtick - current_tick) / HZ;
else
return 0;
}
void handle_sleep_timer(void)
{
if (!sleeptimer_active)
return;
/* Handle sleeptimer */
if (TIME_AFTER(current_tick, sleeptimer_endtick)) {
audio_stop();
if (usb_inserted()
#if CONFIG_CHARGING && !defined(HAVE_POWEROFF_WHILE_CHARGING)
|| charger_input_state != NO_CHARGER
#endif
) {
DEBUGF("Sleep timer timeout. Stopping...\n");
set_sleep_timer(0);
backlight_off(); /* Nighty, nighty... */
}
else {
DEBUGF("Sleep timer timeout. Shutting off...\n");
sys_poweroff();
}
}
}

View file

@ -73,14 +73,3 @@ unsigned battery_voltage(void)
{
return 0;
}
static int sleeptime;
void set_sleep_timer(int seconds)
{
sleeptime = seconds;
}
int get_sleep_timer(void)
{
return sleeptime;
}

View file

@ -385,17 +385,6 @@ void mpeg_set_pitch(int pitch)
(void)pitch;
}
static int sleeptime;
void set_sleep_timer(int seconds)
{
sleeptime = seconds;
}
int get_sleep_timer(void)
{
return sleeptime;
}
#ifdef HAVE_LCD_CHARCELLS
void lcd_clearrect (int x, int y, int nx, int ny)
{