diff options
author | Thomas Martitz <kugel@rockbox.org> | 2013-12-15 00:38:48 +0100 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2013-12-15 00:38:48 +0100 |
commit | c72b454286864d728de676ebdf92288dd04ace45 (patch) | |
tree | bfe7ebfff65c3452b54661eafa844d28d0812a96 | |
parent | 1fc19042f72e9171b79c5a847cbce0c8939888c5 (diff) | |
download | rockbox-c72b454286864d728de676ebdf92288dd04ace45.tar.gz rockbox-c72b454286864d728de676ebdf92288dd04ace45.zip |
Fix reds. Also apply the new scrolling to lcd charcell (this even uncovered an
error).
Change-Id: I29243bb36b6cec1471bd6c0afc64e00547a68c50
-rw-r--r-- | firmware/drivers/lcd-2bit-vert.c | 2 | ||||
-rw-r--r-- | firmware/drivers/lcd-charcell.c | 156 | ||||
-rw-r--r-- | firmware/drivers/lcd-scroll.c | 42 | ||||
-rw-r--r-- | firmware/export/lcd.h | 2 | ||||
-rw-r--r-- | firmware/export/scroll_engine.h | 3 | ||||
-rw-r--r-- | firmware/rolo.c | 1 |
6 files changed, 81 insertions, 125 deletions
diff --git a/firmware/drivers/lcd-2bit-vert.c b/firmware/drivers/lcd-2bit-vert.c index 08ec6cac79..501e568a69 100644 --- a/firmware/drivers/lcd-2bit-vert.c +++ b/firmware/drivers/lcd-2bit-vert.c | |||
@@ -387,7 +387,7 @@ void lcd_clear_viewport(void) | |||
387 | 387 | ||
388 | current_vp->drawmode = lastmode; | 388 | current_vp->drawmode = lastmode; |
389 | 389 | ||
390 | lcd_scroll_stop(current_vp); | 390 | lcd_scroll_stop_viewport(current_vp); |
391 | } | 391 | } |
392 | } | 392 | } |
393 | 393 | ||
diff --git a/firmware/drivers/lcd-charcell.c b/firmware/drivers/lcd-charcell.c index bdd02de1b6..db867cdb0a 100644 --- a/firmware/drivers/lcd-charcell.c +++ b/firmware/drivers/lcd-charcell.c | |||
@@ -110,11 +110,26 @@ void lcd_set_viewport(struct viewport* vp) | |||
110 | #endif | 110 | #endif |
111 | } | 111 | } |
112 | 112 | ||
113 | struct viewport *lcd_get_viewport(bool *is_default) | ||
114 | { | ||
115 | *is_default = (current_vp == &default_vp); | ||
116 | return current_vp; | ||
117 | } | ||
118 | |||
113 | void lcd_update_viewport(void) | 119 | void lcd_update_viewport(void) |
114 | { | 120 | { |
115 | lcd_update(); | 121 | lcd_update(); |
116 | } | 122 | } |
117 | 123 | ||
124 | void lcd_update_viewport_rect(int x, int y, int width, int height) | ||
125 | { | ||
126 | (void) x; | ||
127 | (void) y; | ||
128 | (void) width; | ||
129 | (void) height; | ||
130 | lcd_update(); | ||
131 | } | ||
132 | |||
118 | /** parameter handling **/ | 133 | /** parameter handling **/ |
119 | 134 | ||
120 | int lcd_getwidth(void) | 135 | int lcd_getwidth(void) |
@@ -486,7 +501,7 @@ void lcd_puts_offset(int x, int y, const unsigned char *str, int offset) | |||
486 | return; | 501 | return; |
487 | 502 | ||
488 | /* make sure scrolling is turned off on the line we are updating */ | 503 | /* make sure scrolling is turned off on the line we are updating */ |
489 | lcd_scroll_stop_viewport_line(current_vp, y); | 504 | lcd_scroll_stop_viewport_rect(current_vp, x, y, current_vp->width - x, 1); |
490 | 505 | ||
491 | x = lcd_putsxyofs(x, y, offset, str); | 506 | x = lcd_putsxyofs(x, y, offset, str); |
492 | while (x < current_vp->width) | 507 | while (x < current_vp->width) |
@@ -499,8 +514,9 @@ void lcd_puts_scroll(int x, int y, const unsigned char *string) | |||
499 | lcd_puts_scroll_offset(x, y, string, 0); | 514 | lcd_puts_scroll_offset(x, y, string, 0); |
500 | } | 515 | } |
501 | 516 | ||
502 | void lcd_puts_scroll_offset(int x, int y, const unsigned char *string, | 517 | void lcd_puts_scroll_worker(int x, int y, const unsigned char *string, |
503 | int offset) | 518 | int offset, |
519 | void (*scroll_func)(struct scrollinfo *), void *data) | ||
504 | { | 520 | { |
505 | struct scrollinfo* s; | 521 | struct scrollinfo* s; |
506 | int len; | 522 | int len; |
@@ -509,7 +525,7 @@ void lcd_puts_scroll_offset(int x, int y, const unsigned char *string, | |||
509 | return; | 525 | return; |
510 | 526 | ||
511 | /* remove any previously scrolling line at the same location */ | 527 | /* remove any previously scrolling line at the same location */ |
512 | lcd_scroll_stop_viewport_line(current_vp, y); | 528 | lcd_scroll_stop_viewport_rect(current_vp, x, y, current_vp->width - x, 1); |
513 | 529 | ||
514 | if (lcd_scroll_info.lines >= LCD_SCROLLABLE_LINES) return; | 530 | if (lcd_scroll_info.lines >= LCD_SCROLLABLE_LINES) return; |
515 | 531 | ||
@@ -520,120 +536,48 @@ void lcd_puts_scroll_offset(int x, int y, const unsigned char *string, | |||
520 | lcd_puts_offset(x, y, string, offset); | 536 | lcd_puts_offset(x, y, string, offset); |
521 | len = utf8length(string); | 537 | len = utf8length(string); |
522 | 538 | ||
523 | if (current_vp->width - x < len) | 539 | if (current_vp->width - x >= len) |
524 | { | 540 | return; |
525 | /* prepare scroll line */ | 541 | /* prepare scroll line */ |
526 | char *end; | 542 | strlcpy(s->linebuffer, string, sizeof s->linebuffer); |
527 | int count; | ||
528 | |||
529 | memset(s->line, 0, sizeof s->line); | ||
530 | strlcpy(s->line, string, sizeof s->line); | ||
531 | |||
532 | /* get width */ | ||
533 | s->len = utf8length(s->line); | ||
534 | |||
535 | /* scroll bidirectional or forward only depending on the string width */ | ||
536 | if (lcd_scroll_info.bidir_limit) | ||
537 | { | ||
538 | s->bidir = s->len < (current_vp->width) * | ||
539 | (100 + lcd_scroll_info.bidir_limit) / 100; | ||
540 | } | ||
541 | else | ||
542 | s->bidir = false; | ||
543 | |||
544 | if (!s->bidir) /* add spaces if scrolling in the round */ | ||
545 | { | ||
546 | strlcat(s->line, " ", sizeof s->line); | ||
547 | /* get new width incl. spaces */ | ||
548 | s->len += SCROLL_SPACING; | ||
549 | } | ||
550 | 543 | ||
551 | end = strchr(s->line, '\0'); | 544 | /* scroll bidirectional or forward only depending on the string width */ |
552 | len = sizeof s->line - (end - s->line); | 545 | if (lcd_scroll_info.bidir_limit) |
553 | count = utf8seek(s->line, current_vp->width); | 546 | { |
554 | strlcpy(end, string, MIN(count, len)); | 547 | s->bidir = len < (current_vp->width) * |
555 | 548 | (100 + lcd_scroll_info.bidir_limit) / 100; | |
556 | s->vp = current_vp; | ||
557 | s->y = y; | ||
558 | s->offset = offset; | ||
559 | s->startx = x; | ||
560 | s->backward = false; | ||
561 | lcd_scroll_info.lines++; | ||
562 | } | 549 | } |
550 | else | ||
551 | s->bidir = false; | ||
552 | |||
553 | s->scroll_func = scroll_func; | ||
554 | s->userdata = data; | ||
555 | |||
556 | s->vp = current_vp; | ||
557 | s->x = x; | ||
558 | s->y = y; | ||
559 | s->height = 1; | ||
560 | s->width = current_vp->width - x; | ||
561 | s->offset = offset; | ||
562 | s->backward = false; | ||
563 | lcd_scroll_info.lines++; | ||
563 | } | 564 | } |
564 | 565 | ||
565 | void lcd_scroll_fn(void) | 566 | void lcd_scroll_fn(struct scrollinfo* s) |
566 | { | 567 | { |
567 | struct scrollinfo* s; | 568 | lcd_putsxyofs(s->x, s->y, s->offset, s->line); |
568 | int index; | ||
569 | int xpos, ypos; | ||
570 | bool update; | ||
571 | struct viewport* old_vp = current_vp; | ||
572 | bool makedelay; | ||
573 | |||
574 | update = false; | ||
575 | for ( index = 0; index < lcd_scroll_info.lines; index++ ) { | ||
576 | s = &lcd_scroll_info.scroll[index]; | ||
577 | |||
578 | /* check pause */ | ||
579 | if (TIME_BEFORE(current_tick, s->start_tick)) | ||
580 | continue; | ||
581 | |||
582 | lcd_set_viewport(s->vp); | ||
583 | |||
584 | if (s->backward) | ||
585 | s->offset--; | ||
586 | else | ||
587 | s->offset++; | ||
588 | |||
589 | xpos = s->startx; | ||
590 | ypos = s->y; | ||
591 | |||
592 | makedelay = false; | ||
593 | if (s->bidir) /* scroll bidirectional */ | ||
594 | { | ||
595 | if (s->offset <= 0) { | ||
596 | /* at beginning of line */ | ||
597 | s->offset = 0; | ||
598 | s->backward = false; | ||
599 | makedelay = true; | ||
600 | } | ||
601 | else if (s->offset >= s->len - (current_vp->width - xpos)) { | ||
602 | /* at end of line */ | ||
603 | s->offset = s->len - (current_vp->width - xpos); | ||
604 | s->backward = true; | ||
605 | makedelay = true; | ||
606 | } | ||
607 | } | ||
608 | else /* scroll forward the whole time */ | ||
609 | { | ||
610 | if (s->offset >= s->len) { | ||
611 | s->offset = 0; | ||
612 | makedelay = true; | ||
613 | } | ||
614 | } | ||
615 | |||
616 | if (makedelay) | ||
617 | s->start_tick = current_tick + lcd_scroll_info.delay + | ||
618 | lcd_scroll_info.ticks; | ||
619 | |||
620 | lcd_putsxyofs(xpos, ypos, s->offset, s->line); | ||
621 | update = true; | ||
622 | } | ||
623 | |||
624 | lcd_set_viewport(old_vp); | ||
625 | |||
626 | if (lcd_cursor.enabled) | 569 | if (lcd_cursor.enabled) |
627 | { | 570 | { |
628 | if (--lcd_cursor.downcount <= 0) | 571 | if (--lcd_cursor.downcount <= 0) |
629 | { | 572 | { |
630 | lcd_cursor.downcount = lcd_cursor.divider; | 573 | lcd_cursor.downcount = lcd_cursor.divider; |
631 | lcd_cursor.visible = !lcd_cursor.visible; | 574 | lcd_cursor.visible = !lcd_cursor.visible; |
632 | update = true; | ||
633 | } | 575 | } |
634 | } | 576 | } |
635 | |||
636 | if (update) | ||
637 | lcd_update(); | ||
638 | } | 577 | } |
639 | 578 | ||
579 | void lcd_puts_scroll_offset(int x, int y, const unsigned char *string, | ||
580 | int offset) | ||
581 | { | ||
582 | lcd_puts_scroll_worker(x, y, string, offset, lcd_scroll_fn, NULL); | ||
583 | } | ||
diff --git a/firmware/drivers/lcd-scroll.c b/firmware/drivers/lcd-scroll.c index 31c2cf20b0..d524ce81c8 100644 --- a/firmware/drivers/lcd-scroll.c +++ b/firmware/drivers/lcd-scroll.c | |||
@@ -132,10 +132,10 @@ static void LCDFN(scroll_worker)(void) | |||
132 | struct scroll_screen_info *si = &LCDFN(scroll_info); | 132 | struct scroll_screen_info *si = &LCDFN(scroll_info); |
133 | struct scrollinfo *s; | 133 | struct scrollinfo *s; |
134 | struct viewport *vp; | 134 | struct viewport *vp; |
135 | int step; | ||
135 | 136 | ||
136 | unsigned fg_pattern, bg_pattern, drawmode; | 137 | for ( index = 0; index < si->lines; index++ ) |
137 | 138 | { | |
138 | for ( index = 0; index < si->lines; index++ ) { | ||
139 | s = &si->scroll[index]; | 139 | s = &si->scroll[index]; |
140 | 140 | ||
141 | /* check pause */ | 141 | /* check pause */ |
@@ -154,14 +154,19 @@ static void LCDFN(scroll_worker)(void) | |||
154 | 154 | ||
155 | width = LCDFN(getstringsize)(s->linebuffer, NULL, NULL); | 155 | width = LCDFN(getstringsize)(s->linebuffer, NULL, NULL); |
156 | makedelay = false; | 156 | makedelay = false; |
157 | 157 | #ifdef HAVE_LCD_BITMAP | |
158 | step = si->step; | ||
159 | #else | ||
160 | step = 1; | ||
161 | #endif | ||
162 | |||
158 | if (s->backward) | 163 | if (s->backward) |
159 | s->offset -= si->step; | 164 | s->offset -= step; |
160 | else | 165 | else |
161 | s->offset += si->step; | 166 | s->offset += step; |
162 | |||
163 | if (s->bidir) { /* scroll bidirectional */ | ||
164 | 167 | ||
168 | if (s->bidir) | ||
169 | { /* scroll bidirectional */ | ||
165 | s->line = s->linebuffer; | 170 | s->line = s->linebuffer; |
166 | if (s->offset <= 0) { | 171 | if (s->offset <= 0) { |
167 | /* at beginning of line */ | 172 | /* at beginning of line */ |
@@ -169,15 +174,15 @@ static void LCDFN(scroll_worker)(void) | |||
169 | s->backward = false; | 174 | s->backward = false; |
170 | makedelay = true; | 175 | makedelay = true; |
171 | } | 176 | } |
172 | else if (s->offset >= width - (s->width - s->x)) { | 177 | else if (s->offset >= width - s->width) { |
173 | /* at end of line */ | 178 | /* at end of line */ |
174 | s->offset = width - (s->width - s->x); | 179 | s->offset = width - s->width; |
175 | s->backward = true; | 180 | s->backward = true; |
176 | makedelay = true; | 181 | makedelay = true; |
177 | } | 182 | } |
178 | } | 183 | } |
179 | else { | 184 | else |
180 | 185 | { | |
181 | snprintf(line_buf, sizeof(line_buf)-1, "%s%s%s", | 186 | snprintf(line_buf, sizeof(line_buf)-1, "%s%s%s", |
182 | s->linebuffer, " ", s->linebuffer); | 187 | s->linebuffer, " ", s->linebuffer); |
183 | s->line = line_buf; | 188 | s->line = line_buf; |
@@ -191,17 +196,26 @@ static void LCDFN(scroll_worker)(void) | |||
191 | 196 | ||
192 | /* Stash and restore these three, so that the scroll_func | 197 | /* Stash and restore these three, so that the scroll_func |
193 | * can do whatever it likes without destroying the state */ | 198 | * can do whatever it likes without destroying the state */ |
199 | #ifdef HAVE_LCD_BITMAP | ||
200 | unsigned drawmode; | ||
201 | #if LCD_DEPTH > 1 | ||
202 | unsigned fg_pattern, bg_pattern; | ||
194 | fg_pattern = s->vp->fg_pattern; | 203 | fg_pattern = s->vp->fg_pattern; |
195 | bg_pattern = s->vp->bg_pattern; | 204 | bg_pattern = s->vp->bg_pattern; |
205 | #endif | ||
196 | drawmode = s->vp->drawmode; | 206 | drawmode = s->vp->drawmode; |
197 | 207 | #endif | |
198 | s->scroll_func(s); | 208 | s->scroll_func(s); |
209 | |||
199 | LCDFN(update_viewport_rect)(s->x, s->y, s->width, s->height); | 210 | LCDFN(update_viewport_rect)(s->x, s->y, s->width, s->height); |
200 | 211 | ||
212 | #ifdef HAVE_LCD_BITMAP | ||
213 | #if LCD_DEPTH > 1 | ||
201 | s->vp->fg_pattern = fg_pattern; | 214 | s->vp->fg_pattern = fg_pattern; |
202 | s->vp->bg_pattern = bg_pattern; | 215 | s->vp->bg_pattern = bg_pattern; |
216 | #endif | ||
203 | s->vp->drawmode = drawmode; | 217 | s->vp->drawmode = drawmode; |
204 | 218 | #endif | |
205 | LCDFN(set_viewport)(vp); | 219 | LCDFN(set_viewport)(vp); |
206 | 220 | ||
207 | if (makedelay) | 221 | if (makedelay) |
diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h index 37e6bf4d16..f6b32a37ee 100644 --- a/firmware/export/lcd.h +++ b/firmware/export/lcd.h | |||
@@ -195,6 +195,7 @@ extern int lcd_getstringsize(const unsigned char *str, int *w, int *h); | |||
195 | extern void lcd_set_viewport(struct viewport* vp); | 195 | extern void lcd_set_viewport(struct viewport* vp); |
196 | extern void lcd_update(void); | 196 | extern void lcd_update(void); |
197 | extern void lcd_update_viewport(void); | 197 | extern void lcd_update_viewport(void); |
198 | extern void lcd_update_viewport_rect(int x, int y, int width, int height); | ||
198 | extern void lcd_clear_viewport(void); | 199 | extern void lcd_clear_viewport(void); |
199 | extern void lcd_clear_display(void); | 200 | extern void lcd_clear_display(void); |
200 | extern void lcd_putsxy(int x, int y, const unsigned char *string); | 201 | extern void lcd_putsxy(int x, int y, const unsigned char *string); |
@@ -234,7 +235,6 @@ extern void lcd_blit_grey_phase(unsigned char *values, unsigned char *phases, | |||
234 | 235 | ||
235 | /* update a fraction of the screen */ | 236 | /* update a fraction of the screen */ |
236 | extern void lcd_update_rect(int x, int y, int width, int height); | 237 | extern void lcd_update_rect(int x, int y, int width, int height); |
237 | extern void lcd_update_viewport_rect(int x, int y, int width, int height); | ||
238 | 238 | ||
239 | #ifdef HAVE_REMOTE_LCD | 239 | #ifdef HAVE_REMOTE_LCD |
240 | extern void lcd_remote_update(void); | 240 | extern void lcd_remote_update(void); |
diff --git a/firmware/export/scroll_engine.h b/firmware/export/scroll_engine.h index c7eb97aecc..5e4b744c59 100644 --- a/firmware/export/scroll_engine.h +++ b/firmware/export/scroll_engine.h | |||
@@ -62,9 +62,6 @@ struct scrollinfo | |||
62 | struct viewport* vp; | 62 | struct viewport* vp; |
63 | char linebuffer[9*MAX_PATH/10]; | 63 | char linebuffer[9*MAX_PATH/10]; |
64 | const char *line; | 64 | const char *line; |
65 | #ifdef HAVE_LCD_CHARCELLS | ||
66 | int len; /* length of line in chars */ | ||
67 | #endif | ||
68 | /* rectangle for the line */ | 65 | /* rectangle for the line */ |
69 | int x, y; /* relative to the viewort */ | 66 | int x, y; /* relative to the viewort */ |
70 | int width, height; | 67 | int width, height; |
diff --git a/firmware/rolo.c b/firmware/rolo.c index 79969bbbcf..923199f9d4 100644 --- a/firmware/rolo.c +++ b/firmware/rolo.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #ifdef HAVE_REMOTE_LCD | 24 | #ifdef HAVE_REMOTE_LCD |
25 | #include "lcd-remote.h" | 25 | #include "lcd-remote.h" |
26 | #endif | 26 | #endif |
27 | #include "scroll_engine.h" | ||
27 | #include "thread.h" | 28 | #include "thread.h" |
28 | #include "kernel.h" | 29 | #include "kernel.h" |
29 | #include "button.h" | 30 | #include "button.h" |