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
This commit is contained in:
parent
e90006133b
commit
a69b53dc89
1 changed files with 32 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
@ -138,5 +155,19 @@ 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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue