summaryrefslogtreecommitdiff
path: root/firmware/drivers/lcd-2bit-horz.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-2bit-horz.c
parent885cdfdeb98d54b2597e65f1b9ae9ab98da8286f (diff)
downloadrockbox-58fc279d2674b5d56fed6772f82cdf1e431088f1.tar.gz
rockbox-58fc279d2674b5d56fed6772f82cdf1e431088f1.zip
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-2bit-horz.c')
-rw-r--r--firmware/drivers/lcd-2bit-horz.c176
1 files changed, 57 insertions, 119 deletions
diff --git a/firmware/drivers/lcd-2bit-horz.c b/firmware/drivers/lcd-2bit-horz.c
index d3d086a9d2..48fd22f703 100644
--- a/firmware/drivers/lcd-2bit-horz.c
+++ b/firmware/drivers/lcd-2bit-horz.c
@@ -33,8 +33,7 @@
33#include "font.h" 33#include "font.h"
34#include "rbunicode.h" 34#include "rbunicode.h"
35#include "bidi.h" 35#include "bidi.h"
36 36#include "scroll_engine.h"
37#define SCROLLABLE_LINES (((LCD_HEIGHT+4)/5 < 32) ? (LCD_HEIGHT+4)/5 : 32)
38 37
39/*** globals ***/ 38/*** globals ***/
40 39
@@ -54,33 +53,13 @@ static int xmargin = 0;
54static int ymargin = 0; 53static int ymargin = 0;
55static int curfont = FONT_SYSFIXED; 54static int curfont = FONT_SYSFIXED;
56 55
57/* scrolling */
58static volatile int scrolling_lines=0; /* Bitpattern of which lines are scrolling */
59static void scroll_thread(void);
60static long scroll_stack[DEFAULT_STACK_SIZE/sizeof(long)];
61static const char scroll_name[] = "scroll";
62static int scroll_ticks = 12; /* # of ticks between updates*/
63static int scroll_delay = HZ/2; /* ticks delay before start */
64static int scroll_step = 6; /* pixels per scroll step */
65static int bidir_limit = 50; /* percent */
66static struct scrollinfo scroll[SCROLLABLE_LINES];
67
68static const char scroll_tick_table[16] = {
69 /* Hz values:
70 1, 1.25, 1.55, 2, 2.5, 3.12, 4, 5, 6.25, 8.33, 10, 12.5, 16.7, 20, 25, 33 */
71 100, 80, 64, 50, 40, 32, 25, 20, 16, 12, 10, 8, 6, 5, 4, 3
72};
73
74
75/* LCD init */ 56/* LCD init */
76void lcd_init(void) 57void lcd_init(void)
77{ 58{
78 lcd_clear_display(); 59 lcd_clear_display();
79 /* Call device specific init */ 60 /* Call device specific init */
80 lcd_init_device(); 61 lcd_init_device();
81 create_thread(scroll_thread, scroll_stack, 62 scroll_init();
82 sizeof(scroll_stack), scroll_name IF_PRIO(, PRIORITY_USER_INTERFACE)
83 IF_COP(, CPU, false));
84} 63}
85 64
86/*** parameter handling ***/ 65/*** parameter handling ***/
@@ -143,6 +122,11 @@ void lcd_setfont(int newfont)
143 curfont = newfont; 122 curfont = newfont;
144} 123}
145 124
125int lcd_getfont(void)
126{
127 return curfont;
128}
129
146int lcd_getstringsize(const unsigned char *str, int *w, int *h) 130int lcd_getstringsize(const unsigned char *str, int *w, int *h)
147{ 131{
148 return font_getstringsize(str, w, h, curfont); 132 return font_getstringsize(str, w, h, curfont);
@@ -377,7 +361,8 @@ void lcd_clear_display(void)
377 else 361 else
378 memset(lcd_framebuffer, bg_pattern, sizeof lcd_framebuffer); 362 memset(lcd_framebuffer, bg_pattern, sizeof lcd_framebuffer);
379 } 363 }
380 scrolling_lines = 0; 364
365 lcd_scroll_info.lines = 0;
381} 366}
382 367
383/* Set a single pixel */ 368/* Set a single pixel */
@@ -862,7 +847,7 @@ void lcd_puts_style_offset(int x, int y, const unsigned char *str,
862 int lastmode = drawmode; 847 int lastmode = drawmode;
863 848
864 /* make sure scrolling is turned off on the line we are updating */ 849 /* make sure scrolling is turned off on the line we are updating */
865 scrolling_lines &= ~(1 << y); 850 lcd_scroll_info.lines &= ~(1 << y);
866 851
867 if(!str || !str[0]) 852 if(!str || !str[0])
868 return; 853 return;
@@ -880,46 +865,6 @@ void lcd_puts_style_offset(int x, int y, const unsigned char *str,
880} 865}
881 866
882/*** scrolling ***/ 867/*** scrolling ***/
883
884/* Reverse the invert setting of the scrolling line (if any) at given char
885 position. Setting will go into affect next time line scrolls. */
886void lcd_invertscroll(int x, int y)
887{
888 struct scrollinfo* s;
889
890 (void)x;
891
892 if(y>=SCROLLABLE_LINES) return;
893
894 s = &scroll[y];
895 s->invert = !s->invert;
896}
897
898void lcd_stop_scroll(void)
899{
900 scrolling_lines=0;
901}
902
903void lcd_scroll_speed(int speed)
904{
905 scroll_ticks = scroll_tick_table[speed];
906}
907
908void lcd_scroll_step(int step)
909{
910 scroll_step = step;
911}
912
913void lcd_scroll_delay(int ms)
914{
915 scroll_delay = ms / (HZ / 10);
916}
917
918void lcd_bidir_scroll(int percent)
919{
920 bidir_limit = percent;
921}
922
923void lcd_puts_scroll(int x, int y, const unsigned char *string) 868void lcd_puts_scroll(int x, int y, const unsigned char *string)
924{ 869{
925 lcd_puts_scroll_style(x, y, string, STYLE_DEFAULT); 870 lcd_puts_scroll_style(x, y, string, STYLE_DEFAULT);
@@ -941,11 +886,11 @@ void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *string,
941 struct scrollinfo* s; 886 struct scrollinfo* s;
942 int w, h; 887 int w, h;
943 888
944 if(y>=SCROLLABLE_LINES) return; 889 if(y>=LCD_SCROLLABLE_LINES) return;
945 890
946 s = &scroll[y]; 891 s = &lcd_scroll_info.scroll[y];
947 892
948 s->start_tick = current_tick + scroll_delay; 893 s->start_tick = current_tick + lcd_scroll_info.delay;
949 s->invert = false; 894 s->invert = false;
950 if (style & STYLE_INVERT) { 895 if (style & STYLE_INVERT) {
951 s->invert = true; 896 s->invert = true;
@@ -968,9 +913,9 @@ void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *string,
968 913
969 /* scroll bidirectional or forward only depending on the string 914 /* scroll bidirectional or forward only depending on the string
970 width */ 915 width */
971 if ( bidir_limit ) { 916 if ( lcd_scroll_info.bidir_limit ) {
972 s->bidir = s->width < (LCD_WIDTH - xmargin) * 917 s->bidir = s->width < (LCD_WIDTH - xmargin) *
973 (100 + bidir_limit) / 100; 918 (100 + lcd_scroll_info.bidir_limit) / 100;
974 } 919 }
975 else 920 else
976 s->bidir = false; 921 s->bidir = false;
@@ -988,14 +933,14 @@ void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *string,
988 s->offset = offset; 933 s->offset = offset;
989 s->startx = xmargin + x * s->width / s->len;; 934 s->startx = xmargin + x * s->width / s->len;;
990 s->backward = false; 935 s->backward = false;
991 scrolling_lines |= (1<<y); 936 lcd_scroll_info.lines |= (1<<y);
992 } 937 }
993 else 938 else
994 /* force a bit switch-off since it doesn't scroll */ 939 /* force a bit switch-off since it doesn't scroll */
995 scrolling_lines &= ~(1<<y); 940 lcd_scroll_info.lines &= ~(1<<y);
996} 941}
997 942
998static void scroll_thread(void) 943void lcd_scroll_fn(void)
999{ 944{
1000 struct font* pf; 945 struct font* pf;
1001 struct scrollinfo* s; 946 struct scrollinfo* s;
@@ -1003,58 +948,51 @@ static void scroll_thread(void)
1003 int xpos, ypos; 948 int xpos, ypos;
1004 int lastmode; 949 int lastmode;
1005 950
1006 /* initialize scroll struct array */ 951 for ( index = 0; index < LCD_SCROLLABLE_LINES; index++ ) {
1007 scrolling_lines = 0; 952 /* really scroll? */
1008 953 if ((lcd_scroll_info.lines & (1 << index)) == 0)
1009 while ( 1 ) { 954 continue;
1010 for ( index = 0; index < SCROLLABLE_LINES; index++ ) {
1011 /* really scroll? */
1012 if ( !(scrolling_lines&(1<<index)) )
1013 continue;
1014 955
1015 s = &scroll[index]; 956 s = &lcd_scroll_info.scroll[index];
1016 957
1017 /* check pause */ 958 /* check pause */
1018 if (TIME_BEFORE(current_tick, s->start_tick)) 959 if (TIME_BEFORE(current_tick, s->start_tick))
1019 continue; 960 continue;
1020 961
1021 if (s->backward) 962 if (s->backward)
1022 s->offset -= scroll_step; 963 s->offset -= lcd_scroll_info.step;
1023 else 964 else
1024 s->offset += scroll_step; 965 s->offset += lcd_scroll_info.step;
1025 966
1026 pf = font_get(curfont); 967 pf = font_get(curfont);
1027 xpos = s->startx; 968 xpos = s->startx;
1028 ypos = ymargin + index * pf->height; 969 ypos = ymargin + index * pf->height;
1029 970
1030 if (s->bidir) { /* scroll bidirectional */ 971 if (s->bidir) { /* scroll bidirectional */
1031 if (s->offset <= 0) { 972 if (s->offset <= 0) {
1032 /* at beginning of line */ 973 /* at beginning of line */
1033 s->offset = 0; 974 s->offset = 0;
1034 s->backward = false; 975 s->backward = false;
1035 s->start_tick = current_tick + scroll_delay * 2; 976 s->start_tick = current_tick + lcd_scroll_info.delay * 2;
1036 }
1037 if (s->offset >= s->width - (LCD_WIDTH - xpos)) {
1038 /* at end of line */
1039 s->offset = s->width - (LCD_WIDTH - xpos);
1040 s->backward = true;
1041 s->start_tick = current_tick + scroll_delay * 2;
1042 }
1043 } 977 }
1044 else { 978 if (s->offset >= s->width - (LCD_WIDTH - xpos)) {
1045 /* scroll forward the whole time */ 979 /* at end of line */
1046 if (s->offset >= s->width) 980 s->offset = s->width - (LCD_WIDTH - xpos);
1047 s->offset %= s->width; 981 s->backward = true;
982 s->start_tick = current_tick + lcd_scroll_info.delay * 2;
1048 } 983 }
1049 984 }
1050 lastmode = drawmode; 985 else {
1051 drawmode = s->invert ? 986 /* scroll forward the whole time */
1052 (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; 987 if (s->offset >= s->width)
1053 lcd_putsxyofs(xpos, ypos, s->offset, s->line); 988 s->offset %= s->width;
1054 drawmode = lastmode;
1055 lcd_update_rect(xpos, ypos, LCD_WIDTH - xpos, pf->height);
1056 } 989 }
1057 990
1058 sleep(scroll_ticks); 991 lastmode = drawmode;
992 drawmode = s->invert ?
993 (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID;
994 lcd_putsxyofs(xpos, ypos, s->offset, s->line);
995 drawmode = lastmode;
996 lcd_update_rect(xpos, ypos, LCD_WIDTH - xpos, pf->height);
1059 } 997 }
1060} 998}