summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/target/arm/sandisk/sansa-e200/button-e200.c33
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 @@
31static unsigned int old_wheel_value = 0; 31static unsigned int old_wheel_value = 0;
32static unsigned int wheel_repeat = BUTTON_NONE; 32static unsigned int wheel_repeat = BUTTON_NONE;
33 33
34/* Wheel backlight control */
35#define WHEEL_BACKLIGHT_TIMEOUT 5*HZ;
36static unsigned int wheel_backlight_timer;
37
38void wheel_backlight_on(bool enable)
39{
40 if(enable)
41 GPIOG_OUTPUT_VAL |=0x80;
42 else
43 GPIOG_OUTPUT_VAL &=~ 0x80;
44}
45
34void button_init_device(void) 46void button_init_device(void)
35{ 47{
36 /* Enable all buttons */ 48 /* Enable all buttons */
37 GPIOF_ENABLE |= 0xff; 49 GPIOF_ENABLE |= 0xff;
38 GPIOH_ENABLE |= 0xc0; 50 GPIOH_ENABLE |= 0xc0;
39 51
52 /* Scrollwheel light - enable control through GPIOG pin 7 and set timeout */
53 GPIOG_ENABLE = 0x80;
54 GPIOG_OUTPUT_EN |= 0x80;
55 wheel_backlight_timer = WHEEL_BACKLIGHT_TIMEOUT;
56
40 /* Read initial wheel value (bit 6-7 of GPIOH) */ 57 /* Read initial wheel value (bit 6-7 of GPIOH) */
41 old_wheel_value = GPIOH_INPUT_VAL & 0xc0; 58 old_wheel_value = GPIOH_INPUT_VAL & 0xc0;
42} 59}
@@ -137,6 +154,20 @@ int button_read_device(void)
137 154
138 old_wheel_value = new_wheel_value; 155 old_wheel_value = new_wheel_value;
139 } 156 }
140 157
158 if(wheel_backlight_timer>0){
159 wheel_backlight_timer--;
160 if(wheel_backlight_timer==0){
161 wheel_backlight_on(false);
162 }
163 }
164
165 if( (btn & BUTTON_SCROLL_UP) || (btn & BUTTON_SCROLL_DOWN) ){
166 if(wheel_backlight_timer==0){
167 wheel_backlight_on(true);
168 }
169 wheel_backlight_timer = WHEEL_BACKLIGHT_TIMEOUT;
170 }
171
141 return btn; 172 return btn;
142} 173}