forked from len0rd/rockbox
Added delay before starting scroll
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@938 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
42770ea88e
commit
f40a826000
1 changed files with 33 additions and 24 deletions
|
|
@ -100,6 +100,8 @@
|
||||||
|
|
||||||
/*** generic code ***/
|
/*** generic code ***/
|
||||||
|
|
||||||
|
#define SCROLL_DELAY 10 /* number of "scroll ticks" until scroll starts */
|
||||||
|
|
||||||
struct scrollinfo {
|
struct scrollinfo {
|
||||||
char text[128];
|
char text[128];
|
||||||
int textlen;
|
int textlen;
|
||||||
|
|
@ -115,7 +117,7 @@ static char scroll_stack[0x100];
|
||||||
static char scroll_speed = 10; /* updates per second */
|
static char scroll_speed = 10; /* updates per second */
|
||||||
|
|
||||||
static struct scrollinfo scroll; /* only one scroll line at the moment */
|
static struct scrollinfo scroll; /* only one scroll line at the moment */
|
||||||
static bool run_scroll = false;
|
static int scroll_count = 0;
|
||||||
|
|
||||||
#ifndef SIMULATOR
|
#ifndef SIMULATOR
|
||||||
/*
|
/*
|
||||||
|
|
@ -773,6 +775,7 @@ void lcd_puts_scroll(int x, int y, char* string )
|
||||||
lcd_getfontsize(font, &width, &height);
|
lcd_getfontsize(font, &width, &height);
|
||||||
s->space = (LCD_WIDTH - xmargin - x) / width;
|
s->space = (LCD_WIDTH - xmargin - x) / width;
|
||||||
#endif
|
#endif
|
||||||
|
lcd_puts(x,y,string);
|
||||||
s->offset=0;
|
s->offset=0;
|
||||||
s->xpos=x;
|
s->xpos=x;
|
||||||
s->startx=x;
|
s->startx=x;
|
||||||
|
|
@ -781,19 +784,19 @@ void lcd_puts_scroll(int x, int y, char* string )
|
||||||
strncpy(s->text,string,sizeof s->text);
|
strncpy(s->text,string,sizeof s->text);
|
||||||
s->text[sizeof s->text - 1] = 0;
|
s->text[sizeof s->text - 1] = 0;
|
||||||
|
|
||||||
run_scroll = true;
|
scroll_count = 1;
|
||||||
lcd_puts(s->xpos,y,s->text + s->offset);
|
|
||||||
lcd_update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_stop_scroll(void)
|
void lcd_stop_scroll(void)
|
||||||
{
|
{
|
||||||
struct scrollinfo* s = &scroll;
|
if ( scroll_count ) {
|
||||||
run_scroll = false;
|
struct scrollinfo* s = &scroll;
|
||||||
|
scroll_count = 0;
|
||||||
/* restore scrolled row */
|
|
||||||
lcd_puts(s->startx,s->starty,s->text);
|
/* restore scrolled row */
|
||||||
lcd_update();
|
lcd_puts(s->startx,s->starty,s->text);
|
||||||
|
lcd_update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_scroll_speed(int speed)
|
void lcd_scroll_speed(int speed)
|
||||||
|
|
@ -805,23 +808,29 @@ static void scroll_thread(void)
|
||||||
{
|
{
|
||||||
struct scrollinfo* s = &scroll;
|
struct scrollinfo* s = &scroll;
|
||||||
while ( 1 ) {
|
while ( 1 ) {
|
||||||
if ( !run_scroll ) {
|
if ( !scroll_count ) {
|
||||||
yield();
|
yield();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
lcd_puts(s->xpos,s->starty,s->text + s->offset);
|
if ( scroll_count < SCROLL_DELAY )
|
||||||
if ( s->textlen - s->offset < s->space )
|
scroll_count++;
|
||||||
lcd_puts(s->startx + s->textlen - s->offset, s->starty," ");
|
else {
|
||||||
lcd_update();
|
lcd_puts(s->xpos,s->starty,s->text + s->offset);
|
||||||
|
debugf("puts(%2d,%s)\n",s->xpos,s->text+s->offset);
|
||||||
if ( s->xpos > s->startx )
|
if ( s->textlen - s->offset < s->space )
|
||||||
s->xpos--;
|
lcd_puts(s->startx + s->textlen - s->offset, s->starty," ");
|
||||||
else
|
lcd_update();
|
||||||
s->offset++;
|
|
||||||
|
if ( s->xpos > s->startx )
|
||||||
if (s->offset > s->textlen) {
|
s->xpos--;
|
||||||
s->offset=0;
|
else
|
||||||
s->xpos = s->space-1;
|
s->offset++;
|
||||||
|
|
||||||
|
if (s->offset > s->textlen) {
|
||||||
|
scroll_count = SCROLL_DELAY; /* prevent wrap */
|
||||||
|
s->offset=0;
|
||||||
|
s->xpos = s->space;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sleep(HZ/scroll_speed);
|
sleep(HZ/scroll_speed);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue