diff options
Diffstat (limited to 'firmware')
6 files changed, 492 insertions, 49 deletions
diff --git a/firmware/target/arm/gigabeat/meg-fx/ata-meg-fx.c b/firmware/target/arm/gigabeat/meg-fx/ata-meg-fx.c index d098d83de0..5e0fd8429c 100644 --- a/firmware/target/arm/gigabeat/meg-fx/ata-meg-fx.c +++ b/firmware/target/arm/gigabeat/meg-fx/ata-meg-fx.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include "pcf50606.h" | 26 | #include "pcf50606.h" |
27 | #include "ata-target.h" | 27 | #include "ata-target.h" |
28 | #include "mmu-meg-fx.h" | 28 | #include "mmu-meg-fx.h" |
29 | #include "backlight-target.h" | ||
29 | 30 | ||
30 | void ata_reset(void) | 31 | void ata_reset(void) |
31 | { | 32 | { |
@@ -54,6 +55,8 @@ void ata_device_init(void) | |||
54 | 55 | ||
55 | void copy_read_sectors(unsigned char* buf, int wordcount) | 56 | void copy_read_sectors(unsigned char* buf, int wordcount) |
56 | { | 57 | { |
58 | __buttonlight_flicker(DEFAULT_BRIGHTNESS_SETTING); | ||
59 | |||
57 | /* Unaligned transfer - slow copy */ | 60 | /* Unaligned transfer - slow copy */ |
58 | if ( (unsigned long)buf & 1) | 61 | if ( (unsigned long)buf & 1) |
59 | { /* not 16-bit aligned, copy byte by byte */ | 62 | { /* not 16-bit aligned, copy byte by byte */ |
diff --git a/firmware/target/arm/gigabeat/meg-fx/backlight-meg-fx.c b/firmware/target/arm/gigabeat/meg-fx/backlight-meg-fx.c index 12a5b55a3c..173d2ce38b 100644 --- a/firmware/target/arm/gigabeat/meg-fx/backlight-meg-fx.c +++ b/firmware/target/arm/gigabeat/meg-fx/backlight-meg-fx.c | |||
@@ -24,45 +24,100 @@ | |||
24 | #include "lcd.h" | 24 | #include "lcd.h" |
25 | #include "sc606-meg-fx.h" | 25 | #include "sc606-meg-fx.h" |
26 | 26 | ||
27 | #define FLICKER_PERIOD 15 | ||
28 | #define BUTTONLIGHT_MENU (SC606_LED_B1) | ||
29 | #define BUTTONLIGHT_ALL (SC606_LED_B1 | SC606_LED_B2 | SC606_LED_C1 | SC606_LED_C2) | ||
27 | 30 | ||
28 | static void backlight_fade_service(void); | 31 | static void led_control_service(void); |
29 | static unsigned short backlight_brightness; | 32 | static unsigned short backlight_brightness; |
30 | static unsigned short backlight_fading; | ||
31 | static unsigned short backlight_current; | 33 | static unsigned short backlight_current; |
32 | static unsigned short backlight_target; | 34 | static unsigned short backlight_target; |
33 | static unsigned short time_til_fade; | 35 | static unsigned short time_til_fade; |
34 | static unsigned short fade_interval; | 36 | static unsigned short fade_interval; |
37 | static unsigned char backlight_leds; | ||
38 | |||
39 | |||
40 | static enum backlight_states | ||
41 | { | ||
42 | BACKLIGHT_CONTROL_IDLE, | ||
43 | BACKLIGHT_CONTROL_OFF, | ||
44 | BACKLIGHT_CONTROL_ON, | ||
45 | BACKLIGHT_CONTROL_SET, | ||
46 | BACKLIGHT_CONTROL_FADE_OFF, | ||
47 | BACKLIGHT_CONTROL_FADE_ON, | ||
48 | BACKLIGHT_CONTROL_FADE_ON_FROM_OFF | ||
49 | } backlight_control; | ||
50 | |||
51 | |||
52 | |||
53 | enum buttonlight_states | ||
54 | { | ||
55 | /* turn button lights off */ | ||
56 | BUTTONLIGHT_MODE_OFF_ENTRY, | ||
57 | BUTTONLIGHT_MODE_OFF, | ||
58 | |||
59 | /* turns button lights on to same brightness as backlight */ | ||
60 | BUTTONLIGHT_MODE_ON_ENTRY, | ||
61 | BUTTONLIGHT_MODE_ON, | ||
62 | |||
63 | /* turns button lights on to minimum */ | ||
64 | BUTTONLIGHT_MODE_FAINT_ENTRY, | ||
65 | BUTTONLIGHT_MODE_FAINT, | ||
66 | |||
67 | /* allows button lights to flicker when triggered */ | ||
68 | BUTTONLIGHT_MODE_FLICKER_ENTRY, | ||
69 | BUTTONLIGHT_MODE_FLICKER, | ||
70 | BUTTONLIGHT_MODE_FLICKERING, | ||
71 | |||
72 | /* button lights glow */ | ||
73 | BUTTONLIGHT_MODE_GLOW_ENTRY, | ||
74 | BUTTONLIGHT_MODE_GLOW, | ||
75 | |||
76 | /* internal use only */ | ||
77 | BUTTONLIGHT_HELPER_SET, | ||
78 | BUTTONLIGHT_HELPER_SET_FINAL, | ||
79 | }; | ||
35 | 80 | ||
36 | 81 | ||
37 | static int confval = SC606_LOW_FREQ; | 82 | |
83 | static char buttonlight_leds; | ||
84 | static unsigned short buttonlight_setting; | ||
85 | static unsigned short buttonlight_current; | ||
86 | static unsigned char buttonlight_selected; | ||
87 | static enum buttonlight_states buttonlight_state; | ||
88 | static enum buttonlight_states buttonlight_saved_state; | ||
89 | static unsigned short buttonlight_flickering; | ||
90 | static unsigned short buttonlight_flicker_now; | ||
91 | static unsigned short buttonlight_flicker_brightness; | ||
92 | |||
38 | 93 | ||
39 | 94 | ||
40 | 95 | ||
41 | void __backlight_init(void) | 96 | void __backlight_init(void) |
42 | { | 97 | { |
43 | backlight_fading = false; | 98 | backlight_control = BACKLIGHT_CONTROL_IDLE; |
99 | |||
100 | backlight_current = DEFAULT_BRIGHTNESS_SETTING; | ||
44 | 101 | ||
45 | /* current is from settings */ | 102 | buttonlight_state = BUTTONLIGHT_MODE_OFF; |
46 | backlight_current = 50; | 103 | |
104 | buttonlight_selected = 0x04; | ||
47 | 105 | ||
48 | /* put the fade tick on the list */ | 106 | /* put the led control on the tick list */ |
49 | tick_add_task(backlight_fade_service); | 107 | tick_add_task(led_control_service); |
50 | } | 108 | } |
51 | 109 | ||
52 | 110 | ||
53 | 111 | ||
54 | void __backlight_on(void) | 112 | void __backlight_on(void) |
55 | { | 113 | { |
56 | confval |= (SC606_LED_A1 | SC606_LED_A2); | 114 | backlight_control = BACKLIGHT_CONTROL_ON; |
57 | sc606_write(SC606_REG_CONF, confval); | ||
58 | } | 115 | } |
59 | 116 | ||
60 | 117 | ||
61 | |||
62 | void __backlight_off(void) | 118 | void __backlight_off(void) |
63 | { | 119 | { |
64 | confval &= ~(SC606_LED_A1 | SC606_LED_A2); | 120 | backlight_control = BACKLIGHT_CONTROL_OFF; |
65 | sc606_write(SC606_REG_CONF, confval); | ||
66 | } | 121 | } |
67 | 122 | ||
68 | 123 | ||
@@ -71,46 +126,350 @@ void __backlight_off(void) | |||
71 | void __backlight_set_brightness(int brightness) | 126 | void __backlight_set_brightness(int brightness) |
72 | { | 127 | { |
73 | /* stop the interrupt from messing us up */ | 128 | /* stop the interrupt from messing us up */ |
74 | backlight_fading = false; | 129 | backlight_control = BACKLIGHT_CONTROL_IDLE; |
75 | 130 | ||
76 | backlight_brightness = brightness; | 131 | backlight_brightness = brightness + 1; |
77 | 132 | ||
78 | /* only set the brightness if it is different from the current */ | 133 | /* only set the brightness if it is different from the current */ |
79 | if (backlight_brightness != backlight_current) | 134 | if (backlight_brightness != backlight_current) |
80 | { | 135 | { |
81 | backlight_target = brightness; | 136 | backlight_control = BACKLIGHT_CONTROL_SET; |
82 | fade_interval = time_til_fade = 1; | ||
83 | backlight_fading = true; | ||
84 | } | 137 | } |
85 | } | 138 | } |
86 | 139 | ||
87 | 140 | ||
88 | 141 | ||
89 | static void backlight_fade_service(void) | 142 | /* only works if the buttonlight mode is set to flicker */ |
143 | void __buttonlight_flicker(unsigned short brightness) | ||
90 | { | 144 | { |
91 | if (!backlight_fading || --time_til_fade) return; | 145 | /* clip the setting */ |
92 | 146 | if (brightness > MAX_BRIGHTNESS_SETTING) | |
93 | if (backlight_target > backlight_current) | ||
94 | { | 147 | { |
95 | backlight_current++; | 148 | brightness = MAX_BRIGHTNESS_SETTING; |
96 | } | 149 | } |
97 | else | 150 | |
151 | /* add one because we subtract later for full range */ | ||
152 | buttonlight_flicker_brightness = brightness + 1; | ||
153 | buttonlight_flicker_now = 1; | ||
154 | } | ||
155 | |||
156 | |||
157 | |||
158 | /* select which LEDs light up | ||
159 | * The only pleasing combinations are: only menu/power or all LEDs | ||
160 | */ | ||
161 | void __buttonlight_select(enum buttonlight_selection selection) | ||
162 | { | ||
163 | switch (selection) | ||
98 | { | 164 | { |
99 | backlight_current--; | 165 | default: |
166 | case BUTTONLIGHT_LED_MENU: | ||
167 | buttonlight_selected = BUTTONLIGHT_MENU; | ||
168 | break; | ||
169 | |||
170 | case BUTTONLIGHT_LED_ALL: | ||
171 | buttonlight_selected = BUTTONLIGHT_ALL; | ||
172 | break; | ||
100 | } | 173 | } |
174 | } | ||
101 | 175 | ||
102 | /* The SC606 LED driver can set the brightness in 64 steps */ | ||
103 | sc606_write(SC606_REG_A, backlight_current); | ||
104 | 176 | ||
105 | 177 | ||
106 | /* have we hit the target? */ | 178 | /* map the mode from the command into the state machine entries */ |
107 | if (backlight_current == backlight_target) | 179 | void __buttonlight_mode(enum buttonlight_mode mode) |
180 | { | ||
181 | switch (mode) | ||
108 | { | 182 | { |
109 | backlight_fading = false; | 183 | case BUTTONLIGHT_OFF: |
184 | buttonlight_state = BUTTONLIGHT_MODE_OFF_ENTRY; | ||
185 | break; | ||
186 | |||
187 | case BUTTONLIGHT_ON: | ||
188 | buttonlight_state = BUTTONLIGHT_MODE_ON_ENTRY; | ||
189 | break; | ||
190 | |||
191 | case BUTTONLIGHT_FAINT: | ||
192 | buttonlight_state = BUTTONLIGHT_MODE_FAINT_ENTRY; | ||
193 | break; | ||
194 | |||
195 | case BUTTONLIGHT_FLICKER: | ||
196 | buttonlight_state = BUTTONLIGHT_MODE_FLICKER_ENTRY; | ||
197 | break; | ||
198 | |||
199 | default: | ||
200 | return; /* unknown mode */ | ||
110 | } | 201 | } |
111 | else | 202 | |
203 | |||
204 | } | ||
205 | |||
206 | |||
207 | |||
208 | /* | ||
209 | * The button lights have 'modes' of operation. Each mode must setup and | ||
210 | * execute its own operation - taking care that this is all done in an ISR. | ||
211 | * | ||
212 | */ | ||
213 | |||
214 | |||
215 | |||
216 | /* led_control_service runs in interrupt context - be brief! | ||
217 | * This service is called once per interrupt timer tick - 100 times a second. | ||
218 | * | ||
219 | * There should be at most only one i2c operation per call - if more are need | ||
220 | * the calls should be spread across calls. | ||
221 | * | ||
222 | * Putting all led servicing in one thread means that we wont step on any | ||
223 | * i2c operations - they are all serialized here in the ISR tick. It also | ||
224 | * insures that we get called at equal timing for good visual effect. | ||
225 | * | ||
226 | * The buttonlight service runs only after all backlight services have finished. | ||
227 | * Fading the buttonlights is possible, but not recommended because of the | ||
228 | * additional calls needed during the ISR | ||
229 | */ | ||
230 | static void led_control_service(void) | ||
231 | { | ||
232 | switch (backlight_control) | ||
112 | { | 233 | { |
113 | time_til_fade = fade_interval; | 234 | case BACKLIGHT_CONTROL_IDLE: |
235 | switch (buttonlight_state) | ||
236 | { | ||
237 | /* Buttonlight mode: OFF */ | ||
238 | case BUTTONLIGHT_MODE_OFF_ENTRY: | ||
239 | if (buttonlight_current) | ||
240 | { | ||
241 | buttonlight_leds = 0x00; | ||
242 | sc606_write(SC606_REG_CONF, backlight_leds); | ||
243 | buttonlight_current = 0; | ||
244 | } | ||
245 | buttonlight_state = BUTTONLIGHT_MODE_OFF; | ||
246 | break; | ||
247 | |||
248 | case BUTTONLIGHT_MODE_OFF: | ||
249 | break; | ||
250 | |||
251 | |||
252 | /* Buttonlight mode: ON */ | ||
253 | case BUTTONLIGHT_MODE_ON_ENTRY: | ||
254 | case BUTTONLIGHT_MODE_ON: | ||
255 | if (buttonlight_current != backlight_brightness || | ||
256 | (buttonlight_leds != buttonlight_selected)) | ||
257 | { | ||
258 | buttonlight_leds = buttonlight_selected; | ||
259 | sc606_write(SC606_REG_CONF, backlight_leds | buttonlight_leds); | ||
260 | |||
261 | /* temporary save for the next mode - then to do settings */ | ||
262 | buttonlight_setting = backlight_brightness; | ||
263 | buttonlight_saved_state = BUTTONLIGHT_MODE_ON; | ||
264 | buttonlight_state = BUTTONLIGHT_HELPER_SET; | ||
265 | } | ||
266 | break; | ||
267 | |||
268 | |||
269 | /* Buttonlight mode: Faint */ | ||
270 | case BUTTONLIGHT_MODE_FAINT_ENTRY: | ||
271 | if (buttonlight_current != 1) | ||
272 | { | ||
273 | /* need to turn on the backlight? */ | ||
274 | if (buttonlight_current == 0) | ||
275 | { | ||
276 | buttonlight_leds = buttonlight_selected; | ||
277 | sc606_write(SC606_REG_CONF, backlight_leds | buttonlight_leds); | ||
278 | } | ||
279 | |||
280 | /* temporary save for the next mode - then to do settings */ | ||
281 | buttonlight_setting = 1; | ||
282 | buttonlight_saved_state = BUTTONLIGHT_MODE_FAINT; | ||
283 | buttonlight_state = BUTTONLIGHT_HELPER_SET; | ||
284 | } | ||
285 | break; | ||
286 | |||
287 | case BUTTONLIGHT_MODE_FAINT: | ||
288 | /* watch for change in led selction */ | ||
289 | if (buttonlight_leds != buttonlight_selected) | ||
290 | { | ||
291 | buttonlight_leds = buttonlight_selected; | ||
292 | sc606_write(SC606_REG_CONF, backlight_leds | buttonlight_leds); | ||
293 | } | ||
294 | |||
295 | break; | ||
296 | |||
297 | |||
298 | /* Buttonlight mode: FLICKER */ | ||
299 | case BUTTONLIGHT_MODE_FLICKER_ENTRY: | ||
300 | /* already on? turn it off */ | ||
301 | if (buttonlight_current) | ||
302 | { | ||
303 | buttonlight_leds = 0x00; | ||
304 | sc606_write(SC606_REG_CONF, backlight_leds); | ||
305 | buttonlight_current = 0; | ||
306 | } | ||
307 | |||
308 | /* set the brightness if not already set */ | ||
309 | if (buttonlight_current != buttonlight_flicker_brightness) | ||
310 | { | ||
311 | /* temporary save for the next mode - then to do settings */ | ||
312 | buttonlight_setting = buttonlight_flicker_brightness; | ||
313 | buttonlight_saved_state = BUTTONLIGHT_MODE_FLICKER; | ||
314 | buttonlight_state = BUTTONLIGHT_HELPER_SET; | ||
315 | } | ||
316 | break; | ||
317 | |||
318 | |||
319 | case BUTTONLIGHT_MODE_FLICKER: | ||
320 | /* wait for the foreground to trigger flickering */ | ||
321 | if (buttonlight_flicker_now) | ||
322 | { | ||
323 | /* turn them on */ | ||
324 | buttonlight_leds = buttonlight_selected; | ||
325 | buttonlight_current = buttonlight_setting; | ||
326 | sc606_write(SC606_REG_CONF, backlight_leds | buttonlight_leds); | ||
327 | |||
328 | /* reset the trigger and go flicker the LEDs */ | ||
329 | buttonlight_flicker_now = 0; | ||
330 | buttonlight_flickering = FLICKER_PERIOD; | ||
331 | buttonlight_state = BUTTONLIGHT_MODE_FLICKERING; | ||
332 | } | ||
333 | break; | ||
334 | |||
335 | |||
336 | case BUTTONLIGHT_MODE_FLICKERING: | ||
337 | /* flicker the LEDs for as long as we get triggered */ | ||
338 | if (buttonlight_flickering) | ||
339 | { | ||
340 | /* turn the leds off if they are on */ | ||
341 | if (buttonlight_current) | ||
342 | { | ||
343 | buttonlight_leds = 0x00; | ||
344 | sc606_write(SC606_REG_CONF, backlight_leds); | ||
345 | buttonlight_current = 0; | ||
346 | } | ||
347 | |||
348 | buttonlight_flickering--; | ||
349 | } | ||
350 | else | ||
351 | { | ||
352 | /* is flickering triggered again? */ | ||
353 | if (!buttonlight_flicker_now) | ||
354 | { | ||
355 | /* completed a cycle - no new triggers - go back and wait */ | ||
356 | buttonlight_state = BUTTONLIGHT_MODE_FLICKER; | ||
357 | } | ||
358 | else | ||
359 | { | ||
360 | /* reset flickering */ | ||
361 | buttonlight_flicker_now = 0; | ||
362 | buttonlight_flickering = FLICKER_PERIOD; | ||
363 | |||
364 | /* turn buttonlights on */ | ||
365 | buttonlight_leds = buttonlight_selected; | ||
366 | buttonlight_current = buttonlight_setting; | ||
367 | sc606_write(SC606_REG_CONF, backlight_leds | buttonlight_leds); | ||
368 | } | ||
369 | } | ||
370 | break; | ||
371 | |||
372 | /* set the brightness for the buttonlights - takes 2 passes */ | ||
373 | case BUTTONLIGHT_HELPER_SET: | ||
374 | sc606_write(SC606_REG_B, buttonlight_setting-1); | ||
375 | buttonlight_state = BUTTONLIGHT_HELPER_SET_FINAL; | ||
376 | break; | ||
377 | |||
378 | case BUTTONLIGHT_HELPER_SET_FINAL: | ||
379 | sc606_write(SC606_REG_C, buttonlight_setting-1); | ||
380 | buttonlight_current = buttonlight_setting; | ||
381 | buttonlight_state = buttonlight_saved_state; | ||
382 | break; | ||
383 | |||
384 | default: | ||
385 | break; | ||
386 | |||
387 | } | ||
388 | break; | ||
389 | |||
390 | |||
391 | case BACKLIGHT_CONTROL_FADE_ON_FROM_OFF: | ||
392 | backlight_leds = 0x03; | ||
393 | sc606_write(SC606_REG_CONF, 0x03 | buttonlight_leds); | ||
394 | backlight_control = BACKLIGHT_CONTROL_FADE_ON; | ||
395 | break; | ||
396 | |||
397 | |||
398 | case BACKLIGHT_CONTROL_OFF: | ||
399 | backlight_current = 0; | ||
400 | backlight_leds = 0x00; | ||
401 | sc606_write(SC606_REG_CONF, buttonlight_leds); | ||
402 | backlight_control = BACKLIGHT_CONTROL_IDLE; | ||
403 | break; | ||
404 | |||
405 | |||
406 | case BACKLIGHT_CONTROL_ON: | ||
407 | backlight_leds = 0x03; | ||
408 | sc606_write(SC606_REG_CONF, 0x03 | buttonlight_leds); | ||
409 | backlight_current = backlight_brightness; | ||
410 | backlight_control = BACKLIGHT_CONTROL_IDLE; | ||
411 | break; | ||
412 | |||
413 | |||
414 | case BACKLIGHT_CONTROL_SET: | ||
415 | /* The SC606 LED driver can set the brightness in 64 steps */ | ||
416 | sc606_write(SC606_REG_A, backlight_brightness-1); | ||
417 | |||
418 | /* if we were turned off - turn the backlight on */ | ||
419 | if (backlight_current) | ||
420 | { | ||
421 | backlight_current = backlight_brightness; | ||
422 | backlight_control = BACKLIGHT_CONTROL_IDLE; | ||
423 | } | ||
424 | else | ||
425 | { | ||
426 | backlight_control = BACKLIGHT_CONTROL_ON; | ||
427 | } | ||
428 | break; | ||
429 | |||
430 | |||
431 | case BACKLIGHT_CONTROL_FADE_ON: | ||
432 | if (--time_til_fade) return; | ||
433 | |||
434 | /* The SC606 LED driver can set the brightness in 64 steps */ | ||
435 | sc606_write(SC606_REG_A, backlight_current++); | ||
436 | |||
437 | /* have we hit the target? */ | ||
438 | if (backlight_current == backlight_target) | ||
439 | { | ||
440 | backlight_control = BACKLIGHT_CONTROL_IDLE; | ||
441 | } | ||
442 | else | ||
443 | { | ||
444 | time_til_fade = fade_interval; | ||
445 | } | ||
446 | break; | ||
447 | |||
448 | |||
449 | case BACKLIGHT_CONTROL_FADE_OFF: | ||
450 | if (--time_til_fade) return; | ||
451 | |||
452 | /* The SC606 LED driver can set the brightness in 64 steps */ | ||
453 | sc606_write(SC606_REG_A, --backlight_current); | ||
454 | |||
455 | /* have we hit the target? */ | ||
456 | if (backlight_current == backlight_target) | ||
457 | { | ||
458 | if (backlight_current) | ||
459 | { | ||
460 | backlight_control = BACKLIGHT_CONTROL_IDLE; | ||
461 | } | ||
462 | else | ||
463 | { | ||
464 | backlight_control = BACKLIGHT_CONTROL_OFF; | ||
465 | } | ||
466 | |||
467 | } | ||
468 | else | ||
469 | { | ||
470 | time_til_fade = fade_interval; | ||
471 | } | ||
472 | break; | ||
114 | } | 473 | } |
115 | 474 | ||
116 | } | 475 | } |
@@ -121,10 +480,10 @@ static void backlight_fade_service(void) | |||
121 | 480 | ||
122 | void __backlight_dim(bool dim_now) | 481 | void __backlight_dim(bool dim_now) |
123 | { | 482 | { |
124 | int target; | 483 | unsigned short target; |
125 | 484 | ||
126 | /* dont let the interrupt tick happen */ | 485 | /* dont let the interrupt tick happen */ |
127 | backlight_fading = false; | 486 | backlight_control = BACKLIGHT_CONTROL_IDLE; |
128 | 487 | ||
129 | target = (dim_now == true) ? 0 : backlight_brightness; | 488 | target = (dim_now == true) ? 0 : backlight_brightness; |
130 | 489 | ||
@@ -135,17 +494,52 @@ void __backlight_dim(bool dim_now) | |||
135 | 494 | ||
136 | if (backlight_current > backlight_target) | 495 | if (backlight_current > backlight_target) |
137 | { | 496 | { |
138 | fade_interval = 4; | 497 | time_til_fade = fade_interval = 4; |
498 | backlight_control = BACKLIGHT_CONTROL_FADE_OFF; | ||
139 | } | 499 | } |
140 | else | 500 | else |
141 | { | 501 | { |
142 | fade_interval = 1; | 502 | time_til_fade = fade_interval = 1; |
503 | if (backlight_current) | ||
504 | { | ||
505 | backlight_control = BACKLIGHT_CONTROL_FADE_ON; | ||
506 | } | ||
507 | else | ||
508 | { | ||
509 | backlight_control = BACKLIGHT_CONTROL_FADE_ON_FROM_OFF; | ||
510 | } | ||
143 | } | 511 | } |
144 | |||
145 | /* let the tick work */ | ||
146 | time_til_fade = fade_interval; | ||
147 | backlight_fading = true; | ||
148 | } | 512 | } |
149 | 513 | ||
150 | } | 514 | } |
151 | 515 | ||
516 | |||
517 | |||
518 | |||
519 | #define BACKLIGHT_BUTTONS_OFF 0 | ||
520 | #define BACKLIGHT_BUTTONS_ON 1 | ||
521 | #define BACKLIGHT_BUTTONS_FAINT 2 | ||
522 | #define BACKLIGHT_BUTTONS_FOLLOW 3 | ||
523 | |||
524 | |||
525 | void __backlight_buttons(int value) | ||
526 | { | ||
527 | switch (value) | ||
528 | { | ||
529 | default: | ||
530 | case BACKLIGHT_BUTTONS_OFF: | ||
531 | break; | ||
532 | |||
533 | case BACKLIGHT_BUTTONS_ON: | ||
534 | break; | ||
535 | |||
536 | case BACKLIGHT_BUTTONS_FAINT: | ||
537 | break; | ||
538 | |||
539 | case BACKLIGHT_BUTTONS_FOLLOW: | ||
540 | break; | ||
541 | |||
542 | } | ||
543 | |||
544 | } | ||
545 | |||
diff --git a/firmware/target/arm/gigabeat/meg-fx/backlight-target.h b/firmware/target/arm/gigabeat/meg-fx/backlight-target.h index c53d00d8de..67a055449c 100644 --- a/firmware/target/arm/gigabeat/meg-fx/backlight-target.h +++ b/firmware/target/arm/gigabeat/meg-fx/backlight-target.h | |||
@@ -19,11 +19,55 @@ | |||
19 | #ifndef BACKLIGHT_TARGET_H | 19 | #ifndef BACKLIGHT_TARGET_H |
20 | #define BACKLIGHT_TARGET_H | 20 | #define BACKLIGHT_TARGET_H |
21 | 21 | ||
22 | |||
23 | /* select the led */ | ||
24 | enum buttonlight_selection | ||
25 | { | ||
26 | /* all leds */ | ||
27 | BUTTONLIGHT_LED_ALL, | ||
28 | |||
29 | /* only the menu/power led (two buttons for one LED) */ | ||
30 | BUTTONLIGHT_LED_MENU | ||
31 | }; | ||
32 | |||
33 | |||
34 | /* Use these to set the buttonlight mode */ | ||
35 | enum buttonlight_mode | ||
36 | { | ||
37 | /* ON follows the setting of the backlight - same brightness */ | ||
38 | BUTTONLIGHT_ON, | ||
39 | |||
40 | /* buttonlights always off */ | ||
41 | BUTTONLIGHT_OFF, | ||
42 | |||
43 | /* buttonlights always on but set at lowest brightness */ | ||
44 | BUTTONLIGHT_FAINT, | ||
45 | |||
46 | /* buttonlights flicker when triggered */ | ||
47 | BUTTONLIGHT_FLICKER, | ||
48 | }; | ||
49 | |||
50 | |||
51 | /* call to flicker the button lights */ | ||
52 | void __buttonlight_flicker(unsigned short brightness); | ||
53 | |||
54 | |||
55 | /* only use the XX__ENTRY when setting the mode */ | ||
56 | void __buttonlight_mode(enum buttonlight_mode mode); | ||
57 | |||
58 | |||
59 | /* select which led to use on the button lights. Other combinations are | ||
60 | * possible, but don't look very good. | ||
61 | */ | ||
62 | void __buttonlight_select(enum buttonlight_selection selection); | ||
63 | |||
64 | |||
22 | void __backlight_init(void); | 65 | void __backlight_init(void); |
23 | void __backlight_on(void); | 66 | void __backlight_on(void); |
24 | void __backlight_off(void); | 67 | void __backlight_off(void); |
25 | void __backlight_set_brightness(int val); | 68 | void __backlight_set_brightness(int val); |
26 | 69 | ||
70 | /* true: backlight fades off - false: backlight fades on */ | ||
27 | void __backlight_dim(bool dim); | 71 | void __backlight_dim(bool dim); |
28 | 72 | ||
29 | #endif | 73 | #endif |
diff --git a/firmware/target/arm/gigabeat/meg-fx/button-meg-fx.c b/firmware/target/arm/gigabeat/meg-fx/button-meg-fx.c index b5f18a264b..4ba6ce23f7 100644 --- a/firmware/target/arm/gigabeat/meg-fx/button-meg-fx.c +++ b/firmware/target/arm/gigabeat/meg-fx/button-meg-fx.c | |||
@@ -122,6 +122,8 @@ int button_read_device(void) | |||
122 | 122 | ||
123 | if (touchpad & (1 << 3)) | 123 | if (touchpad & (1 << 3)) |
124 | btn |= BUTTON_SELECT; | 124 | btn |= BUTTON_SELECT; |
125 | |||
126 | __buttonlight_flicker(DEFAULT_BRIGHTNESS_SETTING/2); | ||
125 | } | 127 | } |
126 | 128 | ||
127 | return btn; | 129 | return btn; |
diff --git a/firmware/target/arm/gigabeat/meg-fx/sc606-meg-fx.c b/firmware/target/arm/gigabeat/meg-fx/sc606-meg-fx.c index 654095c2f5..6ca64a0437 100644 --- a/firmware/target/arm/gigabeat/meg-fx/sc606-meg-fx.c +++ b/firmware/target/arm/gigabeat/meg-fx/sc606-meg-fx.c | |||
@@ -151,7 +151,7 @@ static unsigned char sc606_i2c_inb(void) | |||
151 | /* returns number of acks that were bad */ | 151 | /* returns number of acks that were bad */ |
152 | int sc606_write(unsigned char reg, unsigned char data) | 152 | int sc606_write(unsigned char reg, unsigned char data) |
153 | { | 153 | { |
154 | int x = 0; | 154 | int x; |
155 | 155 | ||
156 | sc606_i2c_start(); | 156 | sc606_i2c_start(); |
157 | 157 | ||
@@ -178,7 +178,7 @@ int sc606_write(unsigned char reg, unsigned char data) | |||
178 | 178 | ||
179 | int sc606_read(unsigned char reg, unsigned char* data) | 179 | int sc606_read(unsigned char reg, unsigned char* data) |
180 | { | 180 | { |
181 | int x = 0; | 181 | int x; |
182 | 182 | ||
183 | sc606_i2c_start(); | 183 | sc606_i2c_start(); |
184 | sc606_i2c_outb(SLAVE_ADDRESS); | 184 | sc606_i2c_outb(SLAVE_ADDRESS); |
diff --git a/firmware/target/arm/gigabeat/meg-fx/sc606-meg-fx.h b/firmware/target/arm/gigabeat/meg-fx/sc606-meg-fx.h index 2637c067e0..df7a654b36 100644 --- a/firmware/target/arm/gigabeat/meg-fx/sc606-meg-fx.h +++ b/firmware/target/arm/gigabeat/meg-fx/sc606-meg-fx.h | |||
@@ -13,14 +13,14 @@ | |||
13 | #define SC606_REG_C 2 | 13 | #define SC606_REG_C 2 |
14 | #define SC606_REG_CONF 3 | 14 | #define SC606_REG_CONF 3 |
15 | 15 | ||
16 | #define SC606_LED_A1 1 << 0 | 16 | #define SC606_LED_A1 (1 << 0) |
17 | #define SC606_LED_A2 1 << 1 | 17 | #define SC606_LED_A2 (1 << 1) |
18 | #define SC606_LED_B1 1 << 2 | 18 | #define SC606_LED_B1 (1 << 2) |
19 | #define SC606_LED_B2 1 << 3 | 19 | #define SC606_LED_B2 (1 << 3) |
20 | #define SC606_LED_C1 1 << 4 | 20 | #define SC606_LED_C1 (1 << 4) |
21 | #define SC606_LED_C2 1 << 5 | 21 | #define SC606_LED_C2 (1 << 5) |
22 | 22 | ||
23 | #define SC606_LOW_FREQ 1 << 6 | 23 | #define SC606_LOW_FREQ (1 << 6) |
24 | 24 | ||
25 | int sc606_write(unsigned char reg, unsigned char data); | 25 | int sc606_write(unsigned char reg, unsigned char data); |
26 | 26 | ||