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/target/coldfire/iaudio/x5/lcd-remote-x5.c | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'firmware/target/coldfire/iaudio/x5/lcd-remote-x5.c') 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