diff options
-rw-r--r-- | apps/player/keyboard.c | 54 | ||||
-rw-r--r-- | firmware/drivers/lcd-player.c | 35 | ||||
-rw-r--r-- | firmware/drivers/lcd.h | 1 |
3 files changed, 72 insertions, 18 deletions
diff --git a/apps/player/keyboard.c b/apps/player/keyboard.c index b33dcebbdf..42c09098a0 100644 --- a/apps/player/keyboard.c +++ b/apps/player/keyboard.c | |||
@@ -76,10 +76,11 @@ static unsigned short* kbd_setupkeys(int page, int* len) | |||
76 | 76 | ||
77 | #define MENU_LINE_INPUT 0 | 77 | #define MENU_LINE_INPUT 0 |
78 | #define MENU_LINE_NEWCHARS 1 | 78 | #define MENU_LINE_NEWCHARS 1 |
79 | #define MENU_LINE_DELETE 2 | 79 | #define MENU_LINE_BACKSPACE 2 |
80 | #define MENU_LINE_ACCEPT 3 | 80 | #define MENU_LINE_DELETE 3 |
81 | #define MENU_LINE_QUIT 4 | 81 | #define MENU_LINE_ACCEPT 4 |
82 | #define MENU_LINE_LAST 4 | 82 | #define MENU_LINE_QUIT 5 |
83 | #define MENU_LINE_LAST 5 | ||
83 | 84 | ||
84 | int kbd_input(char* text, int buflen) | 85 | int kbd_input(char* text, int buflen) |
85 | { | 86 | { |
@@ -91,7 +92,6 @@ int kbd_input(char* text, int buflen) | |||
91 | int cursor_pos=0; | 92 | int cursor_pos=0; |
92 | int button_pressed; | 93 | int button_pressed; |
93 | unsigned char temptext[12]; | 94 | unsigned char temptext[12]; |
94 | bool cursor_on=true; /* Blinking cursor control */ | ||
95 | int old_cursor_pos=0; /* Windowed cursor movement */ | 95 | int old_cursor_pos=0; /* Windowed cursor movement */ |
96 | int left_pos=0; | 96 | int left_pos=0; |
97 | 97 | ||
@@ -110,17 +110,11 @@ int kbd_input(char* text, int buflen) | |||
110 | p=0; | 110 | p=0; |
111 | i = left_pos; | 111 | i = left_pos; |
112 | while (p<10 && line[i]) { | 112 | while (p<10 && line[i]) { |
113 | if (i == cursor_pos && cursor_on) | 113 | temptext[p++]=text[i++]; |
114 | { | ||
115 | temptext[p++]=KEYBOARD_CURSOR; | ||
116 | i++; | ||
117 | } else { | ||
118 | temptext[p++]=text[i++]; | ||
119 | } | ||
120 | } | 114 | } |
121 | temptext[p]=0; | 115 | temptext[p]=0; |
122 | lcd_puts(1, 0, temptext); | 116 | lcd_puts(1, 0, temptext); |
123 | cursor_on = !cursor_on; | 117 | lcd_put_cursor(cursor_pos-left_pos+1, 0, 0x7f); |
124 | old_cursor_pos=cursor_pos; | 118 | old_cursor_pos=cursor_pos; |
125 | 119 | ||
126 | switch (menu_line) { | 120 | switch (menu_line) { |
@@ -136,6 +130,9 @@ int kbd_input(char* text, int buflen) | |||
136 | temptext[p]=0; | 130 | temptext[p]=0; |
137 | lcd_puts(1, 1, temptext); | 131 | lcd_puts(1, 1, temptext); |
138 | break; | 132 | break; |
133 | case MENU_LINE_BACKSPACE: | ||
134 | lcd_puts_scroll(1, 1, "Backspace"); | ||
135 | break; | ||
139 | case MENU_LINE_DELETE: | 136 | case MENU_LINE_DELETE: |
140 | lcd_puts_scroll(1, 1, "Delete"); | 137 | lcd_puts_scroll(1, 1, "Delete"); |
141 | break; | 138 | break; |
@@ -143,7 +140,7 @@ int kbd_input(char* text, int buflen) | |||
143 | lcd_puts_scroll(1, 1, "Accept"); | 140 | lcd_puts_scroll(1, 1, "Accept"); |
144 | break; | 141 | break; |
145 | case MENU_LINE_QUIT: | 142 | case MENU_LINE_QUIT: |
146 | lcd_puts_scroll(1, 1, "Cancel"); | 143 | lcd_puts_scroll(1, 1, "Abort"); |
147 | break; | 144 | break; |
148 | } | 145 | } |
149 | if (menu_line==MENU_LINE_INPUT) { | 146 | if (menu_line==MENU_LINE_INPUT) { |
@@ -156,7 +153,7 @@ int kbd_input(char* text, int buflen) | |||
156 | 153 | ||
157 | lcd_update(); | 154 | lcd_update(); |
158 | 155 | ||
159 | button_pressed=button_get_w_tmo(HZ/2); | 156 | button_pressed=button_get(true); |
160 | switch (menu_line) | 157 | switch (menu_line) |
161 | { | 158 | { |
162 | case MENU_LINE_INPUT: | 159 | case MENU_LINE_INPUT: |
@@ -167,14 +164,12 @@ int kbd_input(char* text, int buflen) | |||
167 | if (cursor_pos<len) | 164 | if (cursor_pos<len) |
168 | cursor_pos++; | 165 | cursor_pos++; |
169 | button_pressed=BUTTON_NONE; | 166 | button_pressed=BUTTON_NONE; |
170 | cursor_on=true; | ||
171 | break; | 167 | break; |
172 | case BUTTON_DOWN: | 168 | case BUTTON_DOWN: |
173 | case BUTTON_DOWN | BUTTON_REPEAT: | 169 | case BUTTON_DOWN | BUTTON_REPEAT: |
174 | if (cursor_pos>0) | 170 | if (cursor_pos>0) |
175 | cursor_pos--; | 171 | cursor_pos--; |
176 | button_pressed=BUTTON_NONE; | 172 | button_pressed=BUTTON_NONE; |
177 | cursor_on=true; | ||
178 | break; | 173 | break; |
179 | } | 174 | } |
180 | break; | 175 | break; |
@@ -214,6 +209,27 @@ int kbd_input(char* text, int buflen) | |||
214 | } | 209 | } |
215 | break; | 210 | break; |
216 | 211 | ||
212 | case MENU_LINE_BACKSPACE: | ||
213 | switch (button_pressed) { | ||
214 | case BUTTON_ON: | ||
215 | case BUTTON_PLAY: | ||
216 | case BUTTON_PLAY | BUTTON_REPEAT: | ||
217 | button_pressed=BUTTON_NONE; | ||
218 | if (0 < cursor_pos) { | ||
219 | for (i=--cursor_pos; i<=len; i++) { | ||
220 | text[i]=text[i+1]; | ||
221 | } | ||
222 | } | ||
223 | break; | ||
224 | case BUTTON_STOP: | ||
225 | case BUTTON_STOP | BUTTON_REPEAT: | ||
226 | button_pressed=BUTTON_NONE; | ||
227 | for (i=cursor_pos; i<=len; i++) { | ||
228 | text[i]=text[i+1]; | ||
229 | } | ||
230 | break; | ||
231 | } | ||
232 | break; | ||
217 | case MENU_LINE_DELETE: | 233 | case MENU_LINE_DELETE: |
218 | switch (button_pressed) { | 234 | switch (button_pressed) { |
219 | case BUTTON_ON: | 235 | case BUTTON_ON: |
@@ -270,12 +286,16 @@ int kbd_input(char* text, int buflen) | |||
270 | case BUTTON_RIGHT | BUTTON_REPEAT: | 286 | case BUTTON_RIGHT | BUTTON_REPEAT: |
271 | if (menu_line<MENU_LINE_LAST) | 287 | if (menu_line<MENU_LINE_LAST) |
272 | menu_line++; | 288 | menu_line++; |
289 | else | ||
290 | menu_line=0; | ||
273 | break; | 291 | break; |
274 | 292 | ||
275 | case BUTTON_LEFT: | 293 | case BUTTON_LEFT: |
276 | case BUTTON_LEFT | BUTTON_REPEAT: | 294 | case BUTTON_LEFT | BUTTON_REPEAT: |
277 | if (menu_line>0) | 295 | if (menu_line>0) |
278 | menu_line--; | 296 | menu_line--; |
297 | else | ||
298 | menu_line=MENU_LINE_LAST; | ||
279 | break; | 299 | break; |
280 | } | 300 | } |
281 | } | 301 | } |
diff --git a/firmware/drivers/lcd-player.c b/firmware/drivers/lcd-player.c index 0ca551c63a..a03b1b024c 100644 --- a/firmware/drivers/lcd-player.c +++ b/firmware/drivers/lcd-player.c | |||
@@ -72,6 +72,17 @@ struct scrollinfo { | |||
72 | int direction; /* +1 for right or -1 for left*/ | 72 | int direction; /* +1 for right or -1 for left*/ |
73 | }; | 73 | }; |
74 | 74 | ||
75 | #define MAX_CURSOR_CHARS 8 | ||
76 | struct cursorinfo { | ||
77 | int len; | ||
78 | char text[MAX_CURSOR_CHARS]; | ||
79 | int textpos; | ||
80 | int y_pos; | ||
81 | int x_pos; | ||
82 | int divider; | ||
83 | int downcount; | ||
84 | } cursor; | ||
85 | |||
75 | static void scroll_thread(void); | 86 | static void scroll_thread(void); |
76 | static char scroll_stack[DEFAULT_STACK_SIZE]; | 87 | static char scroll_stack[DEFAULT_STACK_SIZE]; |
77 | static char scroll_name[] = "scroll"; | 88 | static char scroll_name[] = "scroll"; |
@@ -265,6 +276,7 @@ void lcd_clear_display(void) | |||
265 | bool update=false; | 276 | bool update=false; |
266 | DEBUGF("lcd_clear_display()\n"); | 277 | DEBUGF("lcd_clear_display()\n"); |
267 | lcd_stop_scroll(); | 278 | lcd_stop_scroll(); |
279 | cursor.len=0; /* Stop cursor */ | ||
268 | for (i=0;i<22;i++) | 280 | for (i=0;i<22;i++) |
269 | update|=lcdx_putc(i%11, i/11, ' '); | 281 | update|=lcdx_putc(i%11, i/11, ' '); |
270 | if (update) | 282 | if (update) |
@@ -301,6 +313,18 @@ void lcd_puts(int x, int y, unsigned char *string) | |||
301 | return lcd_puts_cont_scroll(x, y, string); | 313 | return lcd_puts_cont_scroll(x, y, string); |
302 | } | 314 | } |
303 | 315 | ||
316 | void lcd_put_cursor(int x, int y, char cursor_char) | ||
317 | { | ||
318 | cursor.text[0]=buffer_xlcd[x][y]; | ||
319 | cursor.text[1]=cursor_char; | ||
320 | cursor.len=2; | ||
321 | cursor.textpos=0; | ||
322 | cursor.y_pos=y; | ||
323 | cursor.x_pos=x; | ||
324 | cursor.downcount=0; | ||
325 | cursor.divider=4; | ||
326 | } | ||
327 | |||
304 | void lcd_putc(int x, int y, unsigned short ch) | 328 | void lcd_putc(int x, int y, unsigned short ch) |
305 | { | 329 | { |
306 | bool update; | 330 | bool update; |
@@ -573,7 +597,16 @@ static void scroll_thread(void) | |||
573 | lcd_puts_cont_scroll(s->startx, s->starty, buffer); | 597 | lcd_puts_cont_scroll(s->startx, s->starty, buffer); |
574 | } | 598 | } |
575 | } | 599 | } |
576 | 600 | if (cursor.len>0) { | |
601 | if (cursor.downcount--<0) { | ||
602 | cursor.downcount=cursor.divider; | ||
603 | cursor.textpos++; | ||
604 | if (cursor.textpos>=cursor.len) | ||
605 | cursor.textpos=0; | ||
606 | update|=lcdx_putc(cursor.x_pos, cursor.y_pos, | ||
607 | cursor.text[cursor.textpos]); | ||
608 | } | ||
609 | } | ||
577 | if (update) { | 610 | if (update) { |
578 | lcd_update(); | 611 | lcd_update(); |
579 | } | 612 | } |
diff --git a/firmware/drivers/lcd.h b/firmware/drivers/lcd.h index 6fe07c1924..b4623c2ae7 100644 --- a/firmware/drivers/lcd.h +++ b/firmware/drivers/lcd.h | |||
@@ -85,6 +85,7 @@ unsigned char lcd_get_locked_pattern(void); | |||
85 | void lcd_unlock_pattern(unsigned char pat); | 85 | void lcd_unlock_pattern(unsigned char pat); |
86 | void lcd_allow_bidirectional_scrolling(bool on); | 86 | void lcd_allow_bidirectional_scrolling(bool on); |
87 | extern void lcd_bidir_scroll(int threshold); | 87 | extern void lcd_bidir_scroll(int threshold); |
88 | void lcd_put_cursor(int x, int y, char cursor_char); | ||
88 | #endif | 89 | #endif |
89 | 90 | ||
90 | #if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR) | 91 | #if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR) |