mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-09 13:15:18 -05:00
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"
|
gigabeatf: "Button Light Timeout"
|
||||||
</voice>
|
</voice>
|
||||||
</phrase>
|
</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>
|
<phrase>
|
||||||
id: LANG_PLAYLISTVIEWER_SETTINGS
|
id: LANG_PLAYLISTVIEWER_SETTINGS
|
||||||
desc: title for the playlist viewer settings menus
|
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);
|
MENUITEM_SETTING(button_light_timeout, &global_settings.button_light_timeout, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
|
||||||
|
MENUITEM_SETTING(buttonlight_brightness, &global_settings.buttonlight_brightness, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
MAKE_MENU(system_menu, ID2P(LANG_SYSTEM),
|
MAKE_MENU(system_menu, ID2P(LANG_SYSTEM),
|
||||||
0, Icon_System_menu,
|
0, Icon_System_menu,
|
||||||
&start_screen,
|
&start_screen,
|
||||||
|
|
@ -351,6 +355,9 @@ MAKE_MENU(system_menu, ID2P(LANG_SYSTEM),
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_BUTTON_LIGHT
|
#ifdef HAVE_BUTTON_LIGHT
|
||||||
&button_light_timeout,
|
&button_light_timeout,
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
|
||||||
|
&buttonlight_brightness
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -713,6 +713,9 @@ void settings_apply(void)
|
||||||
#ifdef HAVE_BUTTON_LIGHT
|
#ifdef HAVE_BUTTON_LIGHT
|
||||||
button_backlight_set_timeout(global_settings.button_light_timeout);
|
button_backlight_set_timeout(global_settings.button_light_timeout);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
|
||||||
|
buttonlight_set_brightness(global_settings.buttonlight_brightness);
|
||||||
|
#endif
|
||||||
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
|
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
|
||||||
backlight_set_brightness(global_settings.brightness);
|
backlight_set_brightness(global_settings.brightness);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -720,6 +720,9 @@ struct user_settings
|
||||||
#ifdef HAVE_BUTTON_LIGHT
|
#ifdef HAVE_BUTTON_LIGHT
|
||||||
int button_light_timeout;
|
int button_light_timeout;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
|
||||||
|
int buttonlight_brightness;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/** global variables **/
|
/** global variables **/
|
||||||
|
|
|
||||||
|
|
@ -1183,6 +1183,11 @@ const struct settings_list settings[] = {
|
||||||
0, 18, 1, backlight_formatter, backlight_getlang,
|
0, 18, 1, backlight_formatter, backlight_getlang,
|
||||||
button_backlight_set_timeout),
|
button_backlight_set_timeout),
|
||||||
#endif
|
#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);
|
const int nb_settings = sizeof(settings)/sizeof(*settings);
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,14 @@ static inline void __backlight_set_brightness(int val)
|
||||||
(void)val;
|
(void)val;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
|
||||||
|
static inline void __buttonlight_set_brightness(int val)
|
||||||
|
{
|
||||||
|
(void)val;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* SIMULATOR */
|
#endif /* SIMULATOR */
|
||||||
|
|
||||||
#if defined(HAVE_BACKLIGHT) && !defined(BOOTLOADER)
|
#if defined(HAVE_BACKLIGHT) && !defined(BOOTLOADER)
|
||||||
|
|
@ -846,6 +854,18 @@ void backlight_set_brightness(int val)
|
||||||
}
|
}
|
||||||
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
|
#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)
|
#else /* !defined(HAVE_BACKLIGHT) || defined(BOOTLOADER)
|
||||||
-- no backlight, empty dummy functions */
|
-- no backlight, empty dummy functions */
|
||||||
|
|
||||||
|
|
@ -871,4 +891,7 @@ bool is_remote_backlight_on(void) {return true;}
|
||||||
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
|
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
|
||||||
void backlight_set_brightness(int val) { (void)val; }
|
void backlight_set_brightness(int val) { (void)val; }
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
|
||||||
|
void buttonlight_set_brightness(int val) { (void)val; }
|
||||||
|
#endif
|
||||||
#endif /* defined(HAVE_BACKLIGHT) && !defined(BOOTLOADER) */
|
#endif /* defined(HAVE_BACKLIGHT) && !defined(BOOTLOADER) */
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,10 @@ void sim_remote_backlight(int value);
|
||||||
void backlight_set_brightness(int val);
|
void backlight_set_brightness(int val);
|
||||||
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
|
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
|
||||||
|
|
||||||
|
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
|
||||||
|
void buttonlight_set_brightness(int val);
|
||||||
|
#endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
|
||||||
|
|
||||||
#ifdef HAVE_BUTTON_LIGHT
|
#ifdef HAVE_BUTTON_LIGHT
|
||||||
void button_backlight_on(void);
|
void button_backlight_on(void);
|
||||||
void button_backlight_off(void);
|
void button_backlight_off(void);
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,8 @@
|
||||||
|
|
||||||
#define HAVE_BACKLIGHT_BRIGHTNESS
|
#define HAVE_BACKLIGHT_BRIGHTNESS
|
||||||
|
|
||||||
|
#define HAVE_BUTTONLIGHT_BRIGHTNESS
|
||||||
|
|
||||||
/* Main LCD backlight brightness range and defaults */
|
/* Main LCD backlight brightness range and defaults */
|
||||||
#define MIN_BRIGHTNESS_SETTING 0 /* 0.5 mA */
|
#define MIN_BRIGHTNESS_SETTING 0 /* 0.5 mA */
|
||||||
#define MAX_DIM_BRIGHTNESS_SETTING 15 /* highest 'dimness' */
|
#define MAX_DIM_BRIGHTNESS_SETTING 15 /* highest 'dimness' */
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
static void led_control_service(void);
|
static void led_control_service(void);
|
||||||
static unsigned short backlight_brightness;
|
static unsigned short backlight_brightness;
|
||||||
|
static unsigned short buttonlight_brightness;
|
||||||
static unsigned short backlight_target;
|
static unsigned short backlight_target;
|
||||||
static unsigned short buttonlight_target;
|
static unsigned short buttonlight_target;
|
||||||
|
|
||||||
|
|
@ -57,6 +58,7 @@ enum buttonlight_states
|
||||||
BUTTONLIGHT_CONTROL_IDLE,
|
BUTTONLIGHT_CONTROL_IDLE,
|
||||||
BUTTONLIGHT_CONTROL_OFF,
|
BUTTONLIGHT_CONTROL_OFF,
|
||||||
BUTTONLIGHT_CONTROL_ON,
|
BUTTONLIGHT_CONTROL_ON,
|
||||||
|
BUTTONLIGHT_CONTROL_SET,
|
||||||
BUTTONLIGHT_CONTROL_FADE,
|
BUTTONLIGHT_CONTROL_FADE,
|
||||||
} buttonlight_control;
|
} buttonlight_control;
|
||||||
|
|
||||||
|
|
@ -214,10 +216,15 @@ static void led_control_service(void)
|
||||||
break;
|
break;
|
||||||
case BUTTONLIGHT_CONTROL_ON:
|
case BUTTONLIGHT_CONTROL_ON:
|
||||||
sc606_changed=true;
|
sc606_changed=true;
|
||||||
sc606regBval=sc606regCval=backlight_brightness;
|
sc606regBval=sc606regCval=buttonlight_brightness;
|
||||||
sc606regCONFval |= 0x3C;
|
sc606regCONFval |= 0x3C;
|
||||||
buttonlight_control=BUTTONLIGHT_CONTROL_IDLE;
|
buttonlight_control=BUTTONLIGHT_CONTROL_IDLE;
|
||||||
break;
|
break;
|
||||||
|
case BUTTONLIGHT_CONTROL_SET:
|
||||||
|
sc606regBval=sc606regCval=buttonlight_brightness;
|
||||||
|
sc606_changed=true;
|
||||||
|
buttonlight_control = BUTTONLIGHT_CONTROL_ON;
|
||||||
|
break;
|
||||||
case BUTTONLIGHT_CONTROL_FADE:
|
case BUTTONLIGHT_CONTROL_FADE:
|
||||||
/* Was this mode set while the button light is already on/off? */
|
/* Was this mode set while the button light is already on/off? */
|
||||||
if(buttonlight_target==sc606regBval)
|
if(buttonlight_target==sc606regBval)
|
||||||
|
|
@ -288,15 +295,21 @@ static void led_control_service(void)
|
||||||
void __button_backlight_on(void)
|
void __button_backlight_on(void)
|
||||||
{
|
{
|
||||||
buttonlight_control = BUTTONLIGHT_CONTROL_IDLE;
|
buttonlight_control = BUTTONLIGHT_CONTROL_IDLE;
|
||||||
buttonlight_target = backlight_brightness;
|
buttonlight_target = buttonlight_brightness;
|
||||||
buttonlight_control = BUTTONLIGHT_CONTROL_FADE;
|
if(buttonlight_brightness==0)
|
||||||
|
buttonlight_control = BUTTONLIGHT_CONTROL_ON;
|
||||||
|
else
|
||||||
|
buttonlight_control = BUTTONLIGHT_CONTROL_FADE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __button_backlight_off(void)
|
void __button_backlight_off(void)
|
||||||
{
|
{
|
||||||
buttonlight_control = BUTTONLIGHT_CONTROL_IDLE;
|
buttonlight_control = BUTTONLIGHT_CONTROL_IDLE;
|
||||||
buttonlight_target = 0;
|
buttonlight_target = 0;
|
||||||
buttonlight_control = BUTTONLIGHT_CONTROL_FADE;
|
if(buttonlight_brightness==0)
|
||||||
|
buttonlight_control = BUTTONLIGHT_CONTROL_OFF;
|
||||||
|
else
|
||||||
|
buttonlight_control = BUTTONLIGHT_CONTROL_FADE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __backlight_dim(bool dim_now)
|
void __backlight_dim(bool dim_now)
|
||||||
|
|
@ -304,5 +317,21 @@ void __backlight_dim(bool dim_now)
|
||||||
/* dont let the interrupt tick happen */
|
/* dont let the interrupt tick happen */
|
||||||
backlight_control = BACKLIGHT_CONTROL_IDLE;
|
backlight_control = BACKLIGHT_CONTROL_IDLE;
|
||||||
backlight_target = (dim_now == true) ? 0 : backlight_brightness;
|
backlight_target = (dim_now == true) ? 0 : backlight_brightness;
|
||||||
backlight_control = BACKLIGHT_CONTROL_FADE;
|
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…
Add table
Add a link
Reference in a new issue