diff options
Diffstat (limited to 'firmware/target/arm/gigabeat')
4 files changed, 260 insertions, 111 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 5e0fd8429c..8e246045e6 100644 --- a/firmware/target/arm/gigabeat/meg-fx/ata-meg-fx.c +++ b/firmware/target/arm/gigabeat/meg-fx/ata-meg-fx.c | |||
@@ -55,7 +55,7 @@ void ata_device_init(void) | |||
55 | 55 | ||
56 | void copy_read_sectors(unsigned char* buf, int wordcount) | 56 | void copy_read_sectors(unsigned char* buf, int wordcount) |
57 | { | 57 | { |
58 | __buttonlight_flicker(DEFAULT_BRIGHTNESS_SETTING); | 58 | __buttonlight_trigger(); |
59 | 59 | ||
60 | /* Unaligned transfer - slow copy */ | 60 | /* Unaligned transfer - slow copy */ |
61 | if ( (unsigned long)buf & 1) | 61 | if ( (unsigned long)buf & 1) |
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 173d2ce38b..b97e1430b2 100644 --- a/firmware/target/arm/gigabeat/meg-fx/backlight-meg-fx.c +++ b/firmware/target/arm/gigabeat/meg-fx/backlight-meg-fx.c | |||
@@ -23,6 +23,8 @@ | |||
23 | #include "backlight.h" | 23 | #include "backlight.h" |
24 | #include "lcd.h" | 24 | #include "lcd.h" |
25 | #include "sc606-meg-fx.h" | 25 | #include "sc606-meg-fx.h" |
26 | #include "power.h" | ||
27 | |||
26 | 28 | ||
27 | #define FLICKER_PERIOD 15 | 29 | #define FLICKER_PERIOD 15 |
28 | #define BUTTONLIGHT_MENU (SC606_LED_B1) | 30 | #define BUTTONLIGHT_MENU (SC606_LED_B1) |
@@ -56,7 +58,7 @@ enum buttonlight_states | |||
56 | BUTTONLIGHT_MODE_OFF_ENTRY, | 58 | BUTTONLIGHT_MODE_OFF_ENTRY, |
57 | BUTTONLIGHT_MODE_OFF, | 59 | BUTTONLIGHT_MODE_OFF, |
58 | 60 | ||
59 | /* turns button lights on to same brightness as backlight */ | 61 | /* turns button lights on to setting */ |
60 | BUTTONLIGHT_MODE_ON_ENTRY, | 62 | BUTTONLIGHT_MODE_ON_ENTRY, |
61 | BUTTONLIGHT_MODE_ON, | 63 | BUTTONLIGHT_MODE_ON, |
62 | 64 | ||
@@ -69,13 +71,23 @@ enum buttonlight_states | |||
69 | BUTTONLIGHT_MODE_FLICKER, | 71 | BUTTONLIGHT_MODE_FLICKER, |
70 | BUTTONLIGHT_MODE_FLICKERING, | 72 | BUTTONLIGHT_MODE_FLICKERING, |
71 | 73 | ||
72 | /* button lights glow */ | 74 | /* button lights solid */ |
73 | BUTTONLIGHT_MODE_GLOW_ENTRY, | 75 | BUTTONLIGHT_MODE_SOLID_ENTRY, |
74 | BUTTONLIGHT_MODE_GLOW, | 76 | BUTTONLIGHT_MODE_SOLID, |
75 | 77 | ||
78 | /* button light charing */ | ||
79 | BUTTONLIGHT_MODE_CHARGING_ENTRY, | ||
80 | BUTTONLIGHT_MODE_CHARGING, | ||
81 | BUTTONLIGHT_MODE_CHARGING_WAIT, | ||
82 | |||
76 | /* internal use only */ | 83 | /* internal use only */ |
77 | BUTTONLIGHT_HELPER_SET, | 84 | BUTTONLIGHT_HELPER_SET, |
78 | BUTTONLIGHT_HELPER_SET_FINAL, | 85 | BUTTONLIGHT_HELPER_SET_FINAL, |
86 | BUTTONLIGHT_MODE_STOP, | ||
87 | |||
88 | /* buttonlights follow the backlight settings */ | ||
89 | BUTTONLIGHT_MODE_FOLLOW_ENTRY, | ||
90 | BUTTONLIGHT_MODE_FOLLOW, | ||
79 | }; | 91 | }; |
80 | 92 | ||
81 | 93 | ||
@@ -87,10 +99,18 @@ static unsigned char buttonlight_selected; | |||
87 | static enum buttonlight_states buttonlight_state; | 99 | static enum buttonlight_states buttonlight_state; |
88 | static enum buttonlight_states buttonlight_saved_state; | 100 | static enum buttonlight_states buttonlight_saved_state; |
89 | static unsigned short buttonlight_flickering; | 101 | static unsigned short buttonlight_flickering; |
90 | static unsigned short buttonlight_flicker_now; | 102 | |
91 | static unsigned short buttonlight_flicker_brightness; | 103 | static unsigned short buttonlight_trigger_now; |
104 | static unsigned short buttonlight_trigger_brightness; | ||
105 | |||
92 | 106 | ||
93 | 107 | ||
108 | static unsigned short charging_led_index; | ||
109 | static unsigned short buttonlight_charging_counter; | ||
110 | |||
111 | #define CHARGING_LED_COUNT 60 | ||
112 | unsigned char charging_leds[] = { 0x00, 0x20, 0x38, 0x3C }; | ||
113 | |||
94 | 114 | ||
95 | 115 | ||
96 | void __backlight_init(void) | 116 | void __backlight_init(void) |
@@ -111,10 +131,12 @@ void __backlight_init(void) | |||
111 | 131 | ||
112 | void __backlight_on(void) | 132 | void __backlight_on(void) |
113 | { | 133 | { |
134 | /* now go turn the backlight on */ | ||
114 | backlight_control = BACKLIGHT_CONTROL_ON; | 135 | backlight_control = BACKLIGHT_CONTROL_ON; |
115 | } | 136 | } |
116 | 137 | ||
117 | 138 | ||
139 | |||
118 | void __backlight_off(void) | 140 | void __backlight_off(void) |
119 | { | 141 | { |
120 | backlight_control = BACKLIGHT_CONTROL_OFF; | 142 | backlight_control = BACKLIGHT_CONTROL_OFF; |
@@ -139,45 +161,45 @@ void __backlight_set_brightness(int brightness) | |||
139 | 161 | ||
140 | 162 | ||
141 | 163 | ||
142 | /* only works if the buttonlight mode is set to flicker */ | 164 | /* only works if the buttonlight mode is set to triggered mode */ |
143 | void __buttonlight_flicker(unsigned short brightness) | 165 | void __buttonlight_trigger(void) |
144 | { | 166 | { |
145 | /* clip the setting */ | 167 | buttonlight_trigger_now = 1; |
146 | if (brightness > MAX_BRIGHTNESS_SETTING) | ||
147 | { | ||
148 | brightness = MAX_BRIGHTNESS_SETTING; | ||
149 | } | ||
150 | |||
151 | /* add one because we subtract later for full range */ | ||
152 | buttonlight_flicker_brightness = brightness + 1; | ||
153 | buttonlight_flicker_now = 1; | ||
154 | } | 168 | } |
155 | 169 | ||
170 | |||
156 | 171 | ||
157 | 172 | ||
158 | /* select which LEDs light up | 173 | /* map the mode from the command into the state machine entries */ |
159 | * The only pleasing combinations are: only menu/power or all LEDs | 174 | void __buttonlight_mode(enum buttonlight_mode mode, |
160 | */ | 175 | enum buttonlight_selection selection, |
161 | void __buttonlight_select(enum buttonlight_selection selection) | 176 | unsigned short brightness) |
162 | { | 177 | { |
178 | /* choose stop to setup mode */ | ||
179 | buttonlight_state = BUTTONLIGHT_MODE_STOP; | ||
180 | |||
181 | |||
182 | /* clip brightness */ | ||
183 | if (brightness > MAX_BRIGHTNESS_SETTING) | ||
184 | { | ||
185 | brightness = MAX_BRIGHTNESS_SETTING; | ||
186 | } | ||
187 | |||
188 | brightness++; | ||
189 | |||
190 | /* Select which LEDs to use */ | ||
163 | switch (selection) | 191 | switch (selection) |
164 | { | 192 | { |
165 | default: | ||
166 | case BUTTONLIGHT_LED_MENU: | ||
167 | buttonlight_selected = BUTTONLIGHT_MENU; | ||
168 | break; | ||
169 | |||
170 | case BUTTONLIGHT_LED_ALL: | 193 | case BUTTONLIGHT_LED_ALL: |
171 | buttonlight_selected = BUTTONLIGHT_ALL; | 194 | buttonlight_selected = BUTTONLIGHT_ALL; |
172 | break; | 195 | break; |
173 | } | ||
174 | } | ||
175 | 196 | ||
197 | case BUTTONLIGHT_LED_MENU: | ||
198 | buttonlight_selected = BUTTONLIGHT_MENU; | ||
199 | break; | ||
200 | } | ||
176 | 201 | ||
177 | 202 | /* which mode to use */ | |
178 | /* map the mode from the command into the state machine entries */ | ||
179 | void __buttonlight_mode(enum buttonlight_mode mode) | ||
180 | { | ||
181 | switch (mode) | 203 | switch (mode) |
182 | { | 204 | { |
183 | case BUTTONLIGHT_OFF: | 205 | case BUTTONLIGHT_OFF: |
@@ -185,22 +207,39 @@ void __buttonlight_mode(enum buttonlight_mode mode) | |||
185 | break; | 207 | break; |
186 | 208 | ||
187 | case BUTTONLIGHT_ON: | 209 | case BUTTONLIGHT_ON: |
210 | buttonlight_trigger_brightness = brightness; | ||
188 | buttonlight_state = BUTTONLIGHT_MODE_ON_ENTRY; | 211 | buttonlight_state = BUTTONLIGHT_MODE_ON_ENTRY; |
189 | break; | 212 | break; |
190 | 213 | ||
214 | /* faint is just a quick way to set ON to 1 */ | ||
191 | case BUTTONLIGHT_FAINT: | 215 | case BUTTONLIGHT_FAINT: |
192 | buttonlight_state = BUTTONLIGHT_MODE_FAINT_ENTRY; | 216 | buttonlight_trigger_brightness = 1; |
217 | buttonlight_state = BUTTONLIGHT_MODE_ON_ENTRY; | ||
193 | break; | 218 | break; |
194 | 219 | ||
195 | case BUTTONLIGHT_FLICKER: | 220 | case BUTTONLIGHT_FLICKER: |
221 | buttonlight_trigger_brightness = brightness; | ||
196 | buttonlight_state = BUTTONLIGHT_MODE_FLICKER_ENTRY; | 222 | buttonlight_state = BUTTONLIGHT_MODE_FLICKER_ENTRY; |
197 | break; | 223 | break; |
198 | 224 | ||
225 | case BUTTONLIGHT_SIGNAL: | ||
226 | buttonlight_trigger_brightness = brightness; | ||
227 | buttonlight_state = BUTTONLIGHT_MODE_SOLID_ENTRY; | ||
228 | break; | ||
229 | |||
230 | case BUTTONLIGHT_FOLLOW: | ||
231 | buttonlight_state = BUTTONLIGHT_MODE_FOLLOW_ENTRY; | ||
232 | break; | ||
233 | |||
234 | case BUTTONLIGHT_CHARGING: | ||
235 | buttonlight_state = BUTTONLIGHT_MODE_CHARGING_ENTRY; | ||
236 | break; | ||
237 | |||
199 | default: | 238 | default: |
200 | return; /* unknown mode */ | 239 | return; /* unknown mode */ |
201 | } | 240 | } |
202 | 241 | ||
203 | 242 | ||
204 | } | 243 | } |
205 | 244 | ||
206 | 245 | ||
@@ -234,6 +273,8 @@ static void led_control_service(void) | |||
234 | case BACKLIGHT_CONTROL_IDLE: | 273 | case BACKLIGHT_CONTROL_IDLE: |
235 | switch (buttonlight_state) | 274 | switch (buttonlight_state) |
236 | { | 275 | { |
276 | case BUTTONLIGHT_MODE_STOP: break; | ||
277 | |||
237 | /* Buttonlight mode: OFF */ | 278 | /* Buttonlight mode: OFF */ |
238 | case BUTTONLIGHT_MODE_OFF_ENTRY: | 279 | case BUTTONLIGHT_MODE_OFF_ENTRY: |
239 | if (buttonlight_current) | 280 | if (buttonlight_current) |
@@ -248,52 +289,127 @@ static void led_control_service(void) | |||
248 | case BUTTONLIGHT_MODE_OFF: | 289 | case BUTTONLIGHT_MODE_OFF: |
249 | break; | 290 | break; |
250 | 291 | ||
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 | 292 | ||
261 | /* temporary save for the next mode - then to do settings */ | 293 | /* button mode: CHARGING - show charging sequence */ |
262 | buttonlight_setting = backlight_brightness; | 294 | case BUTTONLIGHT_MODE_CHARGING_ENTRY: |
263 | buttonlight_saved_state = BUTTONLIGHT_MODE_ON; | 295 | /* start turned off */ |
264 | buttonlight_state = BUTTONLIGHT_HELPER_SET; | 296 | buttonlight_leds = 0x00; |
265 | } | 297 | sc606_write(SC606_REG_CONF, backlight_leds); |
266 | break; | 298 | buttonlight_current = 0; |
267 | 299 | ||
300 | /* temporary save for the next mode - then to do settings */ | ||
301 | buttonlight_setting = DEFAULT_BRIGHTNESS_SETTING; | ||
302 | buttonlight_saved_state = BUTTONLIGHT_MODE_CHARGING_WAIT; | ||
303 | buttonlight_state = BUTTONLIGHT_HELPER_SET; | ||
304 | break; | ||
305 | |||
268 | 306 | ||
269 | /* Buttonlight mode: Faint */ | 307 | case BUTTONLIGHT_MODE_CHARGING: |
270 | case BUTTONLIGHT_MODE_FAINT_ENTRY: | 308 | if (--buttonlight_charging_counter == 0) |
271 | if (buttonlight_current != 1) | ||
272 | { | 309 | { |
273 | /* need to turn on the backlight? */ | 310 | /* change led */ |
274 | if (buttonlight_current == 0) | 311 | if (charging_state()) |
275 | { | 312 | { |
276 | buttonlight_leds = buttonlight_selected; | 313 | buttonlight_leds = charging_leds[charging_led_index]; |
314 | if (++charging_led_index >= sizeof(charging_leds)) | ||
315 | { | ||
316 | charging_led_index = 0; | ||
317 | } | ||
277 | sc606_write(SC606_REG_CONF, backlight_leds | buttonlight_leds); | 318 | sc606_write(SC606_REG_CONF, backlight_leds | buttonlight_leds); |
319 | buttonlight_charging_counter = CHARGING_LED_COUNT; | ||
320 | } | ||
321 | else | ||
322 | { | ||
323 | buttonlight_state = BUTTONLIGHT_MODE_CHARGING_ENTRY; | ||
278 | } | 324 | } |
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 | } | 325 | } |
285 | break; | 326 | break; |
286 | 327 | ||
287 | case BUTTONLIGHT_MODE_FAINT: | 328 | /* wait for the charget to be plugged in */ |
288 | /* watch for change in led selction */ | 329 | case BUTTONLIGHT_MODE_CHARGING_WAIT: |
289 | if (buttonlight_leds != buttonlight_selected) | 330 | if (charging_state()) |
290 | { | 331 | { |
332 | charging_led_index = 0; | ||
333 | buttonlight_charging_counter = CHARGING_LED_COUNT; | ||
334 | buttonlight_state = BUTTONLIGHT_MODE_CHARGING; | ||
335 | } | ||
336 | break; | ||
337 | |||
338 | |||
339 | /* Buttonlight mode: FOLLOW - try to stay current with backlight | ||
340 | * since this runs in the idle of the backlight it will not really | ||
341 | * follow in real time | ||
342 | */ | ||
343 | case BUTTONLIGHT_MODE_FOLLOW_ENTRY: | ||
344 | /* case 1 - backlight on, but buttonlight is off */ | ||
345 | if (backlight_current) | ||
346 | { | ||
347 | /* Turn the buttonlights on */ | ||
291 | buttonlight_leds = buttonlight_selected; | 348 | buttonlight_leds = buttonlight_selected; |
292 | sc606_write(SC606_REG_CONF, backlight_leds | buttonlight_leds); | 349 | sc606_write(SC606_REG_CONF, backlight_leds | buttonlight_leds); |
350 | |||
351 | /* temporary save for the next mode - then to do settings */ | ||
352 | buttonlight_setting = backlight_current; | ||
353 | buttonlight_saved_state = BUTTONLIGHT_MODE_FOLLOW; | ||
354 | buttonlight_state = BUTTONLIGHT_HELPER_SET; | ||
293 | } | 355 | } |
356 | /* case 2 - backlight off, but buttonlight is on */ | ||
357 | else | ||
358 | { | ||
359 | buttonlight_current = 0; | ||
360 | buttonlight_leds = 0x00; | ||
361 | sc606_write(SC606_REG_CONF, backlight_leds); | ||
362 | buttonlight_state = BUTTONLIGHT_MODE_FOLLOW; | ||
363 | } | ||
364 | break; | ||
365 | |||
366 | case BUTTONLIGHT_MODE_FOLLOW: | ||
367 | if (buttonlight_current != backlight_current) | ||
368 | { | ||
369 | /* case 1 - backlight on, but buttonlight is off */ | ||
370 | if (backlight_current) | ||
371 | { | ||
372 | if (0 == buttonlight_current) | ||
373 | { | ||
374 | /* Turn the buttonlights on */ | ||
375 | buttonlight_leds = buttonlight_selected; | ||
376 | sc606_write(SC606_REG_CONF, backlight_leds | buttonlight_leds); | ||
377 | } | ||
378 | |||
379 | /* temporary save for the next mode - then to do settings */ | ||
380 | buttonlight_setting = backlight_current; | ||
381 | buttonlight_saved_state = BUTTONLIGHT_MODE_FOLLOW; | ||
382 | buttonlight_state = BUTTONLIGHT_HELPER_SET; | ||
383 | } | ||
384 | |||
385 | /* case 2 - backlight off, but buttonlight is on */ | ||
386 | else | ||
387 | { | ||
388 | buttonlight_current = 0; | ||
389 | buttonlight_leds = 0x00; | ||
390 | sc606_write(SC606_REG_CONF, backlight_leds); | ||
391 | } | ||
392 | |||
393 | } | ||
394 | break; | ||
395 | |||
294 | 396 | ||
397 | |||
398 | /* Buttonlight mode: ON - stays at the set brightness */ | ||
399 | case BUTTONLIGHT_MODE_ON_ENTRY: | ||
400 | buttonlight_leds = buttonlight_selected; | ||
401 | sc606_write(SC606_REG_CONF, backlight_leds | buttonlight_leds); | ||
402 | |||
403 | /* temporary save for the next mode - then to do settings */ | ||
404 | buttonlight_setting = buttonlight_trigger_brightness; | ||
405 | buttonlight_saved_state = BUTTONLIGHT_MODE_ON; | ||
406 | buttonlight_state = BUTTONLIGHT_HELPER_SET; | ||
295 | break; | 407 | break; |
296 | 408 | ||
409 | case BUTTONLIGHT_MODE_ON: | ||
410 | break; | ||
411 | |||
412 | |||
297 | 413 | ||
298 | /* Buttonlight mode: FLICKER */ | 414 | /* Buttonlight mode: FLICKER */ |
299 | case BUTTONLIGHT_MODE_FLICKER_ENTRY: | 415 | case BUTTONLIGHT_MODE_FLICKER_ENTRY: |
@@ -306,19 +422,20 @@ static void led_control_service(void) | |||
306 | } | 422 | } |
307 | 423 | ||
308 | /* set the brightness if not already set */ | 424 | /* set the brightness if not already set */ |
309 | if (buttonlight_current != buttonlight_flicker_brightness) | 425 | if (buttonlight_current != buttonlight_trigger_brightness) |
310 | { | 426 | { |
311 | /* temporary save for the next mode - then to do settings */ | 427 | /* temporary save for the next mode - then to do settings */ |
312 | buttonlight_setting = buttonlight_flicker_brightness; | 428 | buttonlight_setting = buttonlight_trigger_brightness; |
313 | buttonlight_saved_state = BUTTONLIGHT_MODE_FLICKER; | 429 | buttonlight_saved_state = BUTTONLIGHT_MODE_FLICKER; |
314 | buttonlight_state = BUTTONLIGHT_HELPER_SET; | 430 | buttonlight_state = BUTTONLIGHT_HELPER_SET; |
315 | } | 431 | } |
432 | else buttonlight_state = BUTTONLIGHT_MODE_FLICKER; | ||
316 | break; | 433 | break; |
317 | 434 | ||
318 | 435 | ||
319 | case BUTTONLIGHT_MODE_FLICKER: | 436 | case BUTTONLIGHT_MODE_FLICKER: |
320 | /* wait for the foreground to trigger flickering */ | 437 | /* wait for the foreground to trigger flickering */ |
321 | if (buttonlight_flicker_now) | 438 | if (buttonlight_trigger_now) |
322 | { | 439 | { |
323 | /* turn them on */ | 440 | /* turn them on */ |
324 | buttonlight_leds = buttonlight_selected; | 441 | buttonlight_leds = buttonlight_selected; |
@@ -326,7 +443,7 @@ static void led_control_service(void) | |||
326 | sc606_write(SC606_REG_CONF, backlight_leds | buttonlight_leds); | 443 | sc606_write(SC606_REG_CONF, backlight_leds | buttonlight_leds); |
327 | 444 | ||
328 | /* reset the trigger and go flicker the LEDs */ | 445 | /* reset the trigger and go flicker the LEDs */ |
329 | buttonlight_flicker_now = 0; | 446 | buttonlight_trigger_now = 0; |
330 | buttonlight_flickering = FLICKER_PERIOD; | 447 | buttonlight_flickering = FLICKER_PERIOD; |
331 | buttonlight_state = BUTTONLIGHT_MODE_FLICKERING; | 448 | buttonlight_state = BUTTONLIGHT_MODE_FLICKERING; |
332 | } | 449 | } |
@@ -350,7 +467,7 @@ static void led_control_service(void) | |||
350 | else | 467 | else |
351 | { | 468 | { |
352 | /* is flickering triggered again? */ | 469 | /* is flickering triggered again? */ |
353 | if (!buttonlight_flicker_now) | 470 | if (!buttonlight_trigger_now) |
354 | { | 471 | { |
355 | /* completed a cycle - no new triggers - go back and wait */ | 472 | /* completed a cycle - no new triggers - go back and wait */ |
356 | buttonlight_state = BUTTONLIGHT_MODE_FLICKER; | 473 | buttonlight_state = BUTTONLIGHT_MODE_FLICKER; |
@@ -358,7 +475,7 @@ static void led_control_service(void) | |||
358 | else | 475 | else |
359 | { | 476 | { |
360 | /* reset flickering */ | 477 | /* reset flickering */ |
361 | buttonlight_flicker_now = 0; | 478 | buttonlight_trigger_now = 0; |
362 | buttonlight_flickering = FLICKER_PERIOD; | 479 | buttonlight_flickering = FLICKER_PERIOD; |
363 | 480 | ||
364 | /* turn buttonlights on */ | 481 | /* turn buttonlights on */ |
@@ -369,6 +486,52 @@ static void led_control_service(void) | |||
369 | } | 486 | } |
370 | break; | 487 | break; |
371 | 488 | ||
489 | |||
490 | /* Buttonlight mode: SIGNAL / SOLID */ | ||
491 | case BUTTONLIGHT_MODE_SOLID_ENTRY: | ||
492 | /* already on? turn it off */ | ||
493 | if (buttonlight_current) | ||
494 | { | ||
495 | buttonlight_leds = 0x00; | ||
496 | sc606_write(SC606_REG_CONF, backlight_leds); | ||
497 | buttonlight_current = 0; | ||
498 | } | ||
499 | |||
500 | /* set the brightness if not already set */ | ||
501 | /* temporary save for the next mode - then to do settings */ | ||
502 | buttonlight_setting = buttonlight_trigger_brightness; | ||
503 | buttonlight_saved_state = BUTTONLIGHT_MODE_SOLID; | ||
504 | buttonlight_state = BUTTONLIGHT_HELPER_SET; | ||
505 | break; | ||
506 | |||
507 | |||
508 | case BUTTONLIGHT_MODE_SOLID: | ||
509 | /* wait for the foreground to trigger */ | ||
510 | if (buttonlight_trigger_now) | ||
511 | { | ||
512 | /* turn them on if not already on */ | ||
513 | if (0 == buttonlight_current) | ||
514 | { | ||
515 | buttonlight_leds = buttonlight_selected; | ||
516 | buttonlight_current = buttonlight_setting; | ||
517 | sc606_write(SC606_REG_CONF, backlight_leds | buttonlight_leds); | ||
518 | } | ||
519 | |||
520 | /* reset the trigger */ | ||
521 | buttonlight_trigger_now = 0; | ||
522 | } | ||
523 | else | ||
524 | { | ||
525 | if (buttonlight_current) | ||
526 | { | ||
527 | buttonlight_leds = 0x00; | ||
528 | sc606_write(SC606_REG_CONF, backlight_leds); | ||
529 | buttonlight_current = 0; | ||
530 | } | ||
531 | } | ||
532 | break; | ||
533 | |||
534 | |||
372 | /* set the brightness for the buttonlights - takes 2 passes */ | 535 | /* set the brightness for the buttonlights - takes 2 passes */ |
373 | case BUTTONLIGHT_HELPER_SET: | 536 | case BUTTONLIGHT_HELPER_SET: |
374 | sc606_write(SC606_REG_B, buttonlight_setting-1); | 537 | sc606_write(SC606_REG_B, buttonlight_setting-1); |
@@ -400,6 +563,9 @@ static void led_control_service(void) | |||
400 | backlight_leds = 0x00; | 563 | backlight_leds = 0x00; |
401 | sc606_write(SC606_REG_CONF, buttonlight_leds); | 564 | sc606_write(SC606_REG_CONF, buttonlight_leds); |
402 | backlight_control = BACKLIGHT_CONTROL_IDLE; | 565 | backlight_control = BACKLIGHT_CONTROL_IDLE; |
566 | |||
567 | /* turn the lcd completely off after the fade or off command */ | ||
568 | lcd_enable(false); | ||
403 | break; | 569 | break; |
404 | 570 | ||
405 | 571 | ||
@@ -514,32 +680,3 @@ void __backlight_dim(bool dim_now) | |||
514 | } | 680 | } |
515 | 681 | ||
516 | 682 | ||
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 67a055449c..781fb9647b 100644 --- a/firmware/target/arm/gigabeat/meg-fx/backlight-target.h +++ b/firmware/target/arm/gigabeat/meg-fx/backlight-target.h | |||
@@ -34,7 +34,7 @@ enum buttonlight_selection | |||
34 | /* Use these to set the buttonlight mode */ | 34 | /* Use these to set the buttonlight mode */ |
35 | enum buttonlight_mode | 35 | enum buttonlight_mode |
36 | { | 36 | { |
37 | /* ON follows the setting of the backlight - same brightness */ | 37 | /* ON follows the setting */ |
38 | BUTTONLIGHT_ON, | 38 | BUTTONLIGHT_ON, |
39 | 39 | ||
40 | /* buttonlights always off */ | 40 | /* buttonlights always off */ |
@@ -43,23 +43,37 @@ enum buttonlight_mode | |||
43 | /* buttonlights always on but set at lowest brightness */ | 43 | /* buttonlights always on but set at lowest brightness */ |
44 | BUTTONLIGHT_FAINT, | 44 | BUTTONLIGHT_FAINT, |
45 | 45 | ||
46 | /* buttonlights flicker when triggered */ | 46 | /* buttonlights flicker when triggered - continues to flicker |
47 | * even if the flicker is still asserted. | ||
48 | */ | ||
47 | BUTTONLIGHT_FLICKER, | 49 | BUTTONLIGHT_FLICKER, |
48 | }; | ||
49 | |||
50 | 50 | ||
51 | /* call to flicker the button lights */ | 51 | /* buttonlights solid for as long as triggered */ |
52 | void __buttonlight_flicker(unsigned short brightness); | 52 | BUTTONLIGHT_SIGNAL, |
53 | |||
54 | /* buttonlights follow backlight */ | ||
55 | BUTTONLIGHT_FOLLOW, | ||
56 | |||
57 | /* buttonlights show battery charging */ | ||
58 | BUTTONLIGHT_CHARGING, | ||
59 | }; | ||
53 | 60 | ||
54 | 61 | ||
55 | /* only use the XX__ENTRY when setting the mode */ | 62 | /* Call this to flicker or signal the button lights. Only is effective for |
56 | void __buttonlight_mode(enum buttonlight_mode mode); | 63 | * modes that take a trigger input. |
64 | */ | ||
65 | void __buttonlight_trigger(void); | ||
57 | 66 | ||
58 | 67 | ||
59 | /* select which led to use on the button lights. Other combinations are | 68 | /* select which led to use on the button lights. Other combinations are |
60 | * possible, but don't look very good. | 69 | * possible, but don't look very good. |
61 | */ | 70 | */ |
62 | void __buttonlight_select(enum buttonlight_selection selection); | 71 | |
72 | /* map the mode from the command into the state machine entries */ | ||
73 | /* See enum buttonlight_mode for available functions */ | ||
74 | void __buttonlight_mode(enum buttonlight_mode mode, | ||
75 | enum buttonlight_selection selection, | ||
76 | unsigned short brightness); | ||
63 | 77 | ||
64 | 78 | ||
65 | void __backlight_init(void); | 79 | void __backlight_init(void); |
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 c5d0251323..117e1114af 100644 --- a/firmware/target/arm/gigabeat/meg-fx/button-meg-fx.c +++ b/firmware/target/arm/gigabeat/meg-fx/button-meg-fx.c | |||
@@ -123,8 +123,6 @@ int button_read_device(void) | |||
123 | 123 | ||
124 | if (touchpad & (1 << 3)) | 124 | if (touchpad & (1 << 3)) |
125 | btn |= BUTTON_SELECT; | 125 | btn |= BUTTON_SELECT; |
126 | |||
127 | __buttonlight_flicker(DEFAULT_BRIGHTNESS_SETTING/2); | ||
128 | } | 126 | } |
129 | 127 | ||
130 | return btn; | 128 | return btn; |