@@ -244,6 +244,36 @@ void Adafruit_GFX::writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h,
244
244
fillRect (x, y, w, h, color);
245
245
}
246
246
247
+ /* *************************************************************************/
248
+ /* !
249
+ @brief set the address window (memory area), overwrite in subclasses if needed
250
+ */
251
+ /* *************************************************************************/
252
+ void Adafruit_GFX::setAddrWindow (unsigned short x, unsigned short y, unsigned short w, unsigned short h)
253
+ {
254
+ (void )x; (void )y; (void )w; (void )h;
255
+ }
256
+
257
+ /* *************************************************************************/
258
+ /* !
259
+ @brief write len pixels of the given color, overwrite in subclasses if needed
260
+ */
261
+ /* *************************************************************************/
262
+ void Adafruit_GFX::writeColor (uint16_t color, uint32_t len)
263
+ {
264
+ (void )color; (void )len;
265
+ }
266
+
267
+ /* *************************************************************************/
268
+ /* !
269
+ @brief write a buffer of pixels, overwrite in subclasses if needed
270
+ */
271
+ void Adafruit_GFX::writePixels (uint16_t *colors, uint32_t len, bool block,
272
+ bool bigEndian)
273
+ {
274
+ (void )colors; (void )len; (void )block; (void )bigEndian;
275
+ }
276
+
247
277
/* *************************************************************************/
248
278
/* !
249
279
@brief End a display-writing routine, overwrite in subclasses if
@@ -1147,28 +1177,41 @@ void Adafruit_GFX::drawChar(int16_t x, int16_t y, unsigned char c,
1147
1177
c++; // Handle 'classic' charset behavior
1148
1178
1149
1179
startWrite ();
1150
- for (int8_t i = 0 ; i < 5 ; i++) { // Char bitmap = 5 columns
1151
- uint8_t line = pgm_read_byte (&font[c * 5 + i]);
1152
- for (int8_t j = 0 ; j < 8 ; j++, line >>= 1 ) {
1153
- if (line & 1 ) {
1154
- if (size_x == 1 && size_y == 1 )
1155
- writePixel (x + i, y + j, color);
1156
- else
1157
- writeFillRect (x + i * size_x, y + j * size_y, size_x, size_y,
1180
+ if (color != bg) { // faster opaque text
1181
+ setAddrWindow (x, y, 5 *size_x, 7 *size_y);
1182
+ for (int8_t j = 0 ; j < 7 ; j++) { // 7 lines
1183
+ uint8_t uc, ucMask = (1 << j);
1184
+ for (uint8_t k=0 ; k<size_y; k++) { // repeat size_y lines
1185
+ for (uint8_t i=0 ; i<5 ; i++) { // 5 columns
1186
+ uc = pgm_read_byte (&font[(c * 5 ) + i]);
1187
+ writeColor ((uc & ucMask) ? color:bg, size_x);
1188
+ } // for each column
1189
+ } // repeat for each line of size_y
1190
+ } // for j
1191
+ } else { // slower text which doesn't overwrite the background color
1192
+ for (int8_t i = 0 ; i < 5 ; i++) { // Char bitmap = 5 columns
1193
+ uint8_t line = pgm_read_byte (&font[c * 5 + i]);
1194
+ for (int8_t j = 0 ; j < 8 ; j++, line >>= 1 ) {
1195
+ if (line & 1 ) {
1196
+ if (size_x == 1 && size_y == 1 )
1197
+ writePixel (x + i, y + j, color);
1198
+ else
1199
+ writeFillRect (x + i * size_x, y + j * size_y, size_x, size_y,
1158
1200
color);
1159
- } else if (bg != color) {
1201
+ } else if (bg != color) {
1202
+ if (size_x == 1 && size_y == 1 )
1203
+ writePixel (x + i, y + j, bg);
1204
+ else
1205
+ writeFillRect (x + i * size_x, y + j * size_y, size_x, size_y, bg);
1206
+ }
1207
+ }
1208
+ }
1209
+ if (bg != color) { // If opaque, draw vertical line for last column
1160
1210
if (size_x == 1 && size_y == 1 )
1161
- writePixel (x + i , y + j , bg);
1211
+ writeFastVLine (x + 5 , y, 8 , bg);
1162
1212
else
1163
- writeFillRect (x + i * size_x, y + j * size_y , size_x, size_y, bg);
1213
+ writeFillRect (x + 5 * size_x, y, size_x, 8 * size_y, bg);
1164
1214
}
1165
- }
1166
- }
1167
- if (bg != color) { // If opaque, draw vertical line for last column
1168
- if (size_x == 1 && size_y == 1 )
1169
- writeFastVLine (x + 5 , y, 8 , bg);
1170
- else
1171
- writeFillRect (x + 5 * size_x, y, size_x, 8 * size_y, bg);
1172
1215
}
1173
1216
endWrite ();
1174
1217
0 commit comments