summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-12-12 15:20:37 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-12-12 15:20:37 +0000
commita2e98c1cd926efdbfd0fd9f43005068b7684efbe (patch)
tree66185d3ff83eac6daa66fd9ba0cfe4f464fa19f8 /firmware/drivers
parent2950f6c1e72cf7d600dc03b8cdec162aa5ba4676 (diff)
downloadrockbox-a2e98c1cd926efdbfd0fd9f43005068b7684efbe.zip
rockbox-a2e98c1cd926efdbfd0fd9f43005068b7684efbe.tar.gz
rockbox-a2e98c1cd926efdbfd0fd9f43005068b7684efbe.tar.bz2
rockbox-a2e98c1cd926efdbfd0fd9f43005068b7684efbe.tar.xz
Merged Uwe Freese's bidirectional scrolling patch. Added configurable scroll step size and scroll start delay.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2974 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/lcd-player.c11
-rw-r--r--firmware/drivers/lcd-recorder.c105
-rw-r--r--firmware/drivers/lcd.h4
3 files changed, 88 insertions, 32 deletions
diff --git a/firmware/drivers/lcd-player.c b/firmware/drivers/lcd-player.c
index 0d0be69..fd5bf55 100644
--- a/firmware/drivers/lcd-player.c
+++ b/firmware/drivers/lcd-player.c
@@ -69,6 +69,7 @@ static void scroll_thread(void);
static char scroll_stack[DEFAULT_STACK_SIZE];
static char scroll_name[] = "scroll";
static char scroll_speed = 8; /* updates per second */
+static char scroll_delay = HZ/2; /* delay before starting scroll */
static char scroll_spacing = 3; /* spaces between end and start of text */
static long scroll_start_tick;
@@ -282,7 +283,7 @@ void lcd_puts_scroll(int x, int y, unsigned char* string )
struct scrollinfo* s;
int index;
- scroll_start_tick = current_tick + HZ/2;
+ scroll_start_tick = current_tick + scroll_delay;
/* search for the next free entry */
for (index = 0; index < SCROLLABLE_LINES; index++) {
@@ -381,7 +382,7 @@ void lcd_scroll_resume(void)
struct scrollinfo* s;
int index;
- scroll_start_tick = current_tick + HZ/2;
+ scroll_start_tick = current_tick + scroll_delay;
for ( index = 0; index < SCROLLABLE_LINES; index++ ) {
s = &scroll[index];
@@ -396,7 +397,7 @@ void lcd_scroll_resume_line(int line)
struct scrollinfo* s;
int index;
- scroll_start_tick = current_tick + HZ/2;
+ scroll_start_tick = current_tick + scroll_delay;
for ( index = 0; index < SCROLLABLE_LINES; index++ ) {
s = &scroll[index];
@@ -412,6 +413,10 @@ void lcd_scroll_speed(int speed)
scroll_speed = speed;
}
+void lcd_scroll_delay(int ms)
+{
+ scroll_delay = ms / (HZ / 10);
+}
static void scroll_thread(void)
{
struct scrollinfo* s;
diff --git a/firmware/drivers/lcd-recorder.c b/firmware/drivers/lcd-recorder.c
index 1672946..24c4811 100644
--- a/firmware/drivers/lcd-recorder.c
+++ b/firmware/drivers/lcd-recorder.c
@@ -84,14 +84,18 @@ struct scrollinfo {
int offset;
int startx;
int starty;
+ bool backward; /* scroll presently forward or backward? */
+ bool bidir;
+ long start_tick;
};
static void scroll_thread(void);
static char scroll_stack[DEFAULT_STACK_SIZE];
static char scroll_name[] = "scroll";
static char scroll_speed = 8; /* updates per second */
+static int scroll_delay = HZ/2; /* ticks delay before start */
static char scroll_step = 6; /* pixels per scroll step */
-static long scroll_start_tick;
+static int bidir_limit = 50; /* percent */
static struct scrollinfo scroll[SCROLLABLE_LINES];
static int xmargin = 0;
static int ymargin = 0;
@@ -669,8 +673,6 @@ void lcd_puts_scroll(int x, int y, unsigned char* string)
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];
@@ -678,6 +680,7 @@ void lcd_puts_scroll(int x, int y, unsigned char* string)
break;
}
}
+ s->start_tick = current_tick + scroll_delay;
lcd_puts(x,y,string);
lcd_getstringsize(string, &w, &h);
@@ -688,10 +691,24 @@ void lcd_puts_scroll(int x, int y, unsigned char* string)
memset(s->line, 0, sizeof s->line);
strcpy(s->line, string);
- strcat(s->line, " ");
- /* get new width incl. spaces */
+
+ /* get width */
s->width = lcd_getstringsize(s->line, &w, &h);
+ /* scroll bidirectional or forward only depending on the string width */
+ if ( bidir_limit ) {
+ s->bidir = s->width < (LCD_WIDTH - xmargin) *
+ (100 + bidir_limit) / 100;
+ }
+ else
+ s->bidir = false;
+
+ if (!s->bidir) { /* add spaces if scrolling in the round */
+ strcat(s->line, " ");
+ /* get new width incl. spaces */
+ s->width = lcd_getstringsize(s->line, &w, &h);
+ }
+
for (end = s->line; *end; end++);
strncpy(end, string, LCD_WIDTH/2);
@@ -700,6 +717,7 @@ void lcd_puts_scroll(int x, int y, unsigned char* string)
s->offset = 0;
s->startx = x;
s->starty = y;
+ s->backward = false;
}
}
@@ -786,8 +804,6 @@ void lcd_scroll_resume(void)
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 ) {
@@ -801,8 +817,6 @@ 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 &&
@@ -814,9 +828,23 @@ void lcd_scroll_resume_line(int line)
void lcd_scroll_speed(int speed)
{
- scroll_step = speed;
+ scroll_speed = speed;
+}
+
+void lcd_scroll_step(int step)
+{
+ scroll_step = step;
+}
+
+void lcd_scroll_delay(int ms)
+{
+ scroll_delay = ms / (HZ / 10);
}
+void lcd_bidir_scroll(int percent)
+{
+ bidir_limit = percent;
+}
static void scroll_thread(void)
{
struct scrollinfo* s;
@@ -829,31 +857,50 @@ static void scroll_thread(void)
scroll[index].mode = SCROLL_MODE_OFF;
}
- scroll_start_tick = current_tick;
-
while ( 1 ) {
+ for ( index = 0; index < SCROLLABLE_LINES; index++ ) {
+ s = &scroll[index];
- /* wait 0.5s before starting scroll */
- if ( TIME_AFTER(current_tick, scroll_start_tick) ) {
-
- for ( index = 0; index < SCROLLABLE_LINES; index++ ) {
- s = &scroll[index];
- if ( s->mode == SCROLL_MODE_RUN ) {
-
- s->offset += scroll_step;
-
- if (s->offset >= s->width)
- s->offset %= s->width;
+ /* really scroll? */
+ if ( s->mode != SCROLL_MODE_RUN )
+ continue;
- lcd_getstringsize(s->line, &w, &h);
- xpos = xmargin + s->startx * w / s->len;
- ypos = ymargin + s->starty * h;
+ /* check pause */
+ if (TIME_BEFORE(current_tick, s->start_tick))
+ continue;
- lcd_clearrect(xpos, ypos, LCD_WIDTH - xmargin, h);
- lcd_putsxyofs(xpos, ypos, s->offset, s->line);
- lcd_update_rect(xpos, ypos, LCD_WIDTH - xmargin, h);
+ if (s->backward)
+ s->offset -= scroll_step;
+ else
+ s->offset += scroll_step;
+
+ if (s->bidir) { /* scroll bidirectional */
+ if (s->offset <= 0) {
+ /* at beginning of line */
+ s->offset = 0;
+ s->backward = false;
+ s->start_tick = current_tick + scroll_delay * 2;
}
+ if (s->offset >= s->width - (LCD_WIDTH - xmargin)) {
+ /* at end of line */
+ s->offset = s->width - (LCD_WIDTH - xmargin);
+ s->backward = true;
+ s->start_tick = current_tick + scroll_delay * 2;
+ }
+ }
+ else {
+ /* scroll forward the whole time */
+ if (s->offset >= s->width)
+ s->offset %= s->width;
}
+
+ lcd_getstringsize(s->line, &w, &h);
+ xpos = xmargin + s->startx * w / s->len;
+ ypos = ymargin + s->starty * h;
+
+ lcd_clearrect(xpos, ypos, LCD_WIDTH - xmargin, h);
+ lcd_putsxyofs(xpos, ypos, s->offset, s->line);
+ lcd_update_rect(xpos, ypos, LCD_WIDTH - xmargin, h);
}
sleep(HZ/scroll_speed);
diff --git a/firmware/drivers/lcd.h b/firmware/drivers/lcd.h
index d562188..5e1d8f4 100644
--- a/firmware/drivers/lcd.h
+++ b/firmware/drivers/lcd.h
@@ -39,6 +39,7 @@ 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_scroll_delay( int ms );
extern void lcd_set_contrast(int val);
extern void lcd_write( bool command, int byte );
@@ -121,9 +122,12 @@ extern void lcd_clearpixel(int x, int y);
extern void lcd_invertpixel(int x, int y);
extern void lcd_roll(int pixels);
+extern void lcd_bidir_scroll(int threshold);
+extern void lcd_scroll_step(int pixels);
extern void lcd_setfont(int font);
extern void lcd_putsxy(int x, int y, unsigned char *string);
extern int lcd_getstringsize(unsigned char *str, int *w, int *h);
+extern int lcd_getstringsize(unsigned char *str, int *w, int *h);
#endif /* CHARCELLS / BITMAP */