diff --git a/Extensions/Sprite.cpp b/Extensions/Sprite.cpp index 832abb9..c2ecf13 100644 --- a/Extensions/Sprite.cpp +++ b/Extensions/Sprite.cpp @@ -1679,7 +1679,7 @@ int16_t TFT_eSprite::drawChar(uint16_t uniCode, int32_t x, int32_t y, uint8_t fo if ((font>2) && (font<9)) { // This is slower than above but is more convenient for the RLE fonts - flash_address = pgm_read_dword( (const void*)pgm_read_dword( &(fontdata[font].chartbl ) ) + uniCode*sizeof(void *) ); + flash_address = pgm_read_dword( (const void*) (pgm_read_dword( &(fontdata[font].chartbl ) ) + uniCode*sizeof(void *)) ); width = pgm_read_byte( (uint8_t *)pgm_read_dword( &(fontdata[font].widthtbl ) ) + uniCode ); height= pgm_read_byte( &fontdata[font].height ); } diff --git a/Fonts/Font16.c b/Fonts/Font16.c index a69c2c1..0f9167f 100644 --- a/Fonts/Font16.c +++ b/Fonts/Font16.c @@ -15,7 +15,8 @@ PROGMEM const unsigned char widtbl_f16[96] = // character width table 8, 4, 8, 8, 7, 10, 8, 8, // char 72 - 79 8, 8, 8, 8, 8, 8, 8, 10, // char 80 - 87 8, 8, 8, 4, 7, 4, 7, 9, // char 88 - 95 - 4, 7, 7, 7, 7, 7, 6, 7, // char 96 - 103 +// 4, 7, 7, 7, 7, 7, 6, 7, // char 96 - 103 grave see lines 411-414 + 5, 7, 7, 7, 7, 7, 6, 7, // char 96 - 103 celcius 7, 4, 5, 6, 4, 8, 7, 8, // char 104 - 111 7, 8, 6, 6, 5, 7, 8, 8, // char 112 - 119 6, 7, 7, 5, 3, 5, 8, 6 // char 120 - 127 @@ -407,8 +408,10 @@ PROGMEM const unsigned char chr_f16_5F[32] = // 1 unsigned chars per row PROGMEM const unsigned char chr_f16_60[16] = // 1 unsigned char per row { - 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x20, 0x00, 0x00, 0x00, 0x00, // row 1 - 11 - 0x00, 0x00, 0x00, 0x00, 0x00 // row 12 - 16 +// 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x20, 0x00, 0x00, 0x00, 0x00, // row 1 - 11 grave +// 0x00, 0x00, 0x00, 0x00, 0x00 // row 12 - 16 + 0x00, 0x00, 0x00, 0x60, 0x90, 0x90, 0x60, 0x00, 0x00, 0x00, 0x00, // row 1 - 11 Celcius + 0x00, 0x00, 0x00, 0x00, 0x00 }; PROGMEM const unsigned char chr_f16_61[16] = // 1 unsigned char per row diff --git a/TFT_eSPI.cpp b/TFT_eSPI.cpp index 5a98bf3..48d9f8e 100644 --- a/TFT_eSPI.cpp +++ b/TFT_eSPI.cpp @@ -2352,7 +2352,7 @@ int16_t TFT_eSPI::textWidth(const char *string, uint8_t font) str_width += pgm_read_byte( widthtable + uniCode); // Normally we need to subtract 32 from uniCode else str_width += pgm_read_byte( widthtable + 32); // Set illegal character = space width } - if ((font == 2) && (str_width > 0)) str_width--; + } else { @@ -4342,23 +4342,24 @@ int16_t TFT_eSPI::drawChar(uint16_t uniCode, int32_t x, int32_t y, uint8_t font) { spi_begin(); - setWindow(x, y, (x + w * 8) - 1, y + height - 1); + setWindow(x, y, x + width - 1, y + height - 1); uint8_t mask; for (int32_t i = 0; i < height; i++) { + pX = width; for (int32_t k = 0; k < w; k++) { - line = pgm_read_byte((uint8_t *)flash_address + w * i + k); - pX = x + k * 8; + line = pgm_read_byte((uint8_t *) (flash_address + w * i + k) ); mask = 0x80; - while (mask) { + while (mask && pX) { if (line & mask) {tft_Write_16(textcolor);} else {tft_Write_16(textbgcolor);} + pX--; mask = mask >> 1; } } - pY += textsize; + if (pX) {tft_Write_16(textbgcolor);} } spi_end(); @@ -4895,6 +4896,12 @@ int16_t TFT_eSPI::drawFloat(float floatNumber, uint8_t dp, int32_t poX, int32_t void TFT_eSPI::setFreeFont(const GFXfont *f) { + if (f == nullptr) // Fix issue #400 (ESP32 crash) + { + setTextFont(1); // Use GLCD font + return; + } + textfont = 1; gfxFont = (GFXfont *)f; diff --git a/User_Setups/Setup12_M5Stack.h b/User_Setups/Setup12_M5Stack.h index d4b50b8..a1b564f 100644 --- a/User_Setups/Setup12_M5Stack.h +++ b/User_Setups/Setup12_M5Stack.h @@ -27,3 +27,6 @@ #define SPI_FREQUENCY 27000000 + +// Optional reduced SPI frequency for reading TFT +#define SPI_READ_FREQUENCY 5000000 \ No newline at end of file diff --git a/User_Setups/Setup24_ST7789.h b/User_Setups/Setup24_ST7789.h index d75b743..44e4343 100644 --- a/User_Setups/Setup24_ST7789.h +++ b/User_Setups/Setup24_ST7789.h @@ -27,8 +27,9 @@ // For NodeMCU - use pin numbers in the form PIN_Dx where Dx is the NodeMCU pin designation #define TFT_CS -1 // Define as not used -#define TFT_DC PIN_D3 // Data Command control pin -#define TFT_RST PIN_D4 // Reset pin (could connect to NodeMCU RST, see next line) +#define TFT_DC PIN_D1 // Data Command control pin +#define TFT_RST PIN_D4 // TFT reset pin (could connect to NodeMCU RST, see next line) +//#define TFT_RST -1 // TFT reset pin connect to NodeMCU RST, must also then add 10K pull down to TFT SCK #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH diff --git a/library.json b/library.json index 4bbe7e7..145f754 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "TFT_eSPI", - "version": "1.4.13", + "version": "1.4.14", "keywords": "tft, ePaper, display, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9486, ST7789, RM68140", "description": "A TFT and ePaper SPI graphics library for ESP8266 and ESP32", "repository": diff --git a/library.properties b/library.properties index 0bb271d..1a8d51b 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=TFT_eSPI -version=1.4.13 +version=1.4.14 author=Bodmer maintainer=Bodmer sentence=A fast TFT graphics library for ESP8266 and ESP32 processors for the Arduino IDE