summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2007-04-22 13:02:24 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2007-04-22 13:02:24 +0000
commit4b1d1b40339d98e08d1d975d4fa511a0768a7204 (patch)
tree732f6c3ef001f15409181c12a3d27a8d62d03b00 /firmware
parent6bf86b799ec96c9e9d42cf9fd2e0654023eee057 (diff)
downloadrockbox-4b1d1b40339d98e08d1d975d4fa511a0768a7204.tar.gz
rockbox-4b1d1b40339d98e08d1d975d4fa511a0768a7204.zip
e200: Make the wheel light timeout configurable (under settings > system) (FS#7067)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13244 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/backlight.c79
-rw-r--r--firmware/export/backlight.h6
-rw-r--r--firmware/export/config-e200.h3
-rw-r--r--firmware/target/arm/sandisk/sansa-e200/backlight-e200.c11
-rw-r--r--firmware/target/arm/sandisk/sansa-e200/backlight-target.h2
-rw-r--r--firmware/target/arm/sandisk/sansa-e200/button-e200.c25
6 files changed, 102 insertions, 24 deletions
diff --git a/firmware/backlight.c b/firmware/backlight.c
index 54737da647..2bdfe86c77 100644
--- a/firmware/backlight.c
+++ b/firmware/backlight.c
@@ -75,6 +75,10 @@ const signed char backlight_timeout_value[19] =
#ifdef HAVE_LCD_SLEEP
#define LCD_SLEEP 6
#endif
+#ifdef HAVE_BUTTON_LIGHT
+#define BUTTON_LIGHT_ON 7
+#define BUTTON_LIGHT_OFF 8
+#endif
static void backlight_thread(void);
static long backlight_stack[DEFAULT_STACK_SIZE/sizeof(long)];
@@ -93,6 +97,60 @@ static int backlight_timeout_plugged = 5*HZ;
static int backlight_on_button_hold = 0;
#endif
+#ifdef HAVE_BUTTON_LIGHT
+static int button_backlight_timer;
+static int button_backlight_timeout = 5*HZ;
+
+/* external interface */
+void button_backlight_on(void)
+{
+ queue_remove_from_head(&backlight_queue, BUTTON_LIGHT_ON);
+ queue_post(&backlight_queue, BUTTON_LIGHT_ON, 0);
+}
+
+void button_backlight_off(void)
+{
+ queue_post(&backlight_queue, BUTTON_LIGHT_OFF, 0);
+}
+
+void button_backlight_set_timeout(int index)
+{
+ if((unsigned)index >= sizeof(backlight_timeout_value))
+ /* if given a weird value, use default */
+ index = 6;
+ button_backlight_timeout = HZ * backlight_timeout_value[index];
+ if (index == 0) /* off */
+ button_backlight_off();
+ else if (index == 1) /* on */
+ button_backlight_on();
+
+ if (button_backlight_timer)
+ button_backlight_timer = button_backlight_timeout;
+}
+
+/* internal interface */
+static void _button_backlight_on(void)
+{
+ if (button_backlight_timeout < 0)
+ return;
+ button_backlight_timer = button_backlight_timeout;
+#ifndef SIMULATOR
+ __button_backlight_on();
+#endif
+}
+
+static void _button_backlight_off(void)
+{
+ if (button_backlight_timeout == 0)
+ return;
+ button_backlight_timer = 0;
+#ifndef SIMULATOR
+ __button_backlight_off();
+#endif
+}
+
+#endif
+
#ifdef HAVE_REMOTE_LCD
static int remote_backlight_timer;
static int remote_backlight_timeout = 5*HZ;
@@ -444,6 +502,14 @@ void backlight_thread(void)
lcd_sleep();
break;
#endif
+#ifdef HAVE_BUTTON_LIGHT
+ case BUTTON_LIGHT_ON:
+ _button_backlight_on();
+ break;
+ case BUTTON_LIGHT_OFF:
+ _button_backlight_off();
+ break;
+#endif
#ifdef X5_BACKLIGHT_SHUTDOWN
case BACKLIGHT_QUIT:
@@ -521,6 +587,16 @@ static void backlight_tick(void)
}
}
#endif /* HAVE_REMOVE_LCD */
+#ifdef HAVE_BUTTON_LIGHT
+ if (button_backlight_timer)
+ {
+ button_backlight_timer--;
+ if (button_backlight_timer == 0)
+ {
+ button_backlight_off();
+ }
+ }
+#endif /* HAVE_BUTTON_LIGHT */
}
void backlight_init(void)
@@ -542,6 +618,9 @@ void backlight_init(void)
#ifdef HAVE_REMOTE_LCD
remote_backlight_on();
#endif
+#ifdef HAVE_BUTTON_LIGHT
+ button_backlight_on();
+#endif
create_thread(backlight_thread, backlight_stack,
sizeof(backlight_stack), backlight_thread_name
diff --git a/firmware/export/backlight.h b/firmware/export/backlight.h
index 4b164c63d2..9bcb6e9d1d 100644
--- a/firmware/export/backlight.h
+++ b/firmware/export/backlight.h
@@ -80,4 +80,10 @@ void sim_remote_backlight(int value);
void backlight_set_brightness(int val);
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
+#ifdef HAVE_BUTTON_LIGHT
+void button_backlight_on(void);
+void button_backlight_off(void);
+void button_backlight_set_timeout(int index);
+#endif
+
#endif /* BACKLIGHT_H */
diff --git a/firmware/export/config-e200.h b/firmware/export/config-e200.h
index ccff38dbf2..87d7e78fbb 100644
--- a/firmware/export/config-e200.h
+++ b/firmware/export/config-e200.h
@@ -22,6 +22,9 @@
#define MAX_BRIGHTNESS_SETTING 12
#define DEFAULT_BRIGHTNESS_SETTING 6
+/* define this if you have a light associated with the buttons */
+#define HAVE_BUTTON_LIGHT
+
/* define this if you have access to the quickscreen */
#define HAVE_QUICKSCREEN
diff --git a/firmware/target/arm/sandisk/sansa-e200/backlight-e200.c b/firmware/target/arm/sandisk/sansa-e200/backlight-e200.c
index 787f14b1a6..0ec19b4df1 100644
--- a/firmware/target/arm/sandisk/sansa-e200/backlight-e200.c
+++ b/firmware/target/arm/sandisk/sansa-e200/backlight-e200.c
@@ -39,3 +39,14 @@ void __backlight_off(void)
{
pp_i2c_send( 0x46, 0x23, 0x0);
}
+
+
+void __button_backlight_on(void)
+{
+ GPIOG_OUTPUT_VAL |=0x80;
+}
+
+void __button_backlight_off(void)
+{
+ GPIOG_OUTPUT_VAL &=~ 0x80;
+}
diff --git a/firmware/target/arm/sandisk/sansa-e200/backlight-target.h b/firmware/target/arm/sandisk/sansa-e200/backlight-target.h
index 16a02a4d11..2227278985 100644
--- a/firmware/target/arm/sandisk/sansa-e200/backlight-target.h
+++ b/firmware/target/arm/sandisk/sansa-e200/backlight-target.h
@@ -24,4 +24,6 @@ void __backlight_on(void);
void __backlight_off(void);
void __backlight_set_brightness(int brightness);
+void __button_backlight_on(void);
+void __button_backlight_off(void);
#endif
diff --git a/firmware/target/arm/sandisk/sansa-e200/button-e200.c b/firmware/target/arm/sandisk/sansa-e200/button-e200.c
index fe0b1eaf18..bbe37bcd9a 100644
--- a/firmware/target/arm/sandisk/sansa-e200/button-e200.c
+++ b/firmware/target/arm/sandisk/sansa-e200/button-e200.c
@@ -31,18 +31,6 @@
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 */
@@ -52,7 +40,6 @@ void button_init_device(void)
/* 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;
@@ -153,23 +140,13 @@ 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) ){
/* only trigger once per click */
if ((new_wheel_value == 0x00) || (new_wheel_value == 0xc0))
{
btn = btn&(~(BUTTON_SCROLL_UP|BUTTON_SCROLL_DOWN));
}
- if(wheel_backlight_timer==0){
- wheel_backlight_on(true);
- }
- wheel_backlight_timer = WHEEL_BACKLIGHT_TIMEOUT;
+ button_backlight_on();
}
return btn;