diff options
Diffstat (limited to 'firmware/drivers/lcd-2bit-vi.c')
-rw-r--r-- | firmware/drivers/lcd-2bit-vi.c | 225 |
1 files changed, 2 insertions, 223 deletions
diff --git a/firmware/drivers/lcd-2bit-vi.c b/firmware/drivers/lcd-2bit-vi.c index 0a73f0dd25..47f755f240 100644 --- a/firmware/drivers/lcd-2bit-vi.c +++ b/firmware/drivers/lcd-2bit-vi.c | |||
@@ -66,7 +66,7 @@ static struct viewport default_vp = | |||
66 | .bg_pattern = LCDM(DEFAULT_BG) | 66 | .bg_pattern = LCDM(DEFAULT_BG) |
67 | }; | 67 | }; |
68 | 68 | ||
69 | static struct viewport *current_vp IBSS_ATTR; | 69 | static struct viewport * current_vp IBSS_ATTR; |
70 | 70 | ||
71 | static unsigned fg_pattern IBSS_ATTR; | 71 | static unsigned fg_pattern IBSS_ATTR; |
72 | static unsigned bg_pattern IBSS_ATTR; | 72 | static unsigned bg_pattern IBSS_ATTR; |
@@ -1016,225 +1016,4 @@ void LCDFN(bitmap)(const FBFN(data) *src, int x, int y, int width, int height) | |||
1016 | LCDFN(bitmap_part)(src, 0, 0, width, x, y, width, height); | 1016 | LCDFN(bitmap_part)(src, 0, 0, width, x, y, width, height); |
1017 | } | 1017 | } |
1018 | 1018 | ||
1019 | /* put a string at a given pixel position, skipping first ofs pixel columns */ | 1019 | #include "lcd-bitmap-common.c" |
1020 | static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str) | ||
1021 | { | ||
1022 | unsigned short ch; | ||
1023 | unsigned short *ucs; | ||
1024 | struct font* pf = font_get(current_vp->font); | ||
1025 | |||
1026 | ucs = bidi_l2v(str, 1); | ||
1027 | |||
1028 | while ((ch = *ucs++) != 0 && x < current_vp->width) | ||
1029 | { | ||
1030 | int width; | ||
1031 | const unsigned char *bits; | ||
1032 | |||
1033 | /* get proportional width and glyph bits */ | ||
1034 | width = font_get_width(pf, ch); | ||
1035 | |||
1036 | if (ofs > width) | ||
1037 | { | ||
1038 | ofs -= width; | ||
1039 | continue; | ||
1040 | } | ||
1041 | |||
1042 | bits = font_get_bits(pf, ch); | ||
1043 | |||
1044 | LCDFN(mono_bitmap_part)(bits, ofs, 0, width, x, y, width - ofs, | ||
1045 | pf->height); | ||
1046 | |||
1047 | x += width - ofs; | ||
1048 | ofs = 0; | ||
1049 | } | ||
1050 | } | ||
1051 | |||
1052 | /* put a string at a given pixel position */ | ||
1053 | void LCDFN(putsxy)(int x, int y, const unsigned char *str) | ||
1054 | { | ||
1055 | LCDFN(putsxyofs)(x, y, 0, str); | ||
1056 | } | ||
1057 | |||
1058 | /*** line oriented text output ***/ | ||
1059 | |||
1060 | /* put a string at a given char position */ | ||
1061 | void LCDFN(puts)(int x, int y, const unsigned char *str) | ||
1062 | { | ||
1063 | LCDFN(puts_style_offset)(x, y, str, STYLE_DEFAULT, 0); | ||
1064 | } | ||
1065 | |||
1066 | void LCDFN(puts_style)(int x, int y, const unsigned char *str, int style) | ||
1067 | { | ||
1068 | LCDFN(puts_style_offset)(x, y, str, style, 0); | ||
1069 | } | ||
1070 | |||
1071 | void LCDFN(puts_offset)(int x, int y, const unsigned char *str, int offset) | ||
1072 | { | ||
1073 | LCDFN(puts_style_offset)(x, y, str, STYLE_DEFAULT, offset); | ||
1074 | } | ||
1075 | |||
1076 | /* put a string at a given char position, style, and pixel position, | ||
1077 | * skipping first offset pixel columns */ | ||
1078 | void LCDFN(puts_style_offset)(int x, int y, const unsigned char *str, | ||
1079 | int style, int offset) | ||
1080 | { | ||
1081 | int xpos,ypos,w,h,xrect; | ||
1082 | int lastmode = current_vp->drawmode; | ||
1083 | |||
1084 | /* make sure scrolling is turned off on the line we are updating */ | ||
1085 | LCDFN(scroll_stop_line)(current_vp, y); | ||
1086 | |||
1087 | if(!str || !str[0]) | ||
1088 | return; | ||
1089 | |||
1090 | LCDFN(getstringsize)(str, &w, &h); | ||
1091 | xpos = x*w / utf8length((char *)str); | ||
1092 | ypos = y*h; | ||
1093 | current_vp->drawmode = (style & STYLE_INVERT) ? | ||
1094 | (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; | ||
1095 | LCDFN(putsxyofs)(xpos, ypos, offset, str); | ||
1096 | current_vp->drawmode ^= DRMODE_INVERSEVID; | ||
1097 | xrect = xpos + MAX(w - offset, 0); | ||
1098 | LCDFN(fillrect)(xrect, ypos, current_vp->width - xrect, h); | ||
1099 | current_vp->drawmode = lastmode; | ||
1100 | } | ||
1101 | |||
1102 | /*** scrolling ***/ | ||
1103 | void LCDFN(puts_scroll)(int x, int y, const unsigned char *string) | ||
1104 | { | ||
1105 | LCDFN(puts_scroll_style)(x, y, string, STYLE_DEFAULT); | ||
1106 | } | ||
1107 | |||
1108 | void LCDFN(puts_scroll_style)(int x, int y, const unsigned char *string, int style) | ||
1109 | { | ||
1110 | LCDFN(puts_scroll_style_offset)(x, y, string, style, 0); | ||
1111 | } | ||
1112 | |||
1113 | void LCDFN(puts_scroll_offset)(int x, int y, const unsigned char *string, int offset) | ||
1114 | { | ||
1115 | LCDFN(puts_scroll_style_offset)(x, y, string, STYLE_DEFAULT, offset); | ||
1116 | } | ||
1117 | |||
1118 | void LCDFN(puts_scroll_style_offset)(int x, int y, const unsigned char *string, | ||
1119 | int style, int offset) | ||
1120 | { | ||
1121 | struct scrollinfo* s; | ||
1122 | int w, h; | ||
1123 | |||
1124 | if ((unsigned)y >= (unsigned)current_vp->height) | ||
1125 | return; | ||
1126 | |||
1127 | /* remove any previously scrolling line at the same location */ | ||
1128 | LCDFN(scroll_stop_line)(current_vp, y); | ||
1129 | |||
1130 | if (LCDFN(scroll_info).lines >= LCDM(SCROLLABLE_LINES)) return; | ||
1131 | |||
1132 | s = &LCDFN(scroll_info).scroll[LCDFN(scroll_info).lines]; | ||
1133 | |||
1134 | s->start_tick = current_tick + LCDFN(scroll_info).delay; | ||
1135 | s->style = style; | ||
1136 | if (style & STYLE_INVERT) { | ||
1137 | LCDFN(puts_style_offset)(x,y,string,STYLE_INVERT,offset); | ||
1138 | } | ||
1139 | else | ||
1140 | LCDFN(puts_offset)(x,y,string,offset); | ||
1141 | |||
1142 | LCDFN(getstringsize)(string, &w, &h); | ||
1143 | |||
1144 | if (current_vp->width - x * 8 < w) { | ||
1145 | /* prepare scroll line */ | ||
1146 | char *end; | ||
1147 | |||
1148 | memset(s->line, 0, sizeof s->line); | ||
1149 | strcpy(s->line, string); | ||
1150 | |||
1151 | /* get width */ | ||
1152 | s->width = LCDFN(getstringsize)(s->line, &w, &h); | ||
1153 | |||
1154 | /* scroll bidirectional or forward only depending on the string | ||
1155 | width */ | ||
1156 | if ( LCDFN(scroll_info).bidir_limit ) { | ||
1157 | s->bidir = s->width < (current_vp->width) * | ||
1158 | (100 + LCDFN(scroll_info).bidir_limit) / 100; | ||
1159 | } | ||
1160 | else | ||
1161 | s->bidir = false; | ||
1162 | |||
1163 | if (!s->bidir) { /* add spaces if scrolling in the round */ | ||
1164 | strcat(s->line, " "); | ||
1165 | /* get new width incl. spaces */ | ||
1166 | s->width = LCDFN(getstringsize)(s->line, &w, &h); | ||
1167 | } | ||
1168 | |||
1169 | end = strchr(s->line, '\0'); | ||
1170 | strlcpy(end, (char *)string, current_vp->width/2); | ||
1171 | |||
1172 | s->vp = current_vp; | ||
1173 | s->y = y; | ||
1174 | s->len = utf8length((char *)string); | ||
1175 | s->offset = offset; | ||
1176 | s->startx = x * s->width / s->len; | ||
1177 | s->backward = false; | ||
1178 | |||
1179 | LCDFN(scroll_info).lines++; | ||
1180 | } | ||
1181 | } | ||
1182 | |||
1183 | void LCDFN(scroll_fn)(void) | ||
1184 | { | ||
1185 | struct font* pf; | ||
1186 | struct scrollinfo* s; | ||
1187 | int index; | ||
1188 | int xpos, ypos; | ||
1189 | int lastmode; | ||
1190 | struct viewport* old_vp = current_vp; | ||
1191 | |||
1192 | for ( index = 0; index < LCDFN(scroll_info).lines; index++ ) { | ||
1193 | s = &LCDFN(scroll_info).scroll[index]; | ||
1194 | |||
1195 | /* check pause */ | ||
1196 | if (TIME_BEFORE(current_tick, s->start_tick)) | ||
1197 | continue; | ||
1198 | |||
1199 | LCDFN(set_viewport)(s->vp); | ||
1200 | |||
1201 | if (s->backward) | ||
1202 | s->offset -= LCDFN(scroll_info).step; | ||
1203 | else | ||
1204 | s->offset += LCDFN(scroll_info).step; | ||
1205 | |||
1206 | pf = font_get(current_vp->font); | ||
1207 | xpos = s->startx; | ||
1208 | ypos = s->y * pf->height; | ||
1209 | |||
1210 | if (s->bidir) { /* scroll bidirectional */ | ||
1211 | if (s->offset <= 0) { | ||
1212 | /* at beginning of line */ | ||
1213 | s->offset = 0; | ||
1214 | s->backward = false; | ||
1215 | s->start_tick = current_tick + LCDFN(scroll_info).delay * 2; | ||
1216 | } | ||
1217 | if (s->offset >= s->width - (current_vp->width - xpos)) { | ||
1218 | /* at end of line */ | ||
1219 | s->offset = s->width - (current_vp->width - xpos); | ||
1220 | s->backward = true; | ||
1221 | s->start_tick = current_tick + LCDFN(scroll_info).delay * 2; | ||
1222 | } | ||
1223 | } | ||
1224 | else { | ||
1225 | /* scroll forward the whole time */ | ||
1226 | if (s->offset >= s->width) | ||
1227 | s->offset %= s->width; | ||
1228 | } | ||
1229 | |||
1230 | lastmode = current_vp->drawmode; | ||
1231 | current_vp->drawmode = (s->style&STYLE_INVERT) ? | ||
1232 | (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; | ||
1233 | LCDFN(putsxyofs)(xpos, ypos, s->offset, s->line); | ||
1234 | current_vp->drawmode = lastmode; | ||
1235 | LCDFN(update_viewport_rect)(xpos, ypos, | ||
1236 | current_vp->width - xpos, pf->height); | ||
1237 | } | ||
1238 | |||
1239 | LCDFN(set_viewport)(old_vp); | ||
1240 | } | ||