Skip to content

Commit

Permalink
Correct Bodmer#400 and Bodmer#402 + other tweaks
Browse files Browse the repository at this point in the history
Corrected font 2 rendering issue Bodmer#402
Corrected NULL pointer issue Bodmer#400
Changed grave ` character (key for this character is left of numeral 1
key) to degree symbol in font 2
Change setup24 so DC pin is not D3
  • Loading branch information
Bodmer committed Jul 30, 2019
1 parent af4a96a commit 00bf69f
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Extensions/Sprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down
9 changes: 6 additions & 3 deletions Fonts/Font16.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
19 changes: 13 additions & 6 deletions TFT_eSPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;

Expand Down
3 changes: 3 additions & 0 deletions User_Setups/Setup12_M5Stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@


#define SPI_FREQUENCY 27000000

// Optional reduced SPI frequency for reading TFT
#define SPI_READ_FREQUENCY 5000000
5 changes: 3 additions & 2 deletions User_Setups/Setup24_ST7789.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -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":
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 00bf69f

Please sign in to comment.