summaryrefslogtreecommitdiff
path: root/firmware/target/coldfire/iaudio/x5/lcd-remote-x5.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/coldfire/iaudio/x5/lcd-remote-x5.c')
-rw-r--r--firmware/target/coldfire/iaudio/x5/lcd-remote-x5.c48
1 files changed, 48 insertions, 0 deletions
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
59bool remote_initialized = false; 59bool remote_initialized = false;
60 60
61static 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 */
62static inline void _write_byte(unsigned data) 64static 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
340void lcd_remote_on(void) 345void 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 */
401static 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. */
397void lcd_remote_update(void) ICODE_ATTR; 445void lcd_remote_update(void) ICODE_ATTR;