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
This commit is contained in:
Jonathan Gordon 2007-04-22 13:02:24 +00:00
parent 6bf86b799e
commit 4b1d1b4033
11 changed files with 139 additions and 24 deletions

View file

@ -10741,3 +10741,20 @@
*: "Context Menu"
</voice>
</phrase>
<phrase>
id: LANG_BUTTONLIGHT_TIMEOUT
desc: in settings_menu
user:
<source>
*: ""
e200: "Wheel Light Timeout"
</source>
<dest>
*: ""
e200: "Wheel Light Timeout"
</dest>
<voice>
*: ""
e200: "Wheel Light Timeout"
</voice>
</phrase>

View file

@ -319,6 +319,10 @@ MENUITEM_SETTING(car_adapter_mode, &global_settings.car_adapter_mode, NULL);
#endif
MENUITEM_SETTING(start_screen, &global_settings.start_in_screen, NULL);
#ifdef HAVE_BUTTON_LIGHT
MENUITEM_SETTING(button_light_timeout, &global_settings.button_light_timeout, NULL);
#endif
MAKE_MENU(system_menu, ID2P(LANG_SYSTEM),
0, Icon_System_menu,
&start_screen,
@ -344,6 +348,9 @@ MAKE_MENU(system_menu, ID2P(LANG_SYSTEM),
#endif
#if CONFIG_CHARGING
&car_adapter_mode,
#endif
#ifdef HAVE_BUTTON_LIGHT
&button_light_timeout,
#endif
);

View file

@ -709,6 +709,9 @@ void settings_apply(void)
backlight_set_fade_out(global_settings.backlight_fade_out);
#endif
#endif
#ifdef HAVE_BUTTON_LIGHT
button_backlight_set_timeout(global_settings.button_light_timeout);
#endif
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
backlight_set_brightness(global_settings.brightness);
#endif

View file

@ -717,6 +717,9 @@ struct user_settings
unsigned char remote_icon_file[MAX_FILENAME+1];
unsigned char remote_viewers_icon_file[MAX_FILENAME+1];
#endif
#ifdef HAVE_BUTTON_LIGHT
int button_light_timeout;
#endif
};
/** global variables **/

View file

@ -1175,6 +1175,13 @@ const struct settings_list settings[] = {
"remote viewers iconset", "",
ICON_DIR "/", ".bmp", MAX_FILENAME+1),
#endif /* HAVE_REMOTE_LCD */
#ifdef HAVE_BUTTON_LIGHT
INT_SETTING_W_CFGVALS(F_FLIPLIST, button_light_timeout,
LANG_BUTTONLIGHT_TIMEOUT, 6,
"button light timeout", backlight_times_conf, UNIT_SEC,
0, 18, 1, backlight_formatter, backlight_getlang,
button_backlight_set_timeout),
#endif
};
const int nb_settings = sizeof(settings)/sizeof(*settings);

View file

@ -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

View file

@ -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 */

View file

@ -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

View file

@ -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;
}

View file

@ -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

View file

@ -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;