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