summaryrefslogtreecommitdiff
path: root/firmware/drivers/lcd-remote-1bit-v.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-07-28 08:12:05 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-07-28 08:12:05 +0000
commit58fc279d2674b5d56fed6772f82cdf1e431088f1 (patch)
tree07a174bba7430b0ebc3c0f84d39ecb209eec1fc5 /firmware/drivers/lcd-remote-1bit-v.c
parent885cdfdeb98d54b2597e65f1b9ae9ab98da8286f (diff)
Scroll on main and remote with a single thread. Change the way system messages are defined before running out is an issue (which requires a full update of rockbox on the player).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14035 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/lcd-remote-1bit-v.c')
-rw-r--r--firmware/drivers/lcd-remote-1bit-v.c216
1 files changed, 55 insertions, 161 deletions
diff --git a/firmware/drivers/lcd-remote-1bit-v.c b/firmware/drivers/lcd-remote-1bit-v.c
index 6b5b1fb42f..1ddd8e5071 100644
--- a/firmware/drivers/lcd-remote-1bit-v.c
+++ b/firmware/drivers/lcd-remote-1bit-v.c
@@ -31,8 +31,7 @@
#include "font.h"
#include "rbunicode.h"
#include "bidi.h"
-
-#define SCROLLABLE_LINES (((LCD_REMOTE_HEIGHT+4)/5 < 32) ? (LCD_REMOTE_HEIGHT+4)/5 : 32)
+#include "scroll_engine.h"
/*** globals ***/
@@ -44,28 +43,6 @@ static int xmargin = 0;
static int ymargin = 0;
static int curfont = FONT_SYSFIXED;
-/* scrolling */
-static volatile int scrolling_lines=0; /* Bitpattern of which lines are scrolling */
-static void scroll_thread(void);
-static long scroll_stack[DEFAULT_STACK_SIZE/sizeof(long)];
-static const char scroll_name[] = "remote_scroll";
-static int scroll_ticks = 12; /* # of ticks between updates*/
-static int scroll_delay = HZ/2; /* ticks delay before start */
-static int scroll_step = 6; /* pixels per scroll step */
-static int bidir_limit = 50; /* percent */
-static struct scrollinfo scroll[SCROLLABLE_LINES];
-
-static const char scroll_tick_table[16] = {
- /* Hz values:
- 1, 1.25, 1.55, 2, 2.5, 3.12, 4, 5, 6.25, 8.33, 10, 12.5, 16.7, 20, 25, 33 */
- 100, 80, 64, 50, 40, 32, 25, 20, 16, 12, 10, 8, 6, 5, 4, 3
-};
-
-/* remote hotplug */
-#ifndef SIMULATOR
-struct event_queue remote_scroll_queue;
-#endif
-
/*** parameter handling ***/
void lcd_remote_set_drawmode(int mode)
@@ -94,12 +71,16 @@ int lcd_remote_getymargin(void)
return ymargin;
}
-
void lcd_remote_setfont(int newfont)
{
curfont = newfont;
}
+int lcd_remote_getfont(void)
+{
+ return curfont;
+}
+
int lcd_remote_getstringsize(const unsigned char *str, int *w, int *h)
{
return font_getstringsize(str, w, h, curfont);
@@ -208,7 +189,7 @@ void lcd_remote_clear_display(void)
unsigned bits = (drawmode & DRMODE_INVERSEVID) ? 0xFFu : 0;
memset(lcd_remote_framebuffer, bits, sizeof lcd_remote_framebuffer);
- scrolling_lines = 0;
+ lcd_remote_scroll_info.lines = 0;
}
/* Set a single pixel */
@@ -599,7 +580,7 @@ void lcd_remote_bitmap(const unsigned char *src, int x, int y, int width,
}
/* put a string at a given pixel position, skipping first ofs pixel columns */
-static void lcd_remote_putsxyofs(int x, int y, int ofs, const unsigned char *str)
+void lcd_remote_putsxyofs(int x, int y, int ofs, const unsigned char *str)
{
unsigned short ch;
unsigned short *ucs;
@@ -664,7 +645,7 @@ void lcd_remote_puts_style_offset(int x, int y, const unsigned char *str,
int lastmode = drawmode;
/* make sure scrolling is turned off on the line we are updating */
- scrolling_lines &= ~(1 << y);
+ lcd_remote_scroll_info.lines &= ~(1 << y);
if(!str || !str[0])
return;
@@ -683,45 +664,6 @@ void lcd_remote_puts_style_offset(int x, int y, const unsigned char *str,
/*** scrolling ***/
-/* Reverse the invert setting of the scrolling line (if any) at given char
- position. Setting will go into affect next time line scrolls. */
-void lcd_remote_invertscroll(int x, int y)
-{
- struct scrollinfo* s;
-
- (void)x;
-
- if(y>=SCROLLABLE_LINES) return;
-
- s = &scroll[y];
- s->invert = !s->invert;
-}
-
-void lcd_remote_stop_scroll(void)
-{
- scrolling_lines=0;
-}
-
-void lcd_remote_scroll_speed(int speed)
-{
- scroll_ticks = scroll_tick_table[speed];
-}
-
-void lcd_remote_scroll_step(int step)
-{
- scroll_step = step;
-}
-
-void lcd_remote_scroll_delay(int ms)
-{
- scroll_delay = ms / (HZ / 10);
-}
-
-void lcd_remote_bidir_scroll(int percent)
-{
- bidir_limit = percent;
-}
-
void lcd_remote_puts_scroll(int x, int y, const unsigned char *string)
{
lcd_remote_puts_scroll_style(x, y, string, STYLE_DEFAULT);
@@ -743,11 +685,11 @@ void lcd_remote_puts_scroll_style_offset(int x, int y, const unsigned char *stri
struct scrollinfo* s;
int w, h;
- if(y>=SCROLLABLE_LINES) return;
+ if(y>=LCD_REMOTE_SCROLLABLE_LINES) return;
- s = &scroll[y];
+ s = &lcd_remote_scroll_info.scroll[y];
- s->start_tick = current_tick + scroll_delay;
+ s->start_tick = current_tick + lcd_remote_scroll_info.delay;
s->invert = false;
if (style & STYLE_INVERT) {
s->invert = true;
@@ -770,9 +712,9 @@ void lcd_remote_puts_scroll_style_offset(int x, int y, const unsigned char *stri
/* scroll bidirectional or forward only depending on the string
width */
- if ( bidir_limit ) {
+ if ( lcd_remote_scroll_info.bidir_limit ) {
s->bidir = s->width < (LCD_REMOTE_WIDTH - xmargin) *
- (100 + bidir_limit) / 100;
+ (100 + lcd_remote_scroll_info.bidir_limit) / 100;
}
else
s->bidir = false;
@@ -790,110 +732,67 @@ void lcd_remote_puts_scroll_style_offset(int x, int y, const unsigned char *stri
s->offset = offset;
s->startx = xmargin + x * s->width / s->len;;
s->backward = false;
- scrolling_lines |= (1<<y);
+ lcd_remote_scroll_info.lines |= (1<<y);
}
else
/* force a bit switch-off since it doesn't scroll */
- scrolling_lines &= ~(1<<y);
+ lcd_remote_scroll_info.lines &= ~(1<<y);
}
-static void scroll_thread(void)
+void lcd_remote_scroll_fn(void)
{
struct font* pf;
struct scrollinfo* s;
- long next_tick = current_tick;
- long delay = 0;
int index;
int xpos, ypos;
int lastmode;
-#ifndef SIMULATOR
- struct event ev;
-#endif
-
- /* initialize scroll struct array */
- scrolling_lines = 0;
-
- while ( 1 ) {
-
-#ifdef SIMULATOR
- sleep(delay);
-#else
- if (remote_initialized)
- queue_wait_w_tmo(&remote_scroll_queue, &ev, delay);
- else
- queue_wait(&remote_scroll_queue, &ev);
- switch (ev.id)
- {
- case REMOTE_INIT_LCD:
- lcd_remote_on();
- lcd_remote_update();
- break;
-
- case REMOTE_DEINIT_LCD:
- lcd_remote_off();
- break;
- }
-
- delay = next_tick - current_tick - 1;
- if (delay >= 0)
+ for ( index = 0; index < LCD_REMOTE_SCROLLABLE_LINES; index++ ) {
+ /* really scroll? */
+ if ((lcd_remote_scroll_info.lines & (1 << index)) == 0)
continue;
-#endif
- for ( index = 0; index < SCROLLABLE_LINES; index++ ) {
- /* really scroll? */
- if ( !(scrolling_lines&(1<<index)) )
- continue;
- s = &scroll[index];
+ s = &lcd_remote_scroll_info.scroll[index];
- /* check pause */
- if (TIME_BEFORE(current_tick, s->start_tick))
- continue;
+ /* check pause */
+ if (TIME_BEFORE(current_tick, s->start_tick))
+ continue;
- if (s->backward)
- s->offset -= scroll_step;
- else
- s->offset += scroll_step;
-
- pf = font_get(curfont);
- xpos = s->startx;
- ypos = ymargin + index * pf->height;
-
- 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_REMOTE_WIDTH - xpos)) {
- /* at end of line */
- s->offset = s->width - (LCD_REMOTE_WIDTH - xpos);
- s->backward = true;
- s->start_tick = current_tick + scroll_delay * 2;
- }
+ if (s->backward)
+ s->offset -= lcd_remote_scroll_info.step;
+ else
+ s->offset += lcd_remote_scroll_info.step;
+
+ pf = font_get(curfont);
+ xpos = s->startx;
+ ypos = ymargin + index * pf->height;
+
+ if (s->bidir) { /* scroll bidirectional */
+ if (s->offset <= 0) {
+ /* at beginning of line */
+ s->offset = 0;
+ s->backward = false;
+ s->start_tick = current_tick + lcd_remote_scroll_info.delay*2;
}
- else {
- /* scroll forward the whole time */
- if (s->offset >= s->width)
- s->offset %= s->width;
+ if (s->offset >= s->width - (LCD_REMOTE_WIDTH - xpos)) {
+ /* at end of line */
+ s->offset = s->width - (LCD_REMOTE_WIDTH - xpos);
+ s->backward = true;
+ s->start_tick = current_tick + lcd_remote_scroll_info.delay*2;
}
-
- lastmode = drawmode;
- drawmode = s->invert ?
- (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID;
- lcd_remote_putsxyofs(xpos, ypos, s->offset, s->line);
- drawmode = lastmode;
- lcd_remote_update_rect(xpos, ypos, LCD_REMOTE_WIDTH - xpos, pf->height);
}
-
- next_tick += scroll_ticks;
- delay = next_tick - current_tick - 1;
- if (delay < 0)
- {
- next_tick = current_tick + 1;
- delay = 0;
+ else {
+ /* scroll forward the whole time */
+ if (s->offset >= s->width)
+ s->offset %= s->width;
}
+
+ lastmode = drawmode;
+ drawmode = s->invert ?
+ (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID;
+ lcd_remote_putsxyofs(xpos, ypos, s->offset, s->line);
+ drawmode = lastmode;
+ lcd_remote_update_rect(xpos, ypos, LCD_REMOTE_WIDTH - xpos, pf->height);
}
}
@@ -903,10 +802,5 @@ void lcd_remote_init(void)
#ifndef SIMULATOR
/* Call device specific init */
lcd_remote_init_device();
- /* private queue */
- queue_init(&remote_scroll_queue, false);
#endif
- create_thread(scroll_thread, scroll_stack,
- sizeof(scroll_stack), scroll_name IF_PRIO(, PRIORITY_USER_INTERFACE)
- IF_COP(, CPU, false));
}