diff --git a/apps/lang/english.lang b/apps/lang/english.lang index fb19485d43..e8dcf4867d 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang @@ -10775,6 +10775,23 @@ gigabeatf: "Button Light Timeout" + + id: LANG_BUTTONLIGHT_BRIGHTNESS + desc: in settings_menu + user: + + *: "" + gigabeatf: "Button Light Brightness" + + + *: "" + gigabeatf: "Button Light Brightness" + + + *: "" + gigabeatf: "Button Light Brightness" + + id: LANG_PLAYLISTVIEWER_SETTINGS desc: title for the playlist viewer settings menus diff --git a/apps/menus/settings_menu.c b/apps/menus/settings_menu.c index 528587dffb..6d962824f1 100644 --- a/apps/menus/settings_menu.c +++ b/apps/menus/settings_menu.c @@ -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 ); diff --git a/apps/settings.c b/apps/settings.c index 35a063bf96..81dbe71491 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -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 diff --git a/apps/settings.h b/apps/settings.h index 13291be3df..5e9da84bae 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -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 **/ diff --git a/apps/settings_list.c b/apps/settings_list.c index e781c51be0..d39779607d 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c @@ -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); diff --git a/firmware/backlight.c b/firmware/backlight.c index a7fab787e8..d695d1ee19 100644 --- a/firmware/backlight.c +++ b/firmware/backlight.c @@ -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) */ diff --git a/firmware/export/backlight.h b/firmware/export/backlight.h index 9bcb6e9d1d..15dfbf1ddf 100644 --- a/firmware/export/backlight.h +++ b/firmware/export/backlight.h @@ -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); diff --git a/firmware/export/config-gigabeat.h b/firmware/export/config-gigabeat.h index a83dc55fd8..5f45bdbff0 100644 --- a/firmware/export/config-gigabeat.h +++ b/firmware/export/config-gigabeat.h @@ -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' */ diff --git a/firmware/target/arm/s3c2440/gigabeat-fx/backlight-meg-fx.c b/firmware/target/arm/s3c2440/gigabeat-fx/backlight-meg-fx.c index 7b7e8518ec..40b093c689 100644 --- a/firmware/target/arm/s3c2440/gigabeat-fx/backlight-meg-fx.c +++ b/firmware/target/arm/s3c2440/gigabeat-fx/backlight-meg-fx.c @@ -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,15 +295,21 @@ static void led_control_service(void) void __button_backlight_on(void) { buttonlight_control = BUTTONLIGHT_CONTROL_IDLE; - buttonlight_target = backlight_brightness; - buttonlight_control = BUTTONLIGHT_CONTROL_FADE; + buttonlight_target = buttonlight_brightness; + if(buttonlight_brightness==0) + buttonlight_control = BUTTONLIGHT_CONTROL_ON; + else + buttonlight_control = BUTTONLIGHT_CONTROL_FADE; } void __button_backlight_off(void) { buttonlight_control = BUTTONLIGHT_CONTROL_IDLE; 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) @@ -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; - 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; }