From 565505abd4f4fe6aec3ac3a8c12f1b55018cb4d3 Mon Sep 17 00:00:00 2001 From: Kjell Ericson Date: Mon, 27 Jan 2003 14:37:03 +0000 Subject: Added a "cursor"-function for the keyvoard. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3171 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/lcd-player.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'firmware/drivers/lcd-player.c') 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 { int direction; /* +1 for right or -1 for left*/ }; +#define MAX_CURSOR_CHARS 8 +struct cursorinfo { + int len; + char text[MAX_CURSOR_CHARS]; + int textpos; + int y_pos; + int x_pos; + int divider; + int downcount; +} cursor; + static void scroll_thread(void); static char scroll_stack[DEFAULT_STACK_SIZE]; static char scroll_name[] = "scroll"; @@ -265,6 +276,7 @@ void lcd_clear_display(void) bool update=false; DEBUGF("lcd_clear_display()\n"); lcd_stop_scroll(); + cursor.len=0; /* Stop cursor */ for (i=0;i<22;i++) update|=lcdx_putc(i%11, i/11, ' '); if (update) @@ -301,6 +313,18 @@ void lcd_puts(int x, int y, unsigned char *string) return lcd_puts_cont_scroll(x, y, string); } +void lcd_put_cursor(int x, int y, char cursor_char) +{ + cursor.text[0]=buffer_xlcd[x][y]; + cursor.text[1]=cursor_char; + cursor.len=2; + cursor.textpos=0; + cursor.y_pos=y; + cursor.x_pos=x; + cursor.downcount=0; + cursor.divider=4; +} + void lcd_putc(int x, int y, unsigned short ch) { bool update; @@ -573,7 +597,16 @@ static void scroll_thread(void) lcd_puts_cont_scroll(s->startx, s->starty, buffer); } } - + if (cursor.len>0) { + if (cursor.downcount--<0) { + cursor.downcount=cursor.divider; + cursor.textpos++; + if (cursor.textpos>=cursor.len) + cursor.textpos=0; + update|=lcdx_putc(cursor.x_pos, cursor.y_pos, + cursor.text[cursor.textpos]); + } + } if (update) { lcd_update(); } -- cgit v1.2.3