diff options
| author | Steve Gotthardt <gotthardt@rockbox.org> | 2007-01-04 09:32:49 +0000 |
|---|---|---|
| committer | Steve Gotthardt <gotthardt@rockbox.org> | 2007-01-04 09:32:49 +0000 |
| commit | 775c901f765e864a063190203f55ed545e747698 (patch) | |
| tree | 69cd0c4c635f1769572ac1cf4a3aa379a53018e5 | |
| parent | 6d101042c62aa7ac204624e4031fed11cded13d1 (diff) | |
| download | rockbox-775c901f765e864a063190203f55ed545e747698.zip rockbox-775c901f765e864a063190203f55ed545e747698.tar.gz rockbox-775c901f765e864a063190203f55ed545e747698.tar.bz2 rockbox-775c901f765e864a063190203f55ed545e747698.tar.xz | |
Implementing backlight fade for the Gigabeat. Note that fading is the normal behaviour. Settings for LCD off and fade settings will be coming.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11899 a1c6a512-1295-4272-9138-f99709370657
| -rw-r--r-- | firmware/target/arm/gigabeat/meg-fx/backlight-meg-fx.c | 105 | ||||
| -rw-r--r-- | firmware/target/arm/gigabeat/meg-fx/backlight-target.h | 2 |
2 files changed, 105 insertions, 2 deletions
diff --git a/firmware/target/arm/gigabeat/meg-fx/backlight-meg-fx.c b/firmware/target/arm/gigabeat/meg-fx/backlight-meg-fx.c index ba98dba..12a5b55 100644 --- a/firmware/target/arm/gigabeat/meg-fx/backlight-meg-fx.c +++ b/firmware/target/arm/gigabeat/meg-fx/backlight-meg-fx.c @@ -24,27 +24,128 @@ #include "lcd.h" #include "sc606-meg-fx.h" + +static void backlight_fade_service(void); +static unsigned short backlight_brightness; +static unsigned short backlight_fading; +static unsigned short backlight_current; +static unsigned short backlight_target; +static unsigned short time_til_fade; +static unsigned short fade_interval; + + static int confval = SC606_LOW_FREQ; + + void __backlight_init(void) { + backlight_fading = false; + + /* current is from settings */ + backlight_current = 50; + + /* put the fade tick on the list */ + tick_add_task(backlight_fade_service); } + + void __backlight_on(void) { confval |= (SC606_LED_A1 | SC606_LED_A2); sc606_write(SC606_REG_CONF, confval); } + + void __backlight_off(void) { confval &= ~(SC606_LED_A1 | SC606_LED_A2); sc606_write(SC606_REG_CONF, confval); } + + +/* Assumes that the backlight has been initialized */ void __backlight_set_brightness(int brightness) { + /* stop the interrupt from messing us up */ + backlight_fading = false; + + backlight_brightness = brightness; + + /* only set the brightness if it is different from the current */ + if (backlight_brightness != backlight_current) + { + backlight_target = brightness; + fade_interval = time_til_fade = 1; + backlight_fading = true; + } +} + + + +static void backlight_fade_service(void) +{ + if (!backlight_fading || --time_til_fade) return; + + if (backlight_target > backlight_current) + { + backlight_current++; + } + else + { + backlight_current--; + } + /* The SC606 LED driver can set the brightness in 64 steps */ - brightness &= 0x3F; - sc606_write(SC606_REG_A, brightness); + sc606_write(SC606_REG_A, backlight_current); + + + /* have we hit the target? */ + if (backlight_current == backlight_target) + { + backlight_fading = false; + } + else + { + time_til_fade = fade_interval; + } + +} + + + + + +void __backlight_dim(bool dim_now) +{ + int target; + + /* dont let the interrupt tick happen */ + backlight_fading = false; + + target = (dim_now == true) ? 0 : backlight_brightness; + + /* only try and fade if the target is different */ + if (backlight_current != target) + { + backlight_target = target; + + if (backlight_current > backlight_target) + { + fade_interval = 4; + } + else + { + fade_interval = 1; + } + + /* let the tick work */ + time_til_fade = fade_interval; + backlight_fading = true; + } + } + diff --git a/firmware/target/arm/gigabeat/meg-fx/backlight-target.h b/firmware/target/arm/gigabeat/meg-fx/backlight-target.h index e72e863..c53d00d 100644 --- a/firmware/target/arm/gigabeat/meg-fx/backlight-target.h +++ b/firmware/target/arm/gigabeat/meg-fx/backlight-target.h @@ -24,4 +24,6 @@ void __backlight_on(void); void __backlight_off(void); void __backlight_set_brightness(int val); +void __backlight_dim(bool dim); + #endif |