diff options
author | Barry Wardell <rockbox@barrywardell.net> | 2006-12-18 19:08:41 +0000 |
---|---|---|
committer | Barry Wardell <rockbox@barrywardell.net> | 2006-12-18 19:08:41 +0000 |
commit | a69b53dc89d9617257fb40124eb74d02f7633bf8 (patch) | |
tree | deb652a011c08bf6870414bc5099205431694e51 /firmware/target/arm/sandisk/sansa-e200/button-e200.c | |
parent | e90006133b6965dd2e4eb592e54b965a7f0932ba (diff) |
Add support for Sansa scrollwheel backlight. Turn light on when scrollwheel is in use, then back off again after a 5 second timeout.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11807 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/sandisk/sansa-e200/button-e200.c')
-rw-r--r-- | firmware/target/arm/sandisk/sansa-e200/button-e200.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/firmware/target/arm/sandisk/sansa-e200/button-e200.c b/firmware/target/arm/sandisk/sansa-e200/button-e200.c index 7a297885c0..0490c454c8 100644 --- a/firmware/target/arm/sandisk/sansa-e200/button-e200.c +++ b/firmware/target/arm/sandisk/sansa-e200/button-e200.c @@ -31,12 +31,29 @@ static unsigned int old_wheel_value = 0; static unsigned int wheel_repeat = BUTTON_NONE; +/* Wheel backlight control */ +#define WHEEL_BACKLIGHT_TIMEOUT 5*HZ; +static unsigned int wheel_backlight_timer; + +void wheel_backlight_on(bool enable) +{ + if(enable) + GPIOG_OUTPUT_VAL |=0x80; + else + GPIOG_OUTPUT_VAL &=~ 0x80; +} + void button_init_device(void) { /* Enable all buttons */ GPIOF_ENABLE |= 0xff; GPIOH_ENABLE |= 0xc0; + /* Scrollwheel light - enable control through GPIOG pin 7 and set timeout */ + GPIOG_ENABLE = 0x80; + GPIOG_OUTPUT_EN |= 0x80; + wheel_backlight_timer = WHEEL_BACKLIGHT_TIMEOUT; + /* Read initial wheel value (bit 6-7 of GPIOH) */ old_wheel_value = GPIOH_INPUT_VAL & 0xc0; } @@ -137,6 +154,20 @@ int button_read_device(void) old_wheel_value = new_wheel_value; } - + + if(wheel_backlight_timer>0){ + wheel_backlight_timer--; + if(wheel_backlight_timer==0){ + wheel_backlight_on(false); + } + } + + if( (btn & BUTTON_SCROLL_UP) || (btn & BUTTON_SCROLL_DOWN) ){ + if(wheel_backlight_timer==0){ + wheel_backlight_on(true); + } + wheel_backlight_timer = WHEEL_BACKLIGHT_TIMEOUT; + } + return btn; } |