Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide
translations



Rockbox mail archive

Subject: Re: firmware/drivers lcd-player.c,1.4,1.5 lcd-recorder.c,1.6,1.7 lcd.h,1.42,1.43

Re: firmware/drivers lcd-player.c,1.4,1.5 lcd-recorder.c,1.6,1.7 lcd.h,1.42,1.43

From: George Styles <george_at_ripnet.co.uk>
Date: Mon, 21 Oct 2002 14:26:53 +0100

Cool... been waiting for this for some time :)

i am right in saying that we are still limited to 2 lines by default?

thanks
g

----- Original Message -----
From: "Markus Braun" <malle_at_users.sourceforge.net>
To: <rockbox-cvs_at_cool.haxx.se>
Sent: Monday, October 21, 2002 2:14 PM
Subject: cvs: firmware/drivers lcd-player.c,1.4,1.5 lcd-recorder.c,1.6,1.7
lcd.h,1.42,1.43


> Update of /cvsroot/rockbox/firmware/drivers
> In directory usw-pr-cvs1:/tmp/cvs-serv21178/firmware/drivers
>
> Modified Files:
> lcd-player.c lcd-recorder.c lcd.h
> Log Message:
> Added multiline scroll support.
>
>
> Index: lcd-player.c
> ===================================================================
> RCS file: /cvsroot/rockbox/firmware/drivers/lcd-player.c,v
> retrieving revision 1.4
> retrieving revision 1.5
> diff -u -b -r1.4 -r1.5
> --- lcd-player.c 18 Oct 2002 09:24:23 -0000 1.4
> +++ lcd-player.c 21 Oct 2002 13:14:25 -0000 1.5
> _at__at_ -46,9 +46,16 _at__at_
> #define LCD_CURSOR(x,y) ((char)(lcd_cram+((y)*16+(x))))
> #define LCD_ICON(i) ((char)(lcd_iram+i))
>
> +#define SCROLLABLE_LINES 2
> +
> +#define SCROLL_MODE_OFF 0
> +#define SCROLL_MODE_PAUSE 1
> +#define SCROLL_MODE_RUN 2
> +
> /*** generic code ***/
>
> struct scrollinfo {
> + int mode;
> char text[MAX_PATH];
> char line[32];
> int textlen;
> _at__at_ -63,10 +70,10 _at__at_
> static char scroll_name[] = "scroll";
> static char scroll_speed = 8; /* updates per second */
> static char scroll_spacing = 3; /* spaces between end and start of text
*/
> +static long scroll_start_tick;
>
>
> -static struct scrollinfo scroll; /* only one scroll line at the moment */
> -static int scroll_count = 0;
> +static struct scrollinfo scroll[SCROLLABLE_LINES];
>
> static const unsigned char new_lcd_ascii[] = {
> 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
> _at__at_ -272,13 +279,26 _at__at_
>
> void lcd_puts_scroll(int x, int y, unsigned char* string )
> {
> - struct scrollinfo* s = &scroll;
> + struct scrollinfo* s;
> + int index;
> +
> + scroll_start_tick = current_tick + HZ/2;
> +
> + /* search for the next free entry */
> + for (index = 0; index < SCROLLABLE_LINES; index++) {
> + s = &scroll[index];
> + if (s->mode == SCROLL_MODE_OFF) {
> + break;
> + }
> + }
> +
> s->space = 11 - x;
>
> lcd_puts(x,y,string);
> s->textlen = strlen(string);
>
> if ( s->textlen > s->space ) {
> + s->mode = SCROLL_MODE_RUN;
> s->offset=s->space;
> s->startx=x;
> s->starty=y;
> _at__at_ -289,31 +309,102 _at__at_
> s->space > (int)sizeof s->line ?
> (int)sizeof s->line : s->space );
> s->line[sizeof s->line - 1] = 0;
> - scroll_count = 1;
> }
> }
>
> -
> void lcd_stop_scroll(void)
> {
> - if ( scroll_count ) {
> - struct scrollinfo* s = &scroll;
> - scroll_count = 0;
> + struct scrollinfo* s;
> + int index;
>
> + for ( index = 0; index < SCROLLABLE_LINES; index++ ) {
> + s = &scroll[index];
> + if ( s->mode == SCROLL_MODE_RUN ||
> + s->mode == SCROLL_MODE_PAUSE ) {
> /* restore scrolled row */
> - lcd_puts(s->startx,s->starty,s->text);
> + lcd_puts(s->startx, s->starty, s->text);
> + s->mode = SCROLL_MODE_OFF;
> + }
> + }
> +
> lcd_update();
> +}
> +
> +void lcd_stop_scroll_line(int line)
> +{
> + struct scrollinfo* s;
> + int index;
> +
> + for ( index = 0; index < SCROLLABLE_LINES; index++ ) {
> + s = &scroll[index];
> + if ( s->startx == line &&
> + ( s->mode == SCROLL_MODE_RUN ||
> + s->mode == SCROLL_MODE_PAUSE )) {
> + /* restore scrolled row */
> + lcd_puts(s->startx, s->starty, s->text);
> + s->mode = SCROLL_MODE_OFF;
> }
> + }
> +
> + lcd_update();
> }
>
> void lcd_scroll_pause(void)
> {
> - scroll_count = 0;
> + struct scrollinfo* s;
> + int index;
> +
> + for ( index = 0; index < SCROLLABLE_LINES; index++ ) {
> + s = &scroll[index];
> + if ( s->mode == SCROLL_MODE_RUN ) {
> + s->mode = SCROLL_MODE_PAUSE;
> + }
> + }
> +}
> +
> +void lcd_scroll_pause_line(int line)
> +{
> + struct scrollinfo* s;
> + int index;
> +
> + for ( index = 0; index < SCROLLABLE_LINES; index++ ) {
> + s = &scroll[index];
> + if ( s->startx == line &&
> + s->mode == SCROLL_MODE_RUN ) {
> + s->mode = SCROLL_MODE_PAUSE;
> + }
> + }
> }
>
> void lcd_scroll_resume(void)
> {
> - scroll_count = 1;
> + struct scrollinfo* s;
> + int index;
> +
> + scroll_start_tick = current_tick + HZ/2;
> +
> + for ( index = 0; index < SCROLLABLE_LINES; index++ ) {
> + s = &scroll[index];
> + if ( s->mode == SCROLL_MODE_PAUSE ) {
> + s->mode = SCROLL_MODE_RUN;
> + }
> + }
> +}
> +
> +void lcd_scroll_resume_line(int line)
> +{
> + struct scrollinfo* s;
> + int index;
> +
> + scroll_start_tick = current_tick + HZ/2;
> +
> + for ( index = 0; index < SCROLLABLE_LINES; index++ ) {
> + s = &scroll[index];
> + if ( s->startx == line &&
> + s->mode == SCROLL_MODE_PAUSE ) {
> + s->mode = SCROLL_MODE_RUN;
> + }
> + }
> }
>
> void lcd_scroll_speed(int speed)
> _at__at_ -323,19 +414,31 _at__at_
>
> static void scroll_thread(void)
> {
> - struct scrollinfo* s = &scroll;
> + struct scrollinfo* s;
> + int index;
> + int i;
> + bool update;
>
> - while ( 1 ) {
> - if ( !scroll_count ) {
> - yield();
> - continue;
> + /* initialize scroll struct array */
> + for (index = 0; index < SCROLLABLE_LINES; index++) {
> + scroll[index].mode = SCROLL_MODE_OFF;
> }
> +
> + scroll_start_tick = current_tick;
> +
> + while ( 1 ) {
> +
> + update = false;
> +
> /* wait 0.5s before starting scroll */
> - if ( scroll_count < scroll_speed/2 )
> - scroll_count++;
> - else {
> - int i;
> - for ( i=0; i<s->space-1; i++ )
> + if ( TIME_AFTER(current_tick, scroll_start_tick) ) {
> +
> + for ( index = 0; index < SCROLLABLE_LINES; index++ ) {
> + s = &scroll[index];
> + if ( s->mode == SCROLL_MODE_RUN ) {
> + update = true;
> +
> + for ( i = 0; i < s->space - 1; i++ )
> s->line[i] = s->line[i+1];
>
> if ( s->offset < s->textlen ) {
> _at__at_ -351,8 +454,14 _at__at_
> }
>
> lcd_puts(s->startx,s->starty,s->line);
> + }
> + }
> +
> + if (update) {
> lcd_update();
> }
> + }
> +
> sleep(HZ/scroll_speed);
> }
> }
>
> Index: lcd-recorder.c
> ===================================================================
> RCS file: /cvsroot/rockbox/firmware/drivers/lcd-recorder.c,v
> retrieving revision 1.6
> retrieving revision 1.7
> diff -u -b -r1.6 -r1.7
> --- lcd-recorder.c 11 Oct 2002 22:17:34 -0000 1.6
> +++ lcd-recorder.c 21 Oct 2002 13:14:25 -0000 1.7
> _at__at_ -70,7 +70,14 _at__at_
>
> #define SCROLL_SPACING 3
>
> +#define SCROLLABLE_LINES 10
> +
> +#define SCROLL_MODE_OFF 0
> +#define SCROLL_MODE_PAUSE 1
> +#define SCROLL_MODE_RUN 2
> +
> struct scrollinfo {
> + int mode;
> char line[MAX_PATH + LCD_WIDTH/2 + SCROLL_SPACING + 2];
> int len; /* length of line in chars */
> int width; /* length of line in pixels */
> _at__at_ -84,8 +91,8 _at__at_
> static char scroll_name[] = "scroll";
> static char scroll_speed = 8; /* updates per second */
> static char scroll_step = 6; /* pixels per scroll step */
> -static struct scrollinfo scroll; /* only one scroll line at the moment */
> -static int scroll_count = 0;
> +static long scroll_start_tick;
> +static struct scrollinfo scroll[SCROLLABLE_LINES];
> static int xmargin = 0;
> static int ymargin = 0;
> static int curfont = FONT_SYSFIXED;
> _at__at_ -656,16 +663,26 _at__at_
> INVERT_PIXEL(x,y);
> }
>
> -void lcd_puts_scroll(int x, int y, unsigned char* string )
> +void lcd_puts_scroll(int x, int y, unsigned char* string)
> {
> - struct scrollinfo* s = &scroll;
> + struct scrollinfo* s;
> int w, h;
> + int index;
> +
> + scroll_start_tick = current_tick + HZ/2;
> +
> + /* search for the next free entry */
> + for (index = 0; index < SCROLLABLE_LINES; index++) {
> + s = &scroll[index];
> + if (s->mode == SCROLL_MODE_OFF) {
> + break;
> + }
> + }
>
> lcd_puts(x,y,string);
> lcd_getstringsize(string, &w, &h);
>
> - if (LCD_WIDTH - x*8 - xmargin < w)
> - {
> + if (LCD_WIDTH - x * 8 - xmargin < w) {
> /* prepare scroll line */
> char *end;
>
> _at__at_ -678,42 +695,121 _at__at_
> for (end = s->line; *end; end++);
> strncpy(end, string, LCD_WIDTH/2);
>
> + s->mode = SCROLL_MODE_RUN;
> s->len = strlen(string);
> s->offset = 0;
> s->startx = x;
> s->starty = y;
> - scroll_count = 1;
> }
> }
>
> -
> void lcd_stop_scroll(void)
> {
> - if ( scroll_count ) {
> + struct scrollinfo* s;
> int w,h;
> - struct scrollinfo* s = &scroll;
> - scroll_count = 0;
> + int index;
>
> + for ( index = 0; index < SCROLLABLE_LINES; index++ ) {
> + s = &scroll[index];
> + if ( s->mode == SCROLL_MODE_RUN ||
> + s->mode == SCROLL_MODE_PAUSE ) {
> lcd_getstringsize(s->line, &w, &h);
> - lcd_clearrect(xmargin + s->startx*w/s->len,
> - ymargin + s->starty*h,
> + lcd_clearrect(xmargin + s->startx * w / s->len,
> + ymargin + s->starty * h,
> LCD_WIDTH - xmargin,
> h);
>
> /* restore scrolled row */
> - lcd_puts(s->startx,s->starty,s->line);
> + lcd_puts(s->startx, s->starty, s->line);
> + s->mode = SCROLL_MODE_OFF;
> + }
> + }
> +
> lcd_update();
> +}
> +
> +void lcd_stop_scroll_line(int line)
> +{
> + struct scrollinfo* s;
> + int w,h;
> + int index;
> +
> + for ( index = 0; index < SCROLLABLE_LINES; index++ ) {
> + s = &scroll[index];
> + if ( s->startx == line &&
> + ( s->mode == SCROLL_MODE_RUN ||
> + s->mode == SCROLL_MODE_PAUSE )) {
> + lcd_getstringsize(s->line, &w, &h);
> + lcd_clearrect(xmargin + s->startx * w / s->len,
> + ymargin + s->starty * h,
> + LCD_WIDTH - xmargin,
> + h);
> +
> + /* restore scrolled row */
> + lcd_puts(s->startx, s->starty, s->line);
> + s->mode = SCROLL_MODE_OFF;
> }
> + }
> +
> + lcd_update();
> }
>
> void lcd_scroll_pause(void)
> {
> - scroll_count = 0;
> + struct scrollinfo* s;
> + int index;
> +
> + for ( index = 0; index < SCROLLABLE_LINES; index++ ) {
> + s = &scroll[index];
> + if ( s->mode == SCROLL_MODE_RUN ) {
> + s->mode = SCROLL_MODE_PAUSE;
> + }
> + }
> +}
> +
> +void lcd_scroll_pause_line(int line)
> +{
> + struct scrollinfo* s;
> + int index;
> +
> + for ( index = 0; index < SCROLLABLE_LINES; index++ ) {
> + s = &scroll[index];
> + if ( s->startx == line &&
> + s->mode == SCROLL_MODE_RUN ) {
> + s->mode = SCROLL_MODE_PAUSE;
> + }
> + }
> }
>
> void lcd_scroll_resume(void)
> {
> - scroll_count = 1;
> + struct scrollinfo* s;
> + int index;
> +
> + scroll_start_tick = current_tick + HZ/2;
> +
> + for ( index = 0; index < SCROLLABLE_LINES; index++ ) {
> + s = &scroll[index];
> + if ( s->mode == SCROLL_MODE_PAUSE ) {
> + s->mode = SCROLL_MODE_RUN;
> + }
> + }
> +}
> +
> +void lcd_scroll_resume_line(int line)
> +{
> + struct scrollinfo* s;
> + int index;
> +
> + scroll_start_tick = current_tick + HZ/2;
> +
> + for ( index = 0; index < SCROLLABLE_LINES; index++ ) {
> + s = &scroll[index];
> + if ( s->startx == line &&
> + s->mode == SCROLL_MODE_PAUSE ) {
> + s->mode = SCROLL_MODE_RUN;
> + }
> + }
> }
>
> void lcd_scroll_speed(int speed)
> _at__at_ -723,19 +819,30 _at__at_
>
> static void scroll_thread(void)
> {
> - struct scrollinfo* s = &scroll;
> + struct scrollinfo* s;
> + int index;
> + int w, h;
> + int xpos, ypos;
> + bool update;
>
> - while ( 1 ) {
> - if ( !scroll_count ) {
> - yield();
> - continue;
> + /* initialize scroll struct array */
> + for (index = 0; index < SCROLLABLE_LINES; index++) {
> + scroll[index].mode = SCROLL_MODE_OFF;
> }
> +
> + scroll_start_tick = current_tick;
> +
> + while ( 1 ) {
> +
> + update = false;
> +
> /* wait 0.5s before starting scroll */
> - if ( scroll_count < scroll_speed/2 )
> - scroll_count++;
> - else {
> - int w, h;
> - int xpos, ypos;
> + if ( TIME_AFTER(current_tick, scroll_start_tick) ) {
> +
> + for ( index = 0; index < SCROLLABLE_LINES; index++ ) {
> + s = &scroll[index];
> + if ( s->mode == SCROLL_MODE_RUN ) {
> + update = true;
>
> s->offset += scroll_step;
>
> _at__at_ -748,8 +855,14 _at__at_
>
> lcd_clearrect(xpos, ypos, LCD_WIDTH - xmargin, h);
> lcd_putsxyofs(xpos, ypos, s->offset, s->line);
> + }
> + }
> +
> + if (update) {
> lcd_update();
> }
> + }
> +
> sleep(HZ/scroll_speed);
> }
> }
>
> Index: lcd.h
> ===================================================================
> RCS file: /cvsroot/rockbox/firmware/drivers/lcd.h,v
> retrieving revision 1.42
> retrieving revision 1.43
> diff -u -b -r1.42 -r1.43
> --- lcd.h 17 Oct 2002 18:44:02 -0000 1.42
> +++ lcd.h 21 Oct 2002 13:14:25 -0000 1.43
> _at__at_ -31,10 +31,13 _at__at_
> extern void lcd_puts(int x, int y, unsigned char *string);
> extern void lcd_putc(int x, int y, unsigned char ch);
> extern void lcd_scroll_pause(void);
> +extern void lcd_scroll_pause_line(int line);
> extern void lcd_scroll_resume(void);
> +extern void lcd_scroll_resume_line(int line);
> extern void lcd_puts_scroll(int x, int y, unsigned char* string );
> extern void lcd_icon(int icon, bool enable);
> extern void lcd_stop_scroll(void);
> +extern void lcd_stop_scroll_line(int line);
> extern void lcd_scroll_speed( int speed );
> extern void lcd_set_contrast(int val);
> extern void lcd_write( bool command, int byte );
>
>
Received on 2002-10-21

Page template was last modified "Tue Sep 7 00:00:02 2021" The Rockbox Crew -- Privacy Policy