diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/drivers/lcd.c | 149 | ||||
-rw-r--r-- | firmware/drivers/lcd.h | 17 |
2 files changed, 11 insertions, 155 deletions
diff --git a/firmware/drivers/lcd.c b/firmware/drivers/lcd.c index 5e86647280..fe1e13a522 100644 --- a/firmware/drivers/lcd.c +++ b/firmware/drivers/lcd.c | |||
@@ -529,7 +529,7 @@ void lcd_init (void) | |||
529 | * | 529 | * |
530 | * Memory copy of display bitmap | 530 | * Memory copy of display bitmap |
531 | */ | 531 | */ |
532 | unsigned char display[LCD_WIDTH][LCD_HEIGHT/8] __attribute__ ((section (".idata"))); | 532 | unsigned char lcd_framebuffer[LCD_WIDTH][LCD_HEIGHT/8] __attribute__ ((section (".idata"))); |
533 | 533 | ||
534 | static int font=0; | 534 | static int font=0; |
535 | static int xmargin=0; | 535 | static int xmargin=0; |
@@ -590,7 +590,7 @@ void lcd_update (void) | |||
590 | lcd_write (true, LCD_CNTL_LOWCOL); | 590 | lcd_write (true, LCD_CNTL_LOWCOL); |
591 | 591 | ||
592 | for (x = 0; x < LCD_WIDTH; x++) | 592 | for (x = 0; x < LCD_WIDTH; x++) |
593 | lcd_write (false, display[x][y]); | 593 | lcd_write (false, lcd_framebuffer[x][y]); |
594 | } | 594 | } |
595 | } | 595 | } |
596 | 596 | ||
@@ -601,7 +601,7 @@ void lcd_update (void) | |||
601 | */ | 601 | */ |
602 | void lcd_clear_display (void) | 602 | void lcd_clear_display (void) |
603 | { | 603 | { |
604 | memset (display, 0, sizeof display); | 604 | memset (lcd_framebuffer, 0, sizeof lcd_framebuffer); |
605 | #if defined(SIMULATOR) && defined(HAVE_LCD_CHARCELLS) | 605 | #if defined(SIMULATOR) && defined(HAVE_LCD_CHARCELLS) |
606 | /* this function is being used when simulating a charcell LCD and | 606 | /* this function is being used when simulating a charcell LCD and |
607 | then we update immediately */ | 607 | then we update immediately */ |
@@ -791,7 +791,7 @@ void lcd_bitmap (unsigned char *src, int x, int y, int nx, int ny, | |||
791 | ny = LCD_HEIGHT - y; | 791 | ny = LCD_HEIGHT - y; |
792 | 792 | ||
793 | shift = y & 7; | 793 | shift = y & 7; |
794 | dst2 = &display[x][y/8]; | 794 | dst2 = &lcd_framebuffer[x][y/8]; |
795 | ny += shift; | 795 | ny += shift; |
796 | 796 | ||
797 | /* Calculate bit masks */ | 797 | /* Calculate bit masks */ |
@@ -881,9 +881,6 @@ void lcd_invertrect (int x, int y, int nx, int ny) | |||
881 | lcd_bitmap (ones, x+i, y, 1, ny, false); | 881 | lcd_bitmap (ones, x+i, y, 1, ny, false); |
882 | } | 882 | } |
883 | 883 | ||
884 | #define DRAW_PIXEL(x,y) display[x][y/8] |= (1<<(y&7)) | ||
885 | #define CLEAR_PIXEL(x,y) display[x][y/8] &= ~(1<<(y&7)) | ||
886 | |||
887 | void lcd_drawline( int x1, int y1, int x2, int y2 ) | 884 | void lcd_drawline( int x1, int y1, int x2, int y2 ) |
888 | { | 885 | { |
889 | int numpixels; | 886 | int numpixels; |
@@ -1051,144 +1048,6 @@ void lcd_getfontsize(unsigned int font, int *width, int *height) | |||
1051 | } | 1048 | } |
1052 | } | 1049 | } |
1053 | 1050 | ||
1054 | /* | ||
1055 | * Print a progress bar | ||
1056 | */ | ||
1057 | void lcd_progressbar(int x, int y, int width, int height, int percent, int direction) | ||
1058 | { | ||
1059 | int pos; | ||
1060 | int i,j; | ||
1061 | |||
1062 | /* draw horizontal lines */ | ||
1063 | for(i=x+1;i<=x+width-2;i++) { | ||
1064 | DRAW_PIXEL(i,y); | ||
1065 | DRAW_PIXEL(i,(y+height-1)); | ||
1066 | } | ||
1067 | |||
1068 | /* draw vertical lines */ | ||
1069 | for(i=1;i<height;i++) { | ||
1070 | DRAW_PIXEL(x,(y+i)); | ||
1071 | DRAW_PIXEL((x+width-1),(y+i)); | ||
1072 | } | ||
1073 | |||
1074 | /* clear edge pixels */ | ||
1075 | CLEAR_PIXEL(x,y); | ||
1076 | CLEAR_PIXEL((x+width-1),y); | ||
1077 | CLEAR_PIXEL(x,(y+height-1)); | ||
1078 | CLEAR_PIXEL((x+width-1),(y+height-1)); | ||
1079 | |||
1080 | /* clear pixels in progress bar */ | ||
1081 | for(i=1;i<=width-2;i++) { | ||
1082 | for(j=1;j<=height-2;j++) { | ||
1083 | CLEAR_PIXEL((x+i),(y+j)); | ||
1084 | CLEAR_PIXEL((x+i),(y+j)); | ||
1085 | } | ||
1086 | } | ||
1087 | |||
1088 | /* draw bar */ | ||
1089 | pos=percent; | ||
1090 | if(pos<0) | ||
1091 | pos=0; | ||
1092 | if(pos>100) | ||
1093 | pos=100; | ||
1094 | |||
1095 | switch (direction) | ||
1096 | { | ||
1097 | case BAR_RIGHT: | ||
1098 | pos=(width-2)*pos/100; | ||
1099 | for(i=1;i<=pos;i++) | ||
1100 | for(j=1;j<height-1;j++) | ||
1101 | DRAW_PIXEL((x+i),(y+j)); | ||
1102 | break; | ||
1103 | case BAR_LEFT: | ||
1104 | pos=(width-2)*(100-pos)/100; | ||
1105 | for(i=pos+1;i<=width-2;i++) | ||
1106 | for(j=1;j<height-1;j++) | ||
1107 | DRAW_PIXEL((x+i),(y+j)); | ||
1108 | break; | ||
1109 | case BAR_DOWN: | ||
1110 | pos=(height-2)*pos/100; | ||
1111 | for(i=1;i<=pos;i++) | ||
1112 | for(j=1;j<width-1;j++) | ||
1113 | DRAW_PIXEL((x+j),(y+i)); | ||
1114 | break; | ||
1115 | case BAR_UP: | ||
1116 | pos=(height-2)*(100-pos)/100; | ||
1117 | for(i=pos+1;i<=height-2;i++) | ||
1118 | for(j=1;j<width-1;j++) | ||
1119 | DRAW_PIXEL((x+j),(y+i)); | ||
1120 | break; | ||
1121 | } | ||
1122 | |||
1123 | } | ||
1124 | |||
1125 | |||
1126 | /* | ||
1127 | * Print a slidebar bar | ||
1128 | */ | ||
1129 | void lcd_slidebar(int x, int y, int width, int height, int percent, int direction) | ||
1130 | { | ||
1131 | int pos; | ||
1132 | int i,j; | ||
1133 | |||
1134 | /* draw horizontal lines */ | ||
1135 | for(i=x+1;i<=x+width-2;i++) { | ||
1136 | DRAW_PIXEL(i,y); | ||
1137 | DRAW_PIXEL(i,(y+height-1)); | ||
1138 | } | ||
1139 | |||
1140 | /* draw vertical lines */ | ||
1141 | for(i=1;i<height;i++) { | ||
1142 | DRAW_PIXEL(x,(y+i)); | ||
1143 | DRAW_PIXEL((x+width-1),(y+i)); | ||
1144 | } | ||
1145 | |||
1146 | /* clear edge pixels */ | ||
1147 | CLEAR_PIXEL(x,y); | ||
1148 | CLEAR_PIXEL((x+width-1),y); | ||
1149 | CLEAR_PIXEL(x,(y+height-1)); | ||
1150 | CLEAR_PIXEL((x+width-1),(y+height-1)); | ||
1151 | |||
1152 | /* clear pixels in progress bar */ | ||
1153 | for(i=1;i<=width-2;i++) | ||
1154 | for(j=1;j<=height-2;j++) { | ||
1155 | CLEAR_PIXEL((x+i),(y+j)); | ||
1156 | CLEAR_PIXEL((x+i),(y+j)); | ||
1157 | } | ||
1158 | |||
1159 | /* draw point */ | ||
1160 | pos=percent; | ||
1161 | if(pos<0) | ||
1162 | pos=0; | ||
1163 | if(pos>100) | ||
1164 | pos=100; | ||
1165 | |||
1166 | switch (direction) | ||
1167 | { | ||
1168 | case BAR_RIGHT: | ||
1169 | pos=(width-height-1)*pos/100; | ||
1170 | break; | ||
1171 | case BAR_LEFT: | ||
1172 | pos=(width-height-1)*(100-pos)/100; | ||
1173 | break; | ||
1174 | case BAR_DOWN: | ||
1175 | pos=(height-width-1)*pos/100; | ||
1176 | break; | ||
1177 | case BAR_UP: | ||
1178 | pos=(height-width-1)*(100-pos)/100; | ||
1179 | break; | ||
1180 | } | ||
1181 | |||
1182 | if(direction == BAR_LEFT || direction == BAR_RIGHT) | ||
1183 | for(i=1;i<height;i++) | ||
1184 | for(j=1;j<height;j++) | ||
1185 | DRAW_PIXEL((x+pos+i),(y+j)); | ||
1186 | else | ||
1187 | for(i=1;i<width;i++) | ||
1188 | for(j=1;j<width;j++) | ||
1189 | DRAW_PIXEL((x+i),(y+pos+j)); | ||
1190 | } | ||
1191 | |||
1192 | #else | 1051 | #else |
1193 | /* no LCD defined, no code to use */ | 1052 | /* no LCD defined, no code to use */ |
1194 | #endif | 1053 | #endif |
diff --git a/firmware/drivers/lcd.h b/firmware/drivers/lcd.h index c985cb067d..23e333287b 100644 --- a/firmware/drivers/lcd.h +++ b/firmware/drivers/lcd.h | |||
@@ -74,14 +74,13 @@ extern void lcd_double_height (bool on); | |||
74 | #define LCD_WIDTH 112 /* Display width in pixels */ | 74 | #define LCD_WIDTH 112 /* Display width in pixels */ |
75 | #define LCD_HEIGHT 64 /* Display height in pixels */ | 75 | #define LCD_HEIGHT 64 /* Display height in pixels */ |
76 | 76 | ||
77 | /* Directions for progressbar and scrollbar */ | 77 | #define DRAW_PIXEL(x,y) lcd_framebuffer[x][y/8] |= (1<<(y&7)) |
78 | enum | 78 | #define CLEAR_PIXEL(x,y) lcd_framebuffer[x][y/8] &= ~(1<<(y&7)) |
79 | { | 79 | |
80 | BAR_RIGHT = 0, | 80 | /* |
81 | BAR_LEFT, | 81 | * Memory copy of display bitmap |
82 | BAR_DOWN, | 82 | */ |
83 | BAR_UP | 83 | extern unsigned char lcd_framebuffer[LCD_WIDTH][LCD_HEIGHT/8] __attribute__ ((section (".idata"))); |
84 | }; | ||
85 | 84 | ||
86 | extern void lcd_putsxy(int x, int y, unsigned char *string, int font); | 85 | extern void lcd_putsxy(int x, int y, unsigned char *string, int font); |
87 | extern void lcd_setfont(int font); | 86 | extern void lcd_setfont(int font); |
@@ -97,8 +96,6 @@ extern void lcd_drawline( int x1, int y1, int x2, int y2 ); | |||
97 | extern void lcd_clearline( int x1, int y1, int x2, int y2 ); | 96 | extern void lcd_clearline( int x1, int y1, int x2, int y2 ); |
98 | extern void lcd_drawpixel(int x, int y); | 97 | extern void lcd_drawpixel(int x, int y); |
99 | extern void lcd_clearpixel(int x, int y); | 98 | extern void lcd_clearpixel(int x, int y); |
100 | extern void lcd_progressbar(int x, int y, int width, int height, int percent, int direction); | ||
101 | extern void lcd_slidebar(int x, int y, int width, int height, int percent, int direction); | ||
102 | 99 | ||
103 | #endif /* CHARCELLS / BITMAP */ | 100 | #endif /* CHARCELLS / BITMAP */ |
104 | 101 | ||