diff options
Diffstat (limited to 'firmware/target/arm/as3525/sansa-c200v2/backlight-c200v2.c')
-rw-r--r-- | firmware/target/arm/as3525/sansa-c200v2/backlight-c200v2.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/firmware/target/arm/as3525/sansa-c200v2/backlight-c200v2.c b/firmware/target/arm/as3525/sansa-c200v2/backlight-c200v2.c index d38c068ca2..e094cca8fe 100644 --- a/firmware/target/arm/as3525/sansa-c200v2/backlight-c200v2.c +++ b/firmware/target/arm/as3525/sansa-c200v2/backlight-c200v2.c | |||
@@ -27,6 +27,32 @@ | |||
27 | #include "as3514.h" | 27 | #include "as3514.h" |
28 | 28 | ||
29 | int buttonlight_is_on = 0; | 29 | int buttonlight_is_on = 0; |
30 | int backlight_is_on = 0; | ||
31 | static int backlight_level = 0; | ||
32 | |||
33 | /* logarithmic lookup table for brightness s*/ | ||
34 | static const int brightness_table[MAX_BRIGHTNESS_SETTING+1] = { | ||
35 | 0, 21, 47, 78, 118, 165, 224, 296, 386, 495, 630, 796, 1000 | ||
36 | }; | ||
37 | |||
38 | static void _ll_backlight_on(void) | ||
39 | { | ||
40 | GPIOA_PIN(5) = 1<<5; | ||
41 | } | ||
42 | |||
43 | static void _ll_backlight_off(void) | ||
44 | { | ||
45 | GPIOA_PIN(5) = 0; | ||
46 | } | ||
47 | |||
48 | void _backlight_pwm(int on) | ||
49 | { | ||
50 | if (on) { | ||
51 | _ll_backlight_on(); | ||
52 | } else { | ||
53 | _ll_backlight_off(); | ||
54 | } | ||
55 | } | ||
30 | 56 | ||
31 | bool _backlight_init(void) | 57 | bool _backlight_init(void) |
32 | { | 58 | { |
@@ -36,6 +62,8 @@ bool _backlight_init(void) | |||
36 | 62 | ||
37 | void _backlight_set_brightness(int brightness) | 63 | void _backlight_set_brightness(int brightness) |
38 | { | 64 | { |
65 | backlight_level = brightness_table[brightness]; | ||
66 | |||
39 | if (brightness > 0) | 67 | if (brightness > 0) |
40 | _backlight_on(); | 68 | _backlight_on(); |
41 | else | 69 | else |
@@ -47,12 +75,17 @@ void _backlight_on(void) | |||
47 | #ifdef HAVE_LCD_ENABLE | 75 | #ifdef HAVE_LCD_ENABLE |
48 | lcd_enable(true); /* power on lcd + visible display */ | 76 | lcd_enable(true); /* power on lcd + visible display */ |
49 | #endif | 77 | #endif |
50 | GPIOA_PIN(5) = 1<<5; | 78 | if (!backlight_is_on) |
79 | _ll_backlight_on(); | ||
80 | _set_timer2_pwm_ratio(backlight_level); | ||
81 | backlight_is_on = 1; | ||
51 | } | 82 | } |
52 | 83 | ||
53 | void _backlight_off(void) | 84 | void _backlight_off(void) |
54 | { | 85 | { |
55 | GPIOA_PIN(5) = 0; | 86 | backlight_is_on = 0; |
87 | _set_timer2_pwm_ratio(0); | ||
88 | _ll_backlight_off(); | ||
56 | #ifdef HAVE_LCD_ENABLE | 89 | #ifdef HAVE_LCD_ENABLE |
57 | lcd_enable(false); /* power off visible display */ | 90 | lcd_enable(false); /* power off visible display */ |
58 | #endif | 91 | #endif |