Add in buttonlight brightness setting for the Gigabeat, and setup the framework for future players that have adjustable button light brightness settings. Also fixed a bug in the backlight code when the brightness was set to 0.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13356 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
830576bb0b
commit
6f95ab7de7
9 changed files with 98 additions and 5 deletions
|
@ -10775,6 +10775,23 @@
|
|||
gigabeatf: "Button Light Timeout"
|
||||
</voice>
|
||||
</phrase>
|
||||
<phrase>
|
||||
id: LANG_BUTTONLIGHT_BRIGHTNESS
|
||||
desc: in settings_menu
|
||||
user:
|
||||
<source>
|
||||
*: ""
|
||||
gigabeatf: "Button Light Brightness"
|
||||
</source>
|
||||
<dest>
|
||||
*: ""
|
||||
gigabeatf: "Button Light Brightness"
|
||||
</dest>
|
||||
<voice>
|
||||
*: ""
|
||||
gigabeatf: "Button Light Brightness"
|
||||
</voice>
|
||||
</phrase>
|
||||
<phrase>
|
||||
id: LANG_PLAYLISTVIEWER_SETTINGS
|
||||
desc: title for the playlist viewer settings menus
|
||||
|
|
|
@ -323,6 +323,10 @@ MENUITEM_SETTING(start_screen, &global_settings.start_in_screen, NULL);
|
|||
MENUITEM_SETTING(button_light_timeout, &global_settings.button_light_timeout, NULL);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
|
||||
MENUITEM_SETTING(buttonlight_brightness, &global_settings.buttonlight_brightness, NULL);
|
||||
#endif
|
||||
|
||||
MAKE_MENU(system_menu, ID2P(LANG_SYSTEM),
|
||||
0, Icon_System_menu,
|
||||
&start_screen,
|
||||
|
@ -351,6 +355,9 @@ MAKE_MENU(system_menu, ID2P(LANG_SYSTEM),
|
|||
#endif
|
||||
#ifdef HAVE_BUTTON_LIGHT
|
||||
&button_light_timeout,
|
||||
#endif
|
||||
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
|
||||
&buttonlight_brightness
|
||||
#endif
|
||||
);
|
||||
|
||||
|
|
|
@ -713,6 +713,9 @@ void settings_apply(void)
|
|||
#ifdef HAVE_BUTTON_LIGHT
|
||||
button_backlight_set_timeout(global_settings.button_light_timeout);
|
||||
#endif
|
||||
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
|
||||
buttonlight_set_brightness(global_settings.buttonlight_brightness);
|
||||
#endif
|
||||
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
|
||||
backlight_set_brightness(global_settings.brightness);
|
||||
#endif
|
||||
|
|
|
@ -720,6 +720,9 @@ struct user_settings
|
|||
#ifdef HAVE_BUTTON_LIGHT
|
||||
int button_light_timeout;
|
||||
#endif
|
||||
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
|
||||
int buttonlight_brightness;
|
||||
#endif
|
||||
};
|
||||
|
||||
/** global variables **/
|
||||
|
|
|
@ -1183,6 +1183,11 @@ const struct settings_list settings[] = {
|
|||
0, 18, 1, backlight_formatter, backlight_getlang,
|
||||
button_backlight_set_timeout),
|
||||
#endif
|
||||
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
|
||||
INT_SETTING(0, buttonlight_brightness, LANG_BUTTONLIGHT_BRIGHTNESS, DEFAULT_BRIGHTNESS_SETTING,
|
||||
"button light brightness",UNIT_INT, MIN_BRIGHTNESS_SETTING, MAX_BRIGHTNESS_SETTING, 1,
|
||||
NULL, NULL, buttonlight_set_brightness),
|
||||
#endif
|
||||
};
|
||||
|
||||
const int nb_settings = sizeof(settings)/sizeof(*settings);
|
||||
|
|
|
@ -58,6 +58,14 @@ static inline void __backlight_set_brightness(int val)
|
|||
(void)val;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
|
||||
static inline void __buttonlight_set_brightness(int val)
|
||||
{
|
||||
(void)val;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SIMULATOR */
|
||||
|
||||
#if defined(HAVE_BACKLIGHT) && !defined(BOOTLOADER)
|
||||
|
@ -846,6 +854,18 @@ void backlight_set_brightness(int val)
|
|||
}
|
||||
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
|
||||
|
||||
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
|
||||
void buttonlight_set_brightness(int val)
|
||||
{
|
||||
if (val < MIN_BRIGHTNESS_SETTING)
|
||||
val = MIN_BRIGHTNESS_SETTING;
|
||||
else if (val > MAX_BRIGHTNESS_SETTING)
|
||||
val = MAX_BRIGHTNESS_SETTING;
|
||||
|
||||
__buttonlight_set_brightness(val);
|
||||
}
|
||||
#endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
|
||||
|
||||
#else /* !defined(HAVE_BACKLIGHT) || defined(BOOTLOADER)
|
||||
-- no backlight, empty dummy functions */
|
||||
|
||||
|
@ -871,4 +891,7 @@ bool is_remote_backlight_on(void) {return true;}
|
|||
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
|
||||
void backlight_set_brightness(int val) { (void)val; }
|
||||
#endif
|
||||
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
|
||||
void buttonlight_set_brightness(int val) { (void)val; }
|
||||
#endif
|
||||
#endif /* defined(HAVE_BACKLIGHT) && !defined(BOOTLOADER) */
|
||||
|
|
|
@ -80,6 +80,10 @@ void sim_remote_backlight(int value);
|
|||
void backlight_set_brightness(int val);
|
||||
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
|
||||
|
||||
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
|
||||
void buttonlight_set_brightness(int val);
|
||||
#endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
|
||||
|
||||
#ifdef HAVE_BUTTON_LIGHT
|
||||
void button_backlight_on(void);
|
||||
void button_backlight_off(void);
|
||||
|
|
|
@ -49,6 +49,8 @@
|
|||
|
||||
#define HAVE_BACKLIGHT_BRIGHTNESS
|
||||
|
||||
#define HAVE_BUTTONLIGHT_BRIGHTNESS
|
||||
|
||||
/* Main LCD backlight brightness range and defaults */
|
||||
#define MIN_BRIGHTNESS_SETTING 0 /* 0.5 mA */
|
||||
#define MAX_DIM_BRIGHTNESS_SETTING 15 /* highest 'dimness' */
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
static void led_control_service(void);
|
||||
static unsigned short backlight_brightness;
|
||||
static unsigned short buttonlight_brightness;
|
||||
static unsigned short backlight_target;
|
||||
static unsigned short buttonlight_target;
|
||||
|
||||
|
@ -57,6 +58,7 @@ enum buttonlight_states
|
|||
BUTTONLIGHT_CONTROL_IDLE,
|
||||
BUTTONLIGHT_CONTROL_OFF,
|
||||
BUTTONLIGHT_CONTROL_ON,
|
||||
BUTTONLIGHT_CONTROL_SET,
|
||||
BUTTONLIGHT_CONTROL_FADE,
|
||||
} buttonlight_control;
|
||||
|
||||
|
@ -214,10 +216,15 @@ static void led_control_service(void)
|
|||
break;
|
||||
case BUTTONLIGHT_CONTROL_ON:
|
||||
sc606_changed=true;
|
||||
sc606regBval=sc606regCval=backlight_brightness;
|
||||
sc606regBval=sc606regCval=buttonlight_brightness;
|
||||
sc606regCONFval |= 0x3C;
|
||||
buttonlight_control=BUTTONLIGHT_CONTROL_IDLE;
|
||||
break;
|
||||
case BUTTONLIGHT_CONTROL_SET:
|
||||
sc606regBval=sc606regCval=buttonlight_brightness;
|
||||
sc606_changed=true;
|
||||
buttonlight_control = BUTTONLIGHT_CONTROL_ON;
|
||||
break;
|
||||
case BUTTONLIGHT_CONTROL_FADE:
|
||||
/* Was this mode set while the button light is already on/off? */
|
||||
if(buttonlight_target==sc606regBval)
|
||||
|
@ -288,7 +295,10 @@ static void led_control_service(void)
|
|||
void __button_backlight_on(void)
|
||||
{
|
||||
buttonlight_control = BUTTONLIGHT_CONTROL_IDLE;
|
||||
buttonlight_target = backlight_brightness;
|
||||
buttonlight_target = buttonlight_brightness;
|
||||
if(buttonlight_brightness==0)
|
||||
buttonlight_control = BUTTONLIGHT_CONTROL_ON;
|
||||
else
|
||||
buttonlight_control = BUTTONLIGHT_CONTROL_FADE;
|
||||
}
|
||||
|
||||
|
@ -296,6 +306,9 @@ void __button_backlight_off(void)
|
|||
{
|
||||
buttonlight_control = BUTTONLIGHT_CONTROL_IDLE;
|
||||
buttonlight_target = 0;
|
||||
if(buttonlight_brightness==0)
|
||||
buttonlight_control = BUTTONLIGHT_CONTROL_OFF;
|
||||
else
|
||||
buttonlight_control = BUTTONLIGHT_CONTROL_FADE;
|
||||
}
|
||||
|
||||
|
@ -304,5 +317,21 @@ void __backlight_dim(bool dim_now)
|
|||
/* dont let the interrupt tick happen */
|
||||
backlight_control = BACKLIGHT_CONTROL_IDLE;
|
||||
backlight_target = (dim_now == true) ? 0 : backlight_brightness;
|
||||
if(backlight_target==0 && backlight_brightness==0)
|
||||
{
|
||||
if(dim_now == false)
|
||||
backlight_control = BACKLIGHT_CONTROL_ON;
|
||||
else
|
||||
backlight_control = BACKLIGHT_CONTROL_OFF;
|
||||
}
|
||||
else
|
||||
backlight_control = BACKLIGHT_CONTROL_FADE;
|
||||
}
|
||||
|
||||
void __buttonlight_set_brightness(int brightness)
|
||||
{
|
||||
/* stop the interrupt from messing us up */
|
||||
buttonlight_control = BUTTONLIGHT_CONTROL_IDLE;
|
||||
buttonlight_brightness = brightness;
|
||||
buttonlight_control = BUTTONLIGHT_CONTROL_SET;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue