From 6e644c3e633a4b48f230f4890ec2a065b2d13fca Mon Sep 17 00:00:00 2001 From: Bodmer Date: Tue, 5 Dec 2023 17:22:22 +0000 Subject: [PATCH] Add option to correct legacy Adafruit GLCD font bug Raise issue --- Extensions/Sprite.cpp | 3 +++ Fonts/glcdfont.c | 5 +++-- TFT_eSPI.cpp | 11 ++++++----- TFT_eSPI.h | 4 ++-- library.json | 2 +- library.properties | 2 +- 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Extensions/Sprite.cpp b/Extensions/Sprite.cpp index 9de04ef..5343c08 100644 --- a/Extensions/Sprite.cpp +++ b/Extensions/Sprite.cpp @@ -2001,6 +2001,9 @@ void TFT_eSprite::drawChar(int32_t x, int32_t y, uint16_t c, uint32_t color, uin ((y + 8 * size - 1) < (_vpY - _yDatum))) // Clip top return; + if (c > 255) return; + if (!_cp437 && c > 175) c++; + bool fillbg = (bg != color); if ((size==1) && fillbg) diff --git a/Fonts/glcdfont.c b/Fonts/glcdfont.c index 882a133..95c1c98 100644 --- a/Fonts/glcdfont.c +++ b/Fonts/glcdfont.c @@ -182,8 +182,9 @@ static const unsigned char font[] PROGMEM = { 0x00, 0x00, 0x7B, 0x00, 0x00, 0x08, 0x14, 0x2A, 0x14, 0x22, 0x22, 0x14, 0x2A, 0x14, 0x08, - 0xAA, 0x00, 0x55, 0x00, 0xAA, - 0xAA, 0x55, 0xAA, 0x55, 0xAA, + 0x55, 0x00, 0x55, 0x00, 0x55, // #176 (25% block) missing in old code + 0xAA, 0x55, 0xAA, 0x55, 0xAA, // 50% block + 0xFF, 0x55, 0xFF, 0x55, 0xFF, // 75% block 0x00, 0x00, 0x00, 0xFF, 0x00, 0x10, 0x10, 0x10, 0xFF, 0x00, 0x14, 0x14, 0x14, 0xFF, 0x00, diff --git a/TFT_eSPI.cpp b/TFT_eSPI.cpp index ae96f6b..b8fcf7c 100644 --- a/TFT_eSPI.cpp +++ b/TFT_eSPI.cpp @@ -467,7 +467,7 @@ TFT_eSPI::TFT_eSPI(int16_t w, int16_t h) lockTransaction = false; // start/endWrite lock flag to allow sketch to keep SPI bus access open _booted = true; // Default attributes - _cp437 = true; // Legacy GLCD font bug fix + _cp437 = false; // Legacy GLCD font bug fix disabled by default _utf8 = true; // UTF8 decoding enabled #if defined (FONT_FS_AVAILABLE) && defined (SMOOTH_FONT) @@ -2158,7 +2158,7 @@ void TFT_eSPI::pushMaskedImage(int32_t x, int32_t y, int32_t w, int32_t h, uint1 xp += clearCount; clearCount = 0; pushImage(x + xp, y, setCount, 1, iptr + xp); // pushImage handles clipping - if (mptr >= eptr) break; + if (mptr >= eptr) break; xp += setCount; } } while (setCount || mptr < eptr); @@ -2866,7 +2866,7 @@ void TFT_eSPI::setCursor(int16_t x, int16_t y) ***************************************************************************************/ void TFT_eSPI::setCursor(int16_t x, int16_t y, uint8_t font) { - textfont = font; + setTextFont(font); cursor_x = x; cursor_y = y; } @@ -3188,8 +3188,6 @@ void TFT_eSPI::drawChar(int32_t x, int32_t y, uint16_t c, uint32_t color, uint32 #endif //>>>>>>>>>>>>>>>>>> - if (c > 255) return; - int32_t xd = x + _xDatum; int32_t yd = y + _yDatum; @@ -3199,6 +3197,9 @@ void TFT_eSPI::drawChar(int32_t x, int32_t y, uint16_t c, uint32_t color, uint32 ((yd + 8 * size - 1) < _vpY)) // Clip top return; + if (c > 255) return; + if (!_cp437 && c > 175) c++; + bool fillbg = (bg != color); bool clip = xd < _vpX || xd + 6 * textsize >= _vpW || yd < _vpY || yd + 8 * textsize >= _vpH; diff --git a/TFT_eSPI.h b/TFT_eSPI.h index 42bbc92..f892203 100644 --- a/TFT_eSPI.h +++ b/TFT_eSPI.h @@ -16,7 +16,7 @@ #ifndef _TFT_eSPIH_ #define _TFT_eSPIH_ -#define TFT_ESPI_VERSION "2.5.34" +#define TFT_ESPI_VERSION "2.5.40" // Bit level feature flags // Bit 0 set: viewport capability @@ -939,7 +939,7 @@ class TFT_eSPI : public Print { friend class TFT_eSprite; // Sprite class has ac bool _booted; // init() or begin() has already run once // User sketch manages these via set/getAttribute() - bool _cp437; // If set, use correct CP437 charset (default is ON) + bool _cp437; // If set, use correct CP437 charset (default is OFF) bool _utf8; // If set, use UTF-8 decoder in print stream 'write()' function (default ON) bool _psram_enable; // Enable PSRAM use for library functions (TBD) and Sprites diff --git a/library.json b/library.json index 16db5d9..77f30a1 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "TFT_eSPI", - "version": "2.5.34", + "version": "2.5.40", "keywords": "Arduino, tft, display, ttgo, LilyPi, WT32-SC01, ePaper, display, Pico, RP2040 Nano Connect, RP2040, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9481, ILI9486, ILI9488, ST7789, ST7796, RM68140, SSD1351, SSD1963, ILI9225, HX8357D, GC9A01, R61581", "description": "A TFT and ePaper (SPI or parallel interface) graphics library with optimisation for Raspberry Pi Pico, RP2040, ESP8266, ESP32 and STM32 processors", "repository": diff --git a/library.properties b/library.properties index 9a7784e..5fa9768 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=TFT_eSPI -version=2.5.34 +version=2.5.40 author=Bodmer maintainer=Bodmer sentence=TFT graphics library for Arduino processors with performance optimisation for RP2040, STM32, ESP8266 and ESP32