diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2006-07-28 12:41:13 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2006-07-28 12:41:13 +0000 |
commit | d17d08c268290b9ffc2f6e62876f1e0a05b56a6e (patch) | |
tree | 8536a67ffa5c88f7ec38e5a74046c28705b95220 /firmware/drivers/lcd-remote-2bit-vi.c | |
parent | 38719f87cbf6cd5fcefafe14780543eb1dad3f63 (diff) | |
download | rockbox-d17d08c268290b9ffc2f6e62876f1e0a05b56a6e.tar.gz rockbox-d17d08c268290b9ffc2f6e62876f1e0a05b56a6e.zip |
LCD remote support for iAudio X5
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10352 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/lcd-remote-2bit-vi.c')
-rwxr-xr-x | firmware/drivers/lcd-remote-2bit-vi.c | 123 |
1 files changed, 111 insertions, 12 deletions
diff --git a/firmware/drivers/lcd-remote-2bit-vi.c b/firmware/drivers/lcd-remote-2bit-vi.c index cf486b5d0d..eefbae1de3 100755 --- a/firmware/drivers/lcd-remote-2bit-vi.c +++ b/firmware/drivers/lcd-remote-2bit-vi.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include "font.h" | 33 | #include "font.h" |
34 | #include "rbunicode.h" | 34 | #include "rbunicode.h" |
35 | #include "bidi.h" | 35 | #include "bidi.h" |
36 | #include "lcd-remote-target.h" | ||
36 | 37 | ||
37 | #define SCROLLABLE_LINES (((LCD_REMOTE_HEIGHT+4)/5 < 32) ? (LCD_REMOTE_HEIGHT+4)/5 : 32) | 38 | #define SCROLLABLE_LINES (((LCD_REMOTE_HEIGHT+4)/5 < 32) ? (LCD_REMOTE_HEIGHT+4)/5 : 32) |
38 | 39 | ||
@@ -67,18 +68,12 @@ static const char scroll_tick_table[16] = { | |||
67 | 100, 80, 64, 50, 40, 32, 25, 20, 16, 12, 10, 8, 6, 5, 4, 3 | 68 | 100, 80, 64, 50, 40, 32, 25, 20, 16, 12, 10, 8, 6, 5, 4, 3 |
68 | }; | 69 | }; |
69 | 70 | ||
70 | 71 | /* remote hotplug */ | |
71 | /* LCD init */ | 72 | #ifndef SIMULATOR |
72 | void lcd_remote_init(void) | 73 | static struct event_queue remote_scroll_queue; |
73 | { | 74 | #define REMOTE_INIT_LCD 1 |
74 | lcd_remote_clear_display(); | 75 | #define REMOTE_DEINIT_LCD 2 |
75 | #if 0 /* FIXME */ | ||
76 | /* Call device specific init */ | ||
77 | remote_init(); | ||
78 | #endif | 76 | #endif |
79 | create_thread(scroll_thread, scroll_stack, | ||
80 | sizeof(scroll_stack), scroll_name); | ||
81 | } | ||
82 | 77 | ||
83 | /*** parameter handling ***/ | 78 | /*** parameter handling ***/ |
84 | 79 | ||
@@ -1020,6 +1015,51 @@ void lcd_remote_puts_scroll_style_offset(int x, int y, const unsigned char *stri | |||
1020 | scrolling_lines &= ~(1<<y); | 1015 | scrolling_lines &= ~(1<<y); |
1021 | } | 1016 | } |
1022 | 1017 | ||
1018 | #ifndef SIMULATOR | ||
1019 | /* Monitor remote hotswap */ | ||
1020 | static void remote_tick(void) | ||
1021 | { | ||
1022 | static bool last_status = false; | ||
1023 | static int countdown = 0; | ||
1024 | static int init_delay = 0; | ||
1025 | bool current_status; | ||
1026 | |||
1027 | current_status = remote_detect(); | ||
1028 | |||
1029 | /* Only report when the status has changed */ | ||
1030 | if (current_status != last_status) | ||
1031 | { | ||
1032 | last_status = current_status; | ||
1033 | countdown = current_status ? 20*HZ : 1; | ||
1034 | } | ||
1035 | else | ||
1036 | { | ||
1037 | /* Count down until it gets negative */ | ||
1038 | if (countdown >= 0) | ||
1039 | countdown--; | ||
1040 | |||
1041 | if (current_status) | ||
1042 | { | ||
1043 | if (!(countdown % 8)) | ||
1044 | { | ||
1045 | if (--init_delay <= 0) | ||
1046 | { | ||
1047 | queue_post(&remote_scroll_queue, REMOTE_INIT_LCD, 0); | ||
1048 | init_delay = 6; | ||
1049 | } | ||
1050 | } | ||
1051 | } | ||
1052 | else | ||
1053 | { | ||
1054 | if (countdown == 0) | ||
1055 | { | ||
1056 | queue_post(&remote_scroll_queue, REMOTE_DEINIT_LCD, 0); | ||
1057 | } | ||
1058 | } | ||
1059 | } | ||
1060 | } | ||
1061 | #endif | ||
1062 | |||
1023 | static void scroll_thread(void) | 1063 | static void scroll_thread(void) |
1024 | { | 1064 | { |
1025 | struct font* pf; | 1065 | struct font* pf; |
@@ -1027,11 +1067,42 @@ static void scroll_thread(void) | |||
1027 | int index; | 1067 | int index; |
1028 | int xpos, ypos; | 1068 | int xpos, ypos; |
1029 | int lastmode; | 1069 | int lastmode; |
1070 | long delay = 0; | ||
1071 | long next_tick = current_tick; | ||
1072 | #ifndef SIMULATOR | ||
1073 | struct event ev; | ||
1074 | #endif | ||
1030 | 1075 | ||
1031 | /* initialize scroll struct array */ | 1076 | /* initialize scroll struct array */ |
1032 | scrolling_lines = 0; | 1077 | scrolling_lines = 0; |
1033 | 1078 | ||
1034 | while ( 1 ) { | 1079 | while ( 1 ) { |
1080 | |||
1081 | #ifdef SIMULATOR | ||
1082 | sleep(delay); | ||
1083 | #else | ||
1084 | if (remote_initialized) | ||
1085 | queue_wait_w_tmo(&remote_scroll_queue, &ev, delay); | ||
1086 | else | ||
1087 | queue_wait(&remote_scroll_queue, &ev); | ||
1088 | |||
1089 | switch (ev.id) | ||
1090 | { | ||
1091 | case REMOTE_INIT_LCD: | ||
1092 | lcd_remote_on(); | ||
1093 | lcd_remote_update(); | ||
1094 | break; | ||
1095 | |||
1096 | case REMOTE_DEINIT_LCD: | ||
1097 | lcd_remote_off(); | ||
1098 | break; | ||
1099 | } | ||
1100 | |||
1101 | delay = next_tick - current_tick - 1; | ||
1102 | if (delay >= 0) | ||
1103 | continue; | ||
1104 | #endif | ||
1105 | |||
1035 | for ( index = 0; index < SCROLLABLE_LINES; index++ ) { | 1106 | for ( index = 0; index < SCROLLABLE_LINES; index++ ) { |
1036 | /* really scroll? */ | 1107 | /* really scroll? */ |
1037 | if ( !(scrolling_lines&(1<<index)) ) | 1108 | if ( !(scrolling_lines&(1<<index)) ) |
@@ -1080,6 +1151,34 @@ static void scroll_thread(void) | |||
1080 | lcd_remote_update_rect(xpos, ypos, LCD_REMOTE_WIDTH - xpos, pf->height); | 1151 | lcd_remote_update_rect(xpos, ypos, LCD_REMOTE_WIDTH - xpos, pf->height); |
1081 | } | 1152 | } |
1082 | 1153 | ||
1083 | sleep(scroll_ticks); | 1154 | |
1155 | next_tick += scroll_ticks; | ||
1156 | delay = next_tick - current_tick - 1; | ||
1157 | if (delay < 0) | ||
1158 | { | ||
1159 | next_tick = current_tick + 1; | ||
1160 | delay = 0; | ||
1161 | } | ||
1084 | } | 1162 | } |
1085 | } | 1163 | } |
1164 | |||
1165 | /* LCD init */ | ||
1166 | #ifdef SIMULATOR | ||
1167 | void lcd_remote_init(void) | ||
1168 | { | ||
1169 | create_thread(scroll_thread, scroll_stack, | ||
1170 | sizeof(scroll_stack), scroll_name); | ||
1171 | } | ||
1172 | #else | ||
1173 | void lcd_remote_init(void) | ||
1174 | { | ||
1175 | /* Call device specific init */ | ||
1176 | lcd_remote_init_device(); | ||
1177 | |||
1178 | lcd_remote_clear_display(); | ||
1179 | queue_clear(&remote_scroll_queue); /* no queue_init() -- private queue */ | ||
1180 | tick_add_task(remote_tick); | ||
1181 | create_thread(scroll_thread, scroll_stack, | ||
1182 | sizeof(scroll_stack), scroll_name); | ||
1183 | } | ||
1184 | #endif | ||