diff options
| author | Jens Arnold <amiconn@rockbox.org> | 2005-11-23 20:12:33 +0000 |
|---|---|---|
| committer | Jens Arnold <amiconn@rockbox.org> | 2005-11-23 20:12:33 +0000 |
| commit | a6d409d9db969aedd3977ca3d0894bbf75533e39 (patch) | |
| tree | 848ac0a55eb16c5f407017d3f7f73318f248088d /firmware | |
| parent | 47569223ebb5e99040c7c5cfc7d2a725999c6197 (diff) | |
| download | rockbox-a6d409d9db969aedd3977ca3d0894bbf75533e39.zip rockbox-a6d409d9db969aedd3977ca3d0894bbf75533e39.tar.gz rockbox-a6d409d9db969aedd3977ca3d0894bbf75533e39.tar.bz2 rockbox-a6d409d9db969aedd3977ca3d0894bbf75533e39.tar.xz | |
Replaced the booolean 'Backlight On When Plugged' setting with a complete alternative 'Backlight When Plugged' timeout setting. * Yield during poweroff to make backlight_off() work. * Bumped config version, save your settings.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8053 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
| -rw-r--r-- | firmware/backlight.c | 79 | ||||
| -rw-r--r-- | firmware/drivers/power.c | 3 | ||||
| -rw-r--r-- | firmware/export/backlight.h | 7 | ||||
| -rw-r--r-- | firmware/powermgmt.c | 7 |
4 files changed, 46 insertions, 50 deletions
diff --git a/firmware/backlight.c b/firmware/backlight.c index 5a3c509..491d2b5 100644 --- a/firmware/backlight.c +++ b/firmware/backlight.c @@ -52,14 +52,18 @@ static long backlight_stack[DEFAULT_STACK_SIZE/sizeof(long)]; static const char backlight_thread_name[] = "backlight"; static struct event_queue backlight_queue; -static bool backlight_on_when_charging = false; static int backlight_timer; -static unsigned int backlight_timeout = 5; +static int backlight_timeout = 5*HZ; +#ifdef HAVE_CHARGING +static int backlight_timeout_plugged = 5*HZ; +#endif #ifdef HAVE_REMOTE_LCD -static bool remote_backlight_on_when_charging = false; static int remote_backlight_timer; -static unsigned int remote_backlight_timeout = 5; +static int remote_backlight_timeout = 5*HZ; +#ifdef HAVE_CHARGING +static int remote_backlight_timeout_plugged = 5*HZ; +#endif #endif #if (CONFIG_BACKLIGHT == BL_IRIVER_H100) && !defined(SIMULATOR) @@ -304,19 +308,15 @@ void backlight_thread(void) { #ifdef HAVE_REMOTE_LCD case REMOTE_BACKLIGHT_ON: - if( remote_backlight_on_when_charging && charger_inserted() ) - { - /* Forcing to zero keeps the lights on */ - remote_backlight_timer = 0; - } +#ifdef HAVE_CHARGING + if (charger_inserted()) + remote_backlight_timer = remote_backlight_timeout_plugged; else - { - remote_backlight_timer = - HZ*backlight_timeout_value[remote_backlight_timeout]; - } +#endif + remote_backlight_timer = remote_backlight_timeout; /* Backlight == OFF in the setting? */ - if(remote_backlight_timer < 0) + if (remote_backlight_timer < 0) { remote_backlight_timer = 0; /* Disable the timeout */ __remote_backlight_off(); @@ -333,17 +333,14 @@ void backlight_thread(void) #endif /* HAVE_REMOTE_LCD */ case BACKLIGHT_ON: - if( backlight_on_when_charging && charger_inserted() ) - { - /* Forcing to zero keeps the lights on */ - backlight_timer = 0; - } +#ifdef HAVE_CHARGING + if (charger_inserted()) + backlight_timer = backlight_timeout_plugged; else - { - backlight_timer = HZ*backlight_timeout_value[backlight_timeout]; - } +#endif + backlight_timer = backlight_timeout; - if(backlight_timer < 0) /* Backlight == OFF in the setting? */ + if (backlight_timer < 0) /* Backlight == OFF in the setting? */ { backlight_timer = 0; /* Disable the timeout */ __backlight_off(); @@ -385,11 +382,9 @@ static void backlight_tick(void) if( charger_was_inserted != charger_is_inserted ) { - if( backlight_on_when_charging ) - backlight_on(); + backlight_on(); #ifdef HAVE_REMOTE_LCD - if( remote_backlight_on_when_charging ) - remote_backlight_on(); + remote_backlight_on(); #endif } charger_was_inserted = charger_is_inserted; @@ -453,9 +448,14 @@ void backlight_off(void) queue_post(&backlight_queue, BACKLIGHT_OFF, NULL); } -int backlight_get_timeout(void) +/* return value in ticks; 0 means always on, <0 means always off */ +int backlight_get_current_timeout(void) { +#ifdef HAVE_CHARGING + return charger_inserted() ? backlight_timeout_plugged : backlight_timeout; +#else return backlight_timeout; +#endif } void backlight_set_timeout(int index) @@ -463,19 +463,17 @@ void backlight_set_timeout(int index) if((unsigned)index >= sizeof(backlight_timeout_value)) /* if given a weird value, use 0 */ index=0; - backlight_timeout = index; /* index in the backlight_timeout_value table */ + backlight_timeout = HZ * backlight_timeout_value[index]; backlight_on(); } #ifdef HAVE_CHARGING -bool backlight_get_on_when_charging(void) -{ - return backlight_on_when_charging; -} - -void backlight_set_on_when_charging(bool yesno) +void backlight_set_timeout_plugged(int index) { - backlight_on_when_charging = yesno; + if((unsigned)index >= sizeof(backlight_timeout_value)) + /* if given a weird value, use 0 */ + index=0; + backlight_timeout_plugged = HZ * backlight_timeout_value[index]; backlight_on(); } #endif @@ -496,14 +494,17 @@ void remote_backlight_set_timeout(int index) if((unsigned)index >= sizeof(backlight_timeout_value)) /* if given a weird value, use 0 */ index=0; - remote_backlight_timeout = index; /* index in the backlight_timeout_value table */ + remote_backlight_timeout = HZ * backlight_timeout_value[index]; remote_backlight_on(); } #ifdef HAVE_CHARGING -void remote_backlight_set_on_when_charging(bool yesno) +void remote_backlight_set_timeout_plugged(int index) { - remote_backlight_on_when_charging = yesno; + if((unsigned)index >= sizeof(backlight_timeout_value)) + /* if given a weird value, use 0 */ + index=0; + remote_backlight_timeout_plugged = HZ * backlight_timeout_value[index]; remote_backlight_on(); } #endif diff --git a/firmware/drivers/power.c b/firmware/drivers/power.c index 252a04d..e339b90 100644 --- a/firmware/drivers/power.c +++ b/firmware/drivers/power.c @@ -280,7 +280,8 @@ void power_off(void) or_b(0x08, &PAIORH); #endif #endif - while(1); + while(1) + yield(); } #else diff --git a/firmware/export/backlight.h b/firmware/export/backlight.h index 6d3d4d5..9c3f5aa 100644 --- a/firmware/export/backlight.h +++ b/firmware/export/backlight.h @@ -26,13 +26,12 @@ void backlight_off(void); void backlight_set_timeout(int index); #ifdef CONFIG_BACKLIGHT void backlight_init(void); -int backlight_get_timeout(void); +int backlight_get_current_timeout(void); #if CONFIG_BACKLIGHT == BL_IRIVER_H100 void backlight_set_fade_in(int index); void backlight_set_fade_out(int index); #endif -bool backlight_get_on_when_charging(void); -void backlight_set_on_when_charging(bool yesno); +void backlight_set_timeout_plugged(int index); extern const char backlight_timeout_value[]; #else #define backlight_init() @@ -42,7 +41,7 @@ extern const char backlight_timeout_value[]; void remote_backlight_on(void); void remote_backlight_off(void); void remote_backlight_set_timeout(int index); -void remote_backlight_set_on_when_charging(bool yesno); +void remote_backlight_set_timeout_plugged(int index); #endif #ifdef SIMULATOR diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c index 72a9b90..e061f70 100644 --- a/firmware/powermgmt.c +++ b/firmware/powermgmt.c @@ -449,13 +449,8 @@ static int runcurrent(void) } #if defined(CONFIG_BACKLIGHT) && !defined(BOOTLOADER) - if ((backlight_get_timeout() == 1) /* LED always on */ -#ifdef HAVE_CHARGE_CTRL - || (charger_inserted() && backlight_get_on_when_charging()) -#endif - ) { + if (backlight_get_current_timeout() == 0) /* LED always on */ current += CURRENT_BACKLIGHT; - } #endif return(current); |