All pastes #283915 Raw Edit

Stuff

public text v1 · immutable
#283915 ·published 2006-12-18 18:53 UTC
rendered paste body
Index: firmware/target/arm/sandisk/sansa-e200/button-e200.c
===================================================================
RCS file: /cvsroot/rockbox/firmware/target/arm/sandisk/sansa-e200/button-e200.c,v
retrieving revision 1.3
diff -u -r1.3 button-e200.c
--- firmware/target/arm/sandisk/sansa-e200/button-e200.c	16 Dec 2006 00:21:41 -0000	1.3
+++ firmware/target/arm/sandisk/sansa-e200/button-e200.c	18 Dec 2006 18:53:00 -0000
@@ -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 turn off */
+    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 @@
         
         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;
 }