@@ -92,28 +92,33 @@ void painter_draw_char(int x, int y, char ascii_char, const font_t *font, uint16
92
92
PAINTER_CHECK (ascii_char >= ' ' , "ACSII code invalid" );
93
93
PAINTER_CHECK (NULL != font , "Font pointer invalid" );
94
94
int i , j ;
95
- int x0 = x ;
96
95
uint16_t char_size = font -> Height * (font -> Width / 8 + (font -> Width % 8 ? 1 : 0 ));
97
96
unsigned int char_offset = (ascii_char - ' ' ) * char_size ;
98
97
const unsigned char * ptr = & font -> table [char_offset ];
98
+ uint16_t buf [18 * 25 ];
99
+ PAINTER_CHECK (font -> Height * font -> Width * sizeof (uint16_t ) <= sizeof (buf ), "Font size is too large" );
100
+ int ox = 0 ;
101
+ int oy = 0 ;
99
102
103
+ for (i = 0 ; i < font -> Width * font -> Height ; i ++ ) {
104
+ buf [i ] = g_back_color ;
105
+ }
100
106
for (j = 0 ; j < char_size ; j ++ ) {
101
107
uint8_t temp = ptr [j ];
102
108
for (i = 0 ; i < 8 ; i ++ ) {
103
109
if (temp & 0x80 ) {
104
- g_lcd .draw_pixel (x , y , g_point_color );
105
- } else {
106
- g_lcd .draw_pixel (x , y , g_back_color );
110
+ buf [ox + (font -> Width * oy )] = g_point_color ;
107
111
}
108
112
temp <<= 1 ;
109
- x ++ ;
110
- if (( x - x0 ) == font -> Width ) {
111
- x = x0 ;
112
- y ++ ;
113
+ ox ++ ;
114
+ if (ox == font -> Width ) {
115
+ ox = 0 ;
116
+ oy ++ ;
113
117
break ;
114
118
}
115
119
}
116
120
}
121
+ g_lcd .draw_bitmap (x , y , font -> Width , font -> Height , buf ); // Draw NxN char
117
122
}
118
123
119
124
void painter_draw_string (int x , int y , const char * text , const font_t * font , uint16_t color )
@@ -149,7 +154,7 @@ void painter_draw_num(int x, int y, uint32_t num, uint8_t len, const font_t *fon
149
154
{
150
155
PAINTER_CHECK (len < 10 , "The length of the number is too long" );
151
156
PAINTER_CHECK (NULL != font , "Font pointer invalid" );
152
- char buf [10 ]= {0 };
157
+ char buf [10 ] = {0 };
153
158
int8_t num_len ;
154
159
155
160
itoa (num , buf , 10 );
@@ -196,7 +201,7 @@ void painter_draw_line(int x1, int y1, int x2, int y2, uint16_t color)
196
201
uint16_t t ;
197
202
int xerr = 0 , yerr = 0 , delta_x , delta_y , distance ;
198
203
int incx , incy , uRow , uCol ;
199
- delta_x = x2 - x1 ;
204
+ delta_x = x2 - x1 ;
200
205
delta_y = y2 - y1 ;
201
206
uRow = x1 ;
202
207
uCol = y1 ;
0 commit comments