summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/lcd-16bit.c30
-rw-r--r--firmware/drivers/lcd-1bit-vert.c30
-rw-r--r--firmware/drivers/lcd-2bit-horz.c30
-rw-r--r--firmware/drivers/lcd-2bit-vert.c30
-rw-r--r--firmware/drivers/lcd-2bit-vi.c31
-rw-r--r--firmware/drivers/lcd-charcell.c26
6 files changed, 34 insertions, 143 deletions
diff --git a/firmware/drivers/lcd-16bit.c b/firmware/drivers/lcd-16bit.c
index 020d6bf63a..a5b7533cc1 100644
--- a/firmware/drivers/lcd-16bit.c
+++ b/firmware/drivers/lcd-16bit.c
@@ -61,8 +61,6 @@ static struct viewport default_vp =
61 .height = LCD_HEIGHT, 61 .height = LCD_HEIGHT,
62 .font = FONT_SYSFIXED, 62 .font = FONT_SYSFIXED,
63 .drawmode = DRMODE_SOLID, 63 .drawmode = DRMODE_SOLID,
64 .xmargin = 0,
65 .ymargin = 0,
66 .fg_pattern = LCD_DEFAULT_FG, 64 .fg_pattern = LCD_DEFAULT_FG,
67 .bg_pattern = LCD_DEFAULT_BG, 65 .bg_pattern = LCD_DEFAULT_BG,
68 .lss_pattern = LCD_DEFAULT_BG, 66 .lss_pattern = LCD_DEFAULT_BG,
@@ -180,12 +178,6 @@ void lcd_set_drawinfo(int mode, unsigned fg_color, unsigned bg_color)
180 current_vp->bg_pattern = bg_color; 178 current_vp->bg_pattern = bg_color;
181} 179}
182 180
183void lcd_setmargins(int x, int y)
184{
185 current_vp->xmargin = x;
186 current_vp->ymargin = y;
187}
188
189int lcd_getwidth(void) 181int lcd_getwidth(void)
190{ 182{
191 return current_vp->width; 183 return current_vp->width;
@@ -196,16 +188,6 @@ int lcd_getheight(void)
196 return current_vp->height; 188 return current_vp->height;
197} 189}
198 190
199int lcd_getxmargin(void)
200{
201 return current_vp->xmargin;
202}
203
204int lcd_getymargin(void)
205{
206 return current_vp->ymargin;
207}
208
209void lcd_setfont(int newfont) 191void lcd_setfont(int newfont)
210{ 192{
211 current_vp->font = newfont; 193 current_vp->font = newfont;
@@ -1005,8 +987,8 @@ void lcd_puts_style_offset(int x, int y, const unsigned char *str, int style,
1005 return; 987 return;
1006 988
1007 lcd_getstringsize(str, &w, &h); 989 lcd_getstringsize(str, &w, &h);
1008 xpos = current_vp->xmargin + x*w / utf8length(str); 990 xpos = x*w / utf8length(str);
1009 ypos = current_vp->ymargin + y*h; 991 ypos = y*h;
1010 current_vp->drawmode = (style & STYLE_INVERT) ? 992 current_vp->drawmode = (style & STYLE_INVERT) ?
1011 (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; 993 (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID;
1012 if (style & STYLE_COLORED) { 994 if (style & STYLE_COLORED) {
@@ -1081,7 +1063,7 @@ void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *string,
1081 1063
1082 lcd_getstringsize(string, &w, &h); 1064 lcd_getstringsize(string, &w, &h);
1083 1065
1084 if (current_vp->width - x * 8 - current_vp->xmargin < w) { 1066 if (current_vp->width - x * 8 < w) {
1085 /* prepare scroll line */ 1067 /* prepare scroll line */
1086 char *end; 1068 char *end;
1087 1069
@@ -1094,7 +1076,7 @@ void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *string,
1094 /* scroll bidirectional or forward only depending on the string 1076 /* scroll bidirectional or forward only depending on the string
1095 width */ 1077 width */
1096 if ( lcd_scroll_info.bidir_limit ) { 1078 if ( lcd_scroll_info.bidir_limit ) {
1097 s->bidir = s->width < (current_vp->width - current_vp->xmargin) * 1079 s->bidir = s->width < (current_vp->width) *
1098 (100 + lcd_scroll_info.bidir_limit) / 100; 1080 (100 + lcd_scroll_info.bidir_limit) / 100;
1099 } 1081 }
1100 else 1082 else
@@ -1113,7 +1095,7 @@ void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *string,
1113 s->y = y; 1095 s->y = y;
1114 s->len = utf8length(string); 1096 s->len = utf8length(string);
1115 s->offset = offset; 1097 s->offset = offset;
1116 s->startx = current_vp->xmargin + x * s->width / s->len; 1098 s->startx = x * s->width / s->len;
1117 s->backward = false; 1099 s->backward = false;
1118 lcd_scroll_info.lines++; 1100 lcd_scroll_info.lines++;
1119 } 1101 }
@@ -1159,7 +1141,7 @@ void lcd_scroll_fn(void)
1159 1141
1160 pf = font_get(current_vp->font); 1142 pf = font_get(current_vp->font);
1161 xpos = s->startx; 1143 xpos = s->startx;
1162 ypos = current_vp->ymargin + s->y * pf->height; 1144 ypos = s->y * pf->height;
1163 1145
1164 if (s->bidir) { /* scroll bidirectional */ 1146 if (s->bidir) { /* scroll bidirectional */
1165 if (s->offset <= 0) { 1147 if (s->offset <= 0) {
diff --git a/firmware/drivers/lcd-1bit-vert.c b/firmware/drivers/lcd-1bit-vert.c
index c6fe40cdb7..ffc78bd53a 100644
--- a/firmware/drivers/lcd-1bit-vert.c
+++ b/firmware/drivers/lcd-1bit-vert.c
@@ -56,8 +56,6 @@ static struct viewport default_vp =
56 .height = LCDM(HEIGHT), 56 .height = LCDM(HEIGHT),
57 .font = FONT_SYSFIXED, 57 .font = FONT_SYSFIXED,
58 .drawmode = DRMODE_SOLID, 58 .drawmode = DRMODE_SOLID,
59 .xmargin = 0,
60 .ymargin = 0,
61}; 59};
62 60
63static struct viewport* current_vp = &default_vp; 61static struct viewport* current_vp = &default_vp;
@@ -107,22 +105,6 @@ int LCDFN(get_drawmode)(void)
107 return current_vp->drawmode; 105 return current_vp->drawmode;
108} 106}
109 107
110void LCDFN(setmargins)(int x, int y)
111{
112 current_vp->xmargin = x;
113 current_vp->ymargin = y;
114}
115
116int LCDFN(getxmargin)(void)
117{
118 return current_vp->xmargin;
119}
120
121int LCDFN(getymargin)(void)
122{
123 return current_vp->ymargin;
124}
125
126int LCDFN(getwidth)(void) 108int LCDFN(getwidth)(void)
127{ 109{
128 return current_vp->width; 110 return current_vp->width;
@@ -760,8 +742,8 @@ void LCDFN(puts_style_offset)(int x, int y, const unsigned char *str,
760 return; 742 return;
761 743
762 LCDFN(getstringsize)(str, &w, &h); 744 LCDFN(getstringsize)(str, &w, &h);
763 xpos = current_vp->xmargin + x*w / utf8length(str); 745 xpos = x*w / utf8length(str);
764 ypos = current_vp->ymargin + y*h; 746 ypos = y*h;
765 current_vp->drawmode = (style & STYLE_INVERT) ? 747 current_vp->drawmode = (style & STYLE_INVERT) ?
766 (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; 748 (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID;
767 LCDFN(putsxyofs)(xpos, ypos, offset, str); 749 LCDFN(putsxyofs)(xpos, ypos, offset, str);
@@ -816,7 +798,7 @@ void LCDFN(puts_scroll_style_offset)(int x, int y, const unsigned char *string,
816 798
817 LCDFN(getstringsize)(string, &w, &h); 799 LCDFN(getstringsize)(string, &w, &h);
818 800
819 if (current_vp->width - x * 8 - current_vp->xmargin < w) { 801 if (current_vp->width - x * 8 < w) {
820 /* prepare scroll line */ 802 /* prepare scroll line */
821 char *end; 803 char *end;
822 804
@@ -829,7 +811,7 @@ void LCDFN(puts_scroll_style_offset)(int x, int y, const unsigned char *string,
829 /* scroll bidirectional or forward only depending on the string 811 /* scroll bidirectional or forward only depending on the string
830 width */ 812 width */
831 if ( LCDFN(scroll_info).bidir_limit ) { 813 if ( LCDFN(scroll_info).bidir_limit ) {
832 s->bidir = s->width < (current_vp->width - current_vp->xmargin) * 814 s->bidir = s->width < (current_vp->width) *
833 (100 + LCDFN(scroll_info).bidir_limit) / 100; 815 (100 + LCDFN(scroll_info).bidir_limit) / 100;
834 } 816 }
835 else 817 else
@@ -848,7 +830,7 @@ void LCDFN(puts_scroll_style_offset)(int x, int y, const unsigned char *string,
848 s->y = y; 830 s->y = y;
849 s->len = utf8length(string); 831 s->len = utf8length(string);
850 s->offset = offset; 832 s->offset = offset;
851 s->startx = current_vp->xmargin + x * s->width / s->len;; 833 s->startx = x * s->width / s->len;;
852 s->backward = false; 834 s->backward = false;
853 835
854 LCDFN(scroll_info).lines++; 836 LCDFN(scroll_info).lines++;
@@ -880,7 +862,7 @@ void LCDFN(scroll_fn)(void)
880 862
881 pf = font_get(current_vp->font); 863 pf = font_get(current_vp->font);
882 xpos = s->startx; 864 xpos = s->startx;
883 ypos = current_vp->ymargin + s->y * pf->height; 865 ypos = s->y * pf->height;
884 866
885 if (s->bidir) { /* scroll bidirectional */ 867 if (s->bidir) { /* scroll bidirectional */
886 if (s->offset <= 0) { 868 if (s->offset <= 0) {
diff --git a/firmware/drivers/lcd-2bit-horz.c b/firmware/drivers/lcd-2bit-horz.c
index 30901efb98..0818c29d47 100644
--- a/firmware/drivers/lcd-2bit-horz.c
+++ b/firmware/drivers/lcd-2bit-horz.c
@@ -54,8 +54,6 @@ static struct viewport default_vp =
54 .height = LCD_HEIGHT, 54 .height = LCD_HEIGHT,
55 .font = FONT_SYSFIXED, 55 .font = FONT_SYSFIXED,
56 .drawmode = DRMODE_SOLID, 56 .drawmode = DRMODE_SOLID,
57 .xmargin = 0,
58 .ymargin = 0,
59 .fg_pattern = LCD_DEFAULT_FG, 57 .fg_pattern = LCD_DEFAULT_FG,
60 .bg_pattern = LCD_DEFAULT_BG 58 .bg_pattern = LCD_DEFAULT_BG
61}; 59};
@@ -141,22 +139,6 @@ void lcd_set_drawinfo(int mode, unsigned fg_brightness, unsigned bg_brightness)
141 lcd_set_background(bg_brightness); 139 lcd_set_background(bg_brightness);
142} 140}
143 141
144void lcd_setmargins(int x, int y)
145{
146 current_vp->xmargin = x;
147 current_vp->ymargin = y;
148}
149
150int lcd_getxmargin(void)
151{
152 return current_vp->xmargin;
153}
154
155int lcd_getymargin(void)
156{
157 return current_vp->ymargin;
158}
159
160int lcd_getwidth(void) 142int lcd_getwidth(void)
161{ 143{
162 return current_vp->width; 144 return current_vp->width;
@@ -950,8 +932,8 @@ void lcd_puts_style_offset(int x, int y, const unsigned char *str,
950 return; 932 return;
951 933
952 lcd_getstringsize(str, &w, &h); 934 lcd_getstringsize(str, &w, &h);
953 xpos = current_vp->xmargin + x*w / utf8length((char *)str); 935 xpos = x*w / utf8length((char *)str);
954 ypos = current_vp->ymargin + y*h; 936 ypos = y*h;
955 current_vp->drawmode = (style & STYLE_INVERT) ? 937 current_vp->drawmode = (style & STYLE_INVERT) ?
956 (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; 938 (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID;
957 lcd_putsxyofs(xpos, ypos, offset, str); 939 lcd_putsxyofs(xpos, ypos, offset, str);
@@ -1003,7 +985,7 @@ void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *string,
1003 985
1004 lcd_getstringsize(string, &w, &h); 986 lcd_getstringsize(string, &w, &h);
1005 987
1006 if (current_vp->width - x * 8 - current_vp->xmargin < w) { 988 if (current_vp->width - x * 8 < w) {
1007 /* prepare scroll line */ 989 /* prepare scroll line */
1008 char *end; 990 char *end;
1009 991
@@ -1016,7 +998,7 @@ void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *string,
1016 /* scroll bidirectional or forward only depending on the string 998 /* scroll bidirectional or forward only depending on the string
1017 width */ 999 width */
1018 if ( lcd_scroll_info.bidir_limit ) { 1000 if ( lcd_scroll_info.bidir_limit ) {
1019 s->bidir = s->width < (current_vp->width - current_vp->xmargin) * 1001 s->bidir = s->width < (current_vp->width) *
1020 (100 + lcd_scroll_info.bidir_limit) / 100; 1002 (100 + lcd_scroll_info.bidir_limit) / 100;
1021 } 1003 }
1022 else 1004 else
@@ -1035,7 +1017,7 @@ void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *string,
1035 s->y = y; 1017 s->y = y;
1036 s->len = utf8length((char *)string); 1018 s->len = utf8length((char *)string);
1037 s->offset = offset; 1019 s->offset = offset;
1038 s->startx = current_vp->xmargin + x * s->width / s->len;; 1020 s->startx = x * s->width / s->len;;
1039 s->backward = false; 1021 s->backward = false;
1040 lcd_scroll_info.lines++; 1022 lcd_scroll_info.lines++;
1041 } 1023 }
@@ -1066,7 +1048,7 @@ void lcd_scroll_fn(void)
1066 1048
1067 pf = font_get(current_vp->font); 1049 pf = font_get(current_vp->font);
1068 xpos = s->startx; 1050 xpos = s->startx;
1069 ypos = current_vp->ymargin + s->y * pf->height; 1051 ypos = s->y * pf->height;
1070 1052
1071 if (s->bidir) { /* scroll bidirectional */ 1053 if (s->bidir) { /* scroll bidirectional */
1072 if (s->offset <= 0) { 1054 if (s->offset <= 0) {
diff --git a/firmware/drivers/lcd-2bit-vert.c b/firmware/drivers/lcd-2bit-vert.c
index d43bf6cc81..285a592893 100644
--- a/firmware/drivers/lcd-2bit-vert.c
+++ b/firmware/drivers/lcd-2bit-vert.c
@@ -56,8 +56,6 @@ static struct viewport default_vp =
56 .height = LCD_HEIGHT, 56 .height = LCD_HEIGHT,
57 .font = FONT_SYSFIXED, 57 .font = FONT_SYSFIXED,
58 .drawmode = DRMODE_SOLID, 58 .drawmode = DRMODE_SOLID,
59 .xmargin = 0,
60 .ymargin = 0,
61 .fg_pattern = LCD_DEFAULT_FG, 59 .fg_pattern = LCD_DEFAULT_FG,
62 .bg_pattern = LCD_DEFAULT_BG 60 .bg_pattern = LCD_DEFAULT_BG
63}; 61};
@@ -144,22 +142,6 @@ void lcd_set_drawinfo(int mode, unsigned fg_brightness, unsigned bg_brightness)
144 lcd_set_background(bg_brightness); 142 lcd_set_background(bg_brightness);
145} 143}
146 144
147void lcd_setmargins(int x, int y)
148{
149 current_vp->xmargin = x;
150 current_vp->ymargin = y;
151}
152
153int lcd_getxmargin(void)
154{
155 return current_vp->xmargin;
156}
157
158int lcd_getymargin(void)
159{
160 return current_vp->ymargin;
161}
162
163int lcd_getwidth(void) 145int lcd_getwidth(void)
164{ 146{
165 return current_vp->width; 147 return current_vp->width;
@@ -1088,8 +1070,8 @@ void lcd_puts_style_offset(int x, int y, const unsigned char *str,
1088 return; 1070 return;
1089 1071
1090 lcd_getstringsize(str, &w, &h); 1072 lcd_getstringsize(str, &w, &h);
1091 xpos = current_vp->xmargin + x*w / utf8length((char *)str); 1073 xpos = x*w / utf8length((char *)str);
1092 ypos = current_vp->ymargin + y*h; 1074 ypos = y*h;
1093 current_vp->drawmode = (style & STYLE_INVERT) ? 1075 current_vp->drawmode = (style & STYLE_INVERT) ?
1094 (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; 1076 (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID;
1095 lcd_putsxyofs(xpos, ypos, offset, str); 1077 lcd_putsxyofs(xpos, ypos, offset, str);
@@ -1142,7 +1124,7 @@ void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *string,
1142 1124
1143 lcd_getstringsize(string, &w, &h); 1125 lcd_getstringsize(string, &w, &h);
1144 1126
1145 if (current_vp->width - x * 8 - current_vp->xmargin < w) { 1127 if (current_vp->width - x * 8< w) {
1146 /* prepare scroll line */ 1128 /* prepare scroll line */
1147 char *end; 1129 char *end;
1148 1130
@@ -1155,7 +1137,7 @@ void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *string,
1155 /* scroll bidirectional or forward only depending on the string 1137 /* scroll bidirectional or forward only depending on the string
1156 width */ 1138 width */
1157 if ( lcd_scroll_info.bidir_limit ) { 1139 if ( lcd_scroll_info.bidir_limit ) {
1158 s->bidir = s->width < (current_vp->width - current_vp->xmargin) * 1140 s->bidir = s->width < (current_vp->width) *
1159 (100 + lcd_scroll_info.bidir_limit) / 100; 1141 (100 + lcd_scroll_info.bidir_limit) / 100;
1160 } 1142 }
1161 else 1143 else
@@ -1174,7 +1156,7 @@ void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *string,
1174 s->y = y; 1156 s->y = y;
1175 s->len = utf8length((char *)string); 1157 s->len = utf8length((char *)string);
1176 s->offset = offset; 1158 s->offset = offset;
1177 s->startx = current_vp->xmargin + x * s->width / s->len; 1159 s->startx = x * s->width / s->len;
1178 s->backward = false; 1160 s->backward = false;
1179 1161
1180 lcd_scroll_info.lines++; 1162 lcd_scroll_info.lines++;
@@ -1206,7 +1188,7 @@ void lcd_scroll_fn(void)
1206 1188
1207 pf = font_get(current_vp->font); 1189 pf = font_get(current_vp->font);
1208 xpos = s->startx; 1190 xpos = s->startx;
1209 ypos = current_vp->ymargin + s->y * pf->height; 1191 ypos = s->y * pf->height;
1210 1192
1211 if (s->bidir) { /* scroll bidirectional */ 1193 if (s->bidir) { /* scroll bidirectional */
1212 if (s->offset <= 0) { 1194 if (s->offset <= 0) {
diff --git a/firmware/drivers/lcd-2bit-vi.c b/firmware/drivers/lcd-2bit-vi.c
index 7d97f19174..9decc0cbab 100644
--- a/firmware/drivers/lcd-2bit-vi.c
+++ b/firmware/drivers/lcd-2bit-vi.c
@@ -60,8 +60,6 @@ static struct viewport default_vp =
60 .height = LCDM(HEIGHT), 60 .height = LCDM(HEIGHT),
61 .font = FONT_SYSFIXED, 61 .font = FONT_SYSFIXED,
62 .drawmode = DRMODE_SOLID, 62 .drawmode = DRMODE_SOLID,
63 .xmargin = 0,
64 .ymargin = 0,
65 .fg_pattern = LCDM(DEFAULT_FG), 63 .fg_pattern = LCDM(DEFAULT_FG),
66 .bg_pattern = LCDM(DEFAULT_BG) 64 .bg_pattern = LCDM(DEFAULT_BG)
67}; 65};
@@ -175,23 +173,6 @@ int LCDFN(getheight)(void)
175{ 173{
176 return current_vp->height; 174 return current_vp->height;
177} 175}
178
179void LCDFN(setmargins)(int x, int y)
180{
181 current_vp->xmargin = x;
182 current_vp->ymargin = y;
183}
184
185int LCDFN(getxmargin)(void)
186{
187 return current_vp->xmargin;
188}
189
190int LCDFN(getymargin)(void)
191{
192 return current_vp->ymargin;
193}
194
195void LCDFN(setfont)(int newfont) 176void LCDFN(setfont)(int newfont)
196{ 177{
197 current_vp->font = newfont; 178 current_vp->font = newfont;
@@ -1105,8 +1086,8 @@ void LCDFN(puts_style_offset)(int x, int y, const unsigned char *str,
1105 return; 1086 return;
1106 1087
1107 LCDFN(getstringsize)(str, &w, &h); 1088 LCDFN(getstringsize)(str, &w, &h);
1108 xpos = current_vp->xmargin + x*w / utf8length((char *)str); 1089 xpos = x*w / utf8length((char *)str);
1109 ypos = current_vp->ymargin + y*h; 1090 ypos = y*h;
1110 current_vp->drawmode = (style & STYLE_INVERT) ? 1091 current_vp->drawmode = (style & STYLE_INVERT) ?
1111 (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; 1092 (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID;
1112 LCDFN(putsxyofs)(xpos, ypos, offset, str); 1093 LCDFN(putsxyofs)(xpos, ypos, offset, str);
@@ -1158,7 +1139,7 @@ void LCDFN(puts_scroll_style_offset)(int x, int y, const unsigned char *string,
1158 1139
1159 LCDFN(getstringsize)(string, &w, &h); 1140 LCDFN(getstringsize)(string, &w, &h);
1160 1141
1161 if (current_vp->width - x * 8 - current_vp->xmargin < w) { 1142 if (current_vp->width - x * 8 < w) {
1162 /* prepare scroll line */ 1143 /* prepare scroll line */
1163 char *end; 1144 char *end;
1164 1145
@@ -1171,7 +1152,7 @@ void LCDFN(puts_scroll_style_offset)(int x, int y, const unsigned char *string,
1171 /* scroll bidirectional or forward only depending on the string 1152 /* scroll bidirectional or forward only depending on the string
1172 width */ 1153 width */
1173 if ( LCDFN(scroll_info).bidir_limit ) { 1154 if ( LCDFN(scroll_info).bidir_limit ) {
1174 s->bidir = s->width < (current_vp->width - current_vp->xmargin) * 1155 s->bidir = s->width < (current_vp->width) *
1175 (100 + LCDFN(scroll_info).bidir_limit) / 100; 1156 (100 + LCDFN(scroll_info).bidir_limit) / 100;
1176 } 1157 }
1177 else 1158 else
@@ -1190,7 +1171,7 @@ void LCDFN(puts_scroll_style_offset)(int x, int y, const unsigned char *string,
1190 s->y = y; 1171 s->y = y;
1191 s->len = utf8length((char *)string); 1172 s->len = utf8length((char *)string);
1192 s->offset = offset; 1173 s->offset = offset;
1193 s->startx = current_vp->xmargin + x * s->width / s->len; 1174 s->startx = x * s->width / s->len;
1194 s->backward = false; 1175 s->backward = false;
1195 1176
1196 LCDFN(scroll_info).lines++; 1177 LCDFN(scroll_info).lines++;
@@ -1222,7 +1203,7 @@ void LCDFN(scroll_fn)(void)
1222 1203
1223 pf = font_get(current_vp->font); 1204 pf = font_get(current_vp->font);
1224 xpos = s->startx; 1205 xpos = s->startx;
1225 ypos = current_vp->ymargin + s->y * pf->height; 1206 ypos = s->y * pf->height;
1226 1207
1227 if (s->bidir) { /* scroll bidirectional */ 1208 if (s->bidir) { /* scroll bidirectional */
1228 if (s->offset <= 0) { 1209 if (s->offset <= 0) {
diff --git a/firmware/drivers/lcd-charcell.c b/firmware/drivers/lcd-charcell.c
index 1bc634cd2f..1c43b83ab1 100644
--- a/firmware/drivers/lcd-charcell.c
+++ b/firmware/drivers/lcd-charcell.c
@@ -58,8 +58,6 @@ static struct viewport default_vp =
58 .y = 0, 58 .y = 0,
59 .width = LCD_WIDTH, 59 .width = LCD_WIDTH,
60 .height = LCD_HEIGHT, 60 .height = LCD_HEIGHT,
61 .xmargin = 0,
62 .ymargin = 0,
63 }; 61 };
64 62
65static struct viewport* current_vp = &default_vp; 63static struct viewport* current_vp = &default_vp;
@@ -92,22 +90,6 @@ void lcd_update_viewport(void)
92 90
93/** parameter handling **/ 91/** parameter handling **/
94 92
95void lcd_setmargins(int x, int y)
96{
97 current_vp->xmargin = x;
98 current_vp->ymargin = y;
99}
100
101int lcd_getxmargin(void)
102{
103 return current_vp->xmargin;
104}
105
106int lcd_getymargin(void)
107{
108 return current_vp->ymargin;
109}
110
111int lcd_getwidth(void) 93int lcd_getwidth(void)
112{ 94{
113 return current_vp->width; 95 return current_vp->width;
@@ -484,7 +466,7 @@ void lcd_puts_scroll_offset(int x, int y, const unsigned char *string,
484 lcd_puts_offset(x, y, string, offset); 466 lcd_puts_offset(x, y, string, offset);
485 len = utf8length(string); 467 len = utf8length(string);
486 468
487 if (current_vp->width - x - current_vp->xmargin < len) 469 if (current_vp->width - x < len)
488 { 470 {
489 /* prepare scroll line */ 471 /* prepare scroll line */
490 char *end; 472 char *end;
@@ -498,7 +480,7 @@ void lcd_puts_scroll_offset(int x, int y, const unsigned char *string,
498 /* scroll bidirectional or forward only depending on the string width */ 480 /* scroll bidirectional or forward only depending on the string width */
499 if (lcd_scroll_info.bidir_limit) 481 if (lcd_scroll_info.bidir_limit)
500 { 482 {
501 s->bidir = s->len < (current_vp->width - current_vp->xmargin) * 483 s->bidir = s->len < (current_vp->width) *
502 (100 + lcd_scroll_info.bidir_limit) / 100; 484 (100 + lcd_scroll_info.bidir_limit) / 100;
503 } 485 }
504 else 486 else
@@ -517,7 +499,7 @@ void lcd_puts_scroll_offset(int x, int y, const unsigned char *string,
517 s->vp = current_vp; 499 s->vp = current_vp;
518 s->y = y; 500 s->y = y;
519 s->offset = offset; 501 s->offset = offset;
520 s->startx = current_vp->xmargin + x; 502 s->startx = x;
521 s->backward = false; 503 s->backward = false;
522 lcd_scroll_info.lines++; 504 lcd_scroll_info.lines++;
523 } 505 }
@@ -547,7 +529,7 @@ void lcd_scroll_fn(void)
547 s->offset++; 529 s->offset++;
548 530
549 xpos = s->startx; 531 xpos = s->startx;
550 ypos = current_vp->ymargin + s->y; 532 ypos = s->y;
551 533
552 if (s->bidir) /* scroll bidirectional */ 534 if (s->bidir) /* scroll bidirectional */
553 { 535 {