diff options
-rw-r--r-- | firmware/drivers/lcd-remote-2bit-vi.c | 62 | ||||
-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 |
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] = { | |||
73 | 73 | ||
74 | /* remote hotplug */ | 74 | /* remote hotplug */ |
75 | #ifndef SIMULATOR | 75 | #ifndef SIMULATOR |
76 | static struct event_queue remote_scroll_queue; | 76 | struct event_queue remote_scroll_queue; |
77 | #define REMOTE_INIT_LCD 1 | ||
78 | #define REMOTE_DEINIT_LCD 2 | ||
79 | #endif | 77 | #endif |
80 | 78 | ||
81 | /*** parameter handling ***/ | 79 | /*** parameter handling ***/ |
@@ -1131,51 +1129,6 @@ void lcd_remote_puts_scroll_style_offset(int x, int y, const unsigned char *stri | |||
1131 | scrolling_lines &= ~(1<<y); | 1129 | scrolling_lines &= ~(1<<y); |
1132 | } | 1130 | } |
1133 | 1131 | ||
1134 | #ifndef SIMULATOR | ||
1135 | /* Monitor remote hotswap */ | ||
1136 | static void remote_tick(void) | ||
1137 | { | ||
1138 | static bool last_status = false; | ||
1139 | static int countdown = 0; | ||
1140 | static int init_delay = 0; | ||
1141 | bool current_status; | ||
1142 | |||
1143 | current_status = remote_detect(); | ||
1144 | |||
1145 | /* Only report when the status has changed */ | ||
1146 | if (current_status != last_status) | ||
1147 | { | ||
1148 | last_status = current_status; | ||
1149 | countdown = current_status ? 20*HZ : 1; | ||
1150 | } | ||
1151 | else | ||
1152 | { | ||
1153 | /* Count down until it gets negative */ | ||
1154 | if (countdown >= 0) | ||
1155 | countdown--; | ||
1156 | |||
1157 | if (current_status) | ||
1158 | { | ||
1159 | if (!(countdown % 8)) | ||
1160 | { | ||
1161 | if (--init_delay <= 0) | ||
1162 | { | ||
1163 | queue_post(&remote_scroll_queue, REMOTE_INIT_LCD, 0); | ||
1164 | init_delay = 6; | ||
1165 | } | ||
1166 | } | ||
1167 | } | ||
1168 | else | ||
1169 | { | ||
1170 | if (countdown == 0) | ||
1171 | { | ||
1172 | queue_post(&remote_scroll_queue, REMOTE_DEINIT_LCD, 0); | ||
1173 | } | ||
1174 | } | ||
1175 | } | ||
1176 | } | ||
1177 | #endif | ||
1178 | |||
1179 | static void scroll_thread(void) | 1132 | static void scroll_thread(void) |
1180 | { | 1133 | { |
1181 | struct font* pf; | 1134 | struct font* pf; |
@@ -1279,23 +1232,14 @@ static void scroll_thread(void) | |||
1279 | } | 1232 | } |
1280 | 1233 | ||
1281 | /* LCD init */ | 1234 | /* LCD init */ |
1282 | #ifdef SIMULATOR | ||
1283 | void lcd_remote_init(void) | ||
1284 | { | ||
1285 | create_thread(scroll_thread, scroll_stack, | ||
1286 | sizeof(scroll_stack), scroll_name IF_PRIO(, PRIORITY_USER_INTERFACE)); | ||
1287 | } | ||
1288 | #else | ||
1289 | void lcd_remote_init(void) | 1235 | void lcd_remote_init(void) |
1290 | { | 1236 | { |
1237 | #ifndef SIMULATOR | ||
1291 | /* Call device specific init */ | 1238 | /* Call device specific init */ |
1292 | lcd_remote_init_device(); | 1239 | lcd_remote_init_device(); |
1293 | |||
1294 | lcd_remote_clear_display(); | ||
1295 | /* private queue */ | 1240 | /* private queue */ |
1296 | queue_init(&remote_scroll_queue, false); | 1241 | queue_init(&remote_scroll_queue, false); |
1297 | tick_add_task(remote_tick); | 1242 | #endif |
1298 | create_thread(scroll_thread, scroll_stack, | 1243 | create_thread(scroll_thread, scroll_stack, |
1299 | sizeof(scroll_stack), scroll_name IF_PRIO(, PRIORITY_USER_INTERFACE)); | 1244 | sizeof(scroll_stack), scroll_name IF_PRIO(, PRIORITY_USER_INTERFACE)); |
1300 | } | 1245 | } |
1301 | #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 @@ | |||
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; |