diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/backlight.c | 23 | ||||
-rw-r--r-- | firmware/export/backlight.h | 4 | ||||
-rw-r--r-- | firmware/export/config-gigabeat.h | 2 | ||||
-rw-r--r-- | firmware/target/arm/s3c2440/gigabeat-fx/backlight-meg-fx.c | 39 |
4 files changed, 63 insertions, 5 deletions
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; } |