From 7d718a8064177a879423de7a78999a64126c79dc Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Sun, 25 Feb 2007 22:36:04 +0000 Subject: X5: Move the remote tick to target tree. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12486 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/lcd-remote-2bit-vi.c | 62 ++-------------------- .../target/coldfire/iaudio/x5/lcd-remote-target.h | 3 ++ firmware/target/coldfire/iaudio/x5/lcd-remote-x5.c | 48 +++++++++++++++++ 3 files changed, 54 insertions(+), 59 deletions(-) diff --git a/firmware/drivers/lcd-remote-2bit-vi.c b/firmware/drivers/lcd-remote-2bit-vi.c index 74e098010e..281cbc2189 100644 --- a/firmware/drivers/lcd-remote-2bit-vi.c +++ b/firmware/drivers/lcd-remote-2bit-vi.c @@ -73,9 +73,7 @@ static const char scroll_tick_table[16] = { /* remote hotplug */ #ifndef SIMULATOR -static struct event_queue remote_scroll_queue; -#define REMOTE_INIT_LCD 1 -#define REMOTE_DEINIT_LCD 2 +struct event_queue remote_scroll_queue; #endif /*** parameter handling ***/ @@ -1131,51 +1129,6 @@ void lcd_remote_puts_scroll_style_offset(int x, int y, const unsigned char *stri scrolling_lines &= ~(1<= 0) - countdown--; - - if (current_status) - { - if (!(countdown % 8)) - { - if (--init_delay <= 0) - { - queue_post(&remote_scroll_queue, REMOTE_INIT_LCD, 0); - init_delay = 6; - } - } - } - else - { - if (countdown == 0) - { - queue_post(&remote_scroll_queue, REMOTE_DEINIT_LCD, 0); - } - } - } -} -#endif - static void scroll_thread(void) { struct font* pf; @@ -1279,23 +1232,14 @@ static void scroll_thread(void) } /* LCD init */ -#ifdef SIMULATOR -void lcd_remote_init(void) -{ - create_thread(scroll_thread, scroll_stack, - sizeof(scroll_stack), scroll_name IF_PRIO(, PRIORITY_USER_INTERFACE)); -} -#else void lcd_remote_init(void) { +#ifndef SIMULATOR /* Call device specific init */ lcd_remote_init_device(); - - lcd_remote_clear_display(); /* private queue */ queue_init(&remote_scroll_queue, false); - tick_add_task(remote_tick); +#endif create_thread(scroll_thread, scroll_stack, sizeof(scroll_stack), scroll_name IF_PRIO(, PRIORITY_USER_INTERFACE)); } -#endif 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 @@ #ifndef LCD_REMOTE_TARGET_H #define LCD_REMOTE_TARGET_H +#define REMOTE_INIT_LCD 1 +#define REMOTE_DEINIT_LCD 2 + void lcd_remote_init_device(void); void lcd_remote_write_command(int cmd); 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; bool remote_initialized = false; +static void remote_tick(void); + /* Standard low-level byte writer. Requires CLK high on entry */ static inline void _write_byte(unsigned data) { @@ -335,6 +337,9 @@ void lcd_remote_init_device(void) and_l(~0x01000000, &GPIO_OUT); and_l(~0x01000000, &GPIO_ENABLE); or_l(0x01000000, &GPIO_FUNCTION); + + lcd_remote_clear_display(); + tick_add_task(remote_tick); } void lcd_remote_on(void) @@ -392,6 +397,49 @@ void lcd_remote_poweroff(void) lcd_remote_write_command(LCD_SET_POWER_SAVE | 1); } +/* Monitor remote hotswap */ +static void remote_tick(void) +{ + static bool last_status = false; + static int countdown = 0; + static int init_delay = 0; + bool current_status; + + current_status = remote_detect(); + + /* Only report when the status has changed */ + if (current_status != last_status) + { + last_status = current_status; + countdown = current_status ? 20*HZ : 1; + } + else + { + /* Count down until it gets negative */ + if (countdown >= 0) + countdown--; + + if (current_status) + { + if (!(countdown % 8)) + { + if (--init_delay <= 0) + { + queue_post(&remote_scroll_queue, REMOTE_INIT_LCD, 0); + init_delay = 6; + } + } + } + else + { + if (countdown == 0) + { + queue_post(&remote_scroll_queue, REMOTE_DEINIT_LCD, 0); + } + } + } +} + /* Update the display. This must be called after all other LCD functions that change the display. */ void lcd_remote_update(void) ICODE_ATTR; -- cgit v1.2.3