diff options
Diffstat (limited to 'firmware/target')
-rw-r--r-- | firmware/target/coldfire/iaudio/x5/lcd-remote-target.h | 3 | ||||
-rw-r--r-- | firmware/target/coldfire/iaudio/x5/lcd-remote-x5.c | 48 |
2 files changed, 51 insertions, 0 deletions
diff --git a/firmware/target/coldfire/iaudio/x5/lcd-remote-target.h b/firmware/target/coldfire/iaudio/x5/lcd-remote-target.h index 783363bef3..86c361097b 100644 --- a/firmware/target/coldfire/iaudio/x5/lcd-remote-target.h +++ b/firmware/target/coldfire/iaudio/x5/lcd-remote-target.h | |||
@@ -19,6 +19,9 @@ | |||
19 | #ifndef LCD_REMOTE_TARGET_H | 19 | #ifndef LCD_REMOTE_TARGET_H |
20 | #define LCD_REMOTE_TARGET_H | 20 | #define LCD_REMOTE_TARGET_H |
21 | 21 | ||
22 | #define REMOTE_INIT_LCD 1 | ||
23 | #define REMOTE_DEINIT_LCD 2 | ||
24 | |||
22 | void lcd_remote_init_device(void); | 25 | void lcd_remote_init_device(void); |
23 | void lcd_remote_write_command(int cmd); | 26 | void lcd_remote_write_command(int cmd); |
24 | void lcd_remote_write_command_ex(int cmd, int data); | 27 | void lcd_remote_write_command_ex(int cmd, int data); |
diff --git a/firmware/target/coldfire/iaudio/x5/lcd-remote-x5.c b/firmware/target/coldfire/iaudio/x5/lcd-remote-x5.c index bd1fb19727..139ebbc2a3 100644 --- a/firmware/target/coldfire/iaudio/x5/lcd-remote-x5.c +++ b/firmware/target/coldfire/iaudio/x5/lcd-remote-x5.c | |||
@@ -58,6 +58,8 @@ static int cached_contrast = DEFAULT_REMOTE_CONTRAST_SETTING; | |||
58 | 58 | ||
59 | bool remote_initialized = false; | 59 | bool remote_initialized = false; |
60 | 60 | ||
61 | static void remote_tick(void); | ||
62 | |||
61 | /* Standard low-level byte writer. Requires CLK high on entry */ | 63 | /* Standard low-level byte writer. Requires CLK high on entry */ |
62 | static inline void _write_byte(unsigned data) | 64 | static inline void _write_byte(unsigned data) |
63 | { | 65 | { |
@@ -335,6 +337,9 @@ void lcd_remote_init_device(void) | |||
335 | and_l(~0x01000000, &GPIO_OUT); | 337 | and_l(~0x01000000, &GPIO_OUT); |
336 | and_l(~0x01000000, &GPIO_ENABLE); | 338 | and_l(~0x01000000, &GPIO_ENABLE); |
337 | or_l(0x01000000, &GPIO_FUNCTION); | 339 | or_l(0x01000000, &GPIO_FUNCTION); |
340 | |||
341 | lcd_remote_clear_display(); | ||
342 | tick_add_task(remote_tick); | ||
338 | } | 343 | } |
339 | 344 | ||
340 | void lcd_remote_on(void) | 345 | void lcd_remote_on(void) |
@@ -392,6 +397,49 @@ void lcd_remote_poweroff(void) | |||
392 | lcd_remote_write_command(LCD_SET_POWER_SAVE | 1); | 397 | lcd_remote_write_command(LCD_SET_POWER_SAVE | 1); |
393 | } | 398 | } |
394 | 399 | ||
400 | /* Monitor remote hotswap */ | ||
401 | static void remote_tick(void) | ||
402 | { | ||
403 | static bool last_status = false; | ||
404 | static int countdown = 0; | ||
405 | static int init_delay = 0; | ||
406 | bool current_status; | ||
407 | |||
408 | current_status = remote_detect(); | ||
409 | |||
410 | /* Only report when the status has changed */ | ||
411 | if (current_status != last_status) | ||
412 | { | ||
413 | last_status = current_status; | ||
414 | countdown = current_status ? 20*HZ : 1; | ||
415 | } | ||
416 | else | ||
417 | { | ||
418 | /* Count down until it gets negative */ | ||
419 | if (countdown >= 0) | ||
420 | countdown--; | ||
421 | |||
422 | if (current_status) | ||
423 | { | ||
424 | if (!(countdown % 8)) | ||
425 | { | ||
426 | if (--init_delay <= 0) | ||
427 | { | ||
428 | queue_post(&remote_scroll_queue, REMOTE_INIT_LCD, 0); | ||
429 | init_delay = 6; | ||
430 | } | ||
431 | } | ||
432 | } | ||
433 | else | ||
434 | { | ||
435 | if (countdown == 0) | ||
436 | { | ||
437 | queue_post(&remote_scroll_queue, REMOTE_DEINIT_LCD, 0); | ||
438 | } | ||
439 | } | ||
440 | } | ||
441 | } | ||
442 | |||
395 | /* Update the display. | 443 | /* Update the display. |
396 | This must be called after all other LCD functions that change the display. */ | 444 | This must be called after all other LCD functions that change the display. */ |
397 | void lcd_remote_update(void) ICODE_ATTR; | 445 | void lcd_remote_update(void) ICODE_ATTR; |