diff --git a/Extensions/Sprite.cpp b/Extensions/Sprite.cpp index a93cd83..7eea64b 100644 --- a/Extensions/Sprite.cpp +++ b/Extensions/Sprite.cpp @@ -2408,7 +2408,7 @@ void TFT_eSprite::drawGlyph(uint16_t code) if (newSprite) { createSprite(gWidth[gNum], gFont.yAdvance); - if(bg) fillSprite(bg); + if(fg != bg) fillSprite(bg); cursor_x = -gdX[gNum]; cursor_y = 0; } @@ -2437,6 +2437,8 @@ void TFT_eSprite::drawGlyph(uint16_t code) int16_t xs = 0; uint16_t dl = 0; uint8_t pixel = 0; + int32_t cgy = cursor_y + gFont.maxAscent - gdY[gNum]; + int32_t cgx = cursor_x + gdX[gNum]; for (int32_t y = 0; y < gHeight[gNum]; y++) { @@ -2459,33 +2461,35 @@ void TFT_eSprite::drawGlyph(uint16_t code) { if (pixel != 0xFF) { - if (dl) { drawFastHLine( xs, y + cursor_y + gFont.maxAscent - gdY[gNum], dl, fg); dl = 0; } - if (_bpp != 1) drawPixel(x + cursor_x + gdX[gNum], y + cursor_y + gFont.maxAscent - gdY[gNum], alphaBlend(pixel, fg, bg)); - else if (pixel>127) drawPixel(x + cursor_x + gdX[gNum], y + cursor_y + gFont.maxAscent - gdY[gNum], fg); + if (dl) { drawFastHLine( xs, y + cgy, dl, fg); dl = 0; } + if (_bpp != 1) { + if (fg == bg) drawPixel(x + cgx, y + cgy, alphaBlend(pixel, fg, readPixel(x + cgx, y + cgy))); + else drawPixel(x + cgx, y + cgy, alphaBlend(pixel, fg, bg)); + } + else if (pixel>127) drawPixel(x + cgx, y + cgy, fg); } else { - if (dl==0) xs = x + cursor_x + gdX[gNum]; + if (dl==0) xs = x + cgx; dl++; } } else { - if (dl) { drawFastHLine( xs, y + cursor_y + gFont.maxAscent - gdY[gNum], dl, fg); dl = 0; } + if (dl) { drawFastHLine( xs, y + cgy, dl, fg); dl = 0; } } } - if (dl) { drawFastHLine( xs, y + cursor_y + gFont.maxAscent - gdY[gNum], dl, fg); dl = 0; } + if (dl) { drawFastHLine( xs, y + cgy, dl, fg); dl = 0; } } if (pbuffer) free(pbuffer); if (newSprite) { - pushSprite(cursor_x + gdX[gNum], cursor_y, bg); + pushSprite(cgx, cursor_y); deleteSprite(); - cursor_x += gxAdvance[gNum]; } - else cursor_x += gxAdvance[gNum]; + cursor_x += gxAdvance[gNum]; } else { @@ -2503,11 +2507,7 @@ void TFT_eSprite::drawGlyph(uint16_t code) void TFT_eSprite::printToSprite(String string) { if(!fontLoaded) return; - uint16_t len = string.length(); - char cbuffer[len + 1]; // Add 1 for the null - string.toCharArray(cbuffer, len + 1); // Add 1 for the null, otherwise characters get dropped - printToSprite(cbuffer, len); - //printToSprite((char*)string.c_str(), string.length()); + printToSprite((char*)string.c_str(), string.length()); } @@ -2541,7 +2541,7 @@ void TFT_eSprite::printToSprite(char *cbuffer, uint16_t len) //String string) createSprite(sWidth, gFont.yAdvance); - if (textbgcolor != TFT_BLACK) fillSprite(textbgcolor); + if (textcolor != textbgcolor) fillSprite(textbgcolor); } n = 0; @@ -2575,7 +2575,7 @@ int16_t TFT_eSprite::printToSprite(int16_t x, int16_t y, uint16_t index) { createSprite(sWidth, gFont.yAdvance); - if (textbgcolor != TFT_BLACK) fillSprite(textbgcolor); + if (textcolor != textbgcolor) fillSprite(textbgcolor); drawGlyph(gUnicode[index]); diff --git a/TFT_eSPI.h b/TFT_eSPI.h index 60792af..6d25d68 100644 --- a/TFT_eSPI.h +++ b/TFT_eSPI.h @@ -16,7 +16,7 @@ #ifndef _TFT_eSPIH_ #define _TFT_eSPIH_ -#define TFT_ESPI_VERSION "2.3.56" +#define TFT_ESPI_VERSION "2.3.57" // Bit level feature flags // Bit 0 set: viewport capability diff --git a/examples/160 x 128/TFT_graphicstest_PDQ3/TFT_graphicstest_PDQ3.ino b/examples/160 x 128/TFT_graphicstest_PDQ3/TFT_graphicstest_PDQ3.ino index 1cb0515..e74d304 100644 --- a/examples/160 x 128/TFT_graphicstest_PDQ3/TFT_graphicstest_PDQ3.ino +++ b/examples/160 x 128/TFT_graphicstest_PDQ3/TFT_graphicstest_PDQ3.ino @@ -234,7 +234,7 @@ void loop(void) void printnice(int32_t v) { char str[32] = { 0 }; - sprintf(str, "%lu", v); + sprintf(str, "%d", v); for (char *p = (str+strlen(str))-3; p > str; p -= 3) { memmove(p+1, p, strlen(p)+1); diff --git a/examples/320 x 240/TFT_ArcFill/TFT_ArcFill.ino b/examples/320 x 240/TFT_ArcFill/TFT_ArcFill.ino index b9b5198..4ad06ca 100644 --- a/examples/320 x 240/TFT_ArcFill/TFT_ArcFill.ino +++ b/examples/320 x 240/TFT_ArcFill/TFT_ArcFill.ino @@ -59,7 +59,7 @@ void loop() { // colour = 16 bit colour value // Note if rx and ry are the same then an arc of a circle is drawn -int fillArc(int x, int y, int start_angle, int seg_count, int rx, int ry, int w, unsigned int colour) +void fillArc(int x, int y, int start_angle, int seg_count, int rx, int ry, int w, unsigned int colour) { byte seg = 6; // Segments are 3 degrees wide = 120 segments for 360 degrees diff --git a/examples/320 x 240/TFT_FillArcSpiral/TFT_FillArcSpiral.ino b/examples/320 x 240/TFT_FillArcSpiral/TFT_FillArcSpiral.ino index d26fb48..83b8f60 100644 --- a/examples/320 x 240/TFT_FillArcSpiral/TFT_FillArcSpiral.ino +++ b/examples/320 x 240/TFT_FillArcSpiral/TFT_FillArcSpiral.ino @@ -51,7 +51,7 @@ void loop() { // colour = 16 bit colour value // Note if rx and ry are the same an arc of a circle is drawn -int fillArc(int x, int y, int start_angle, int seg_count, int rx, int ry, int w, unsigned int colour) +void fillArc(int x, int y, int start_angle, int seg_count, int rx, int ry, int w, unsigned int colour) { // Make the segment size 7 degrees to prevent gaps when drawing spirals diff --git a/examples/320 x 240/TFT_graphicstest_PDQ/TFT_graphicstest_PDQ.ino b/examples/320 x 240/TFT_graphicstest_PDQ/TFT_graphicstest_PDQ.ino index ee76936..cca3678 100644 --- a/examples/320 x 240/TFT_graphicstest_PDQ/TFT_graphicstest_PDQ.ino +++ b/examples/320 x 240/TFT_graphicstest_PDQ/TFT_graphicstest_PDQ.ino @@ -219,7 +219,7 @@ void loop(void) void printnice(int32_t v) { char str[32] = { 0 }; - sprintf(str, "%lu", v); + sprintf(str, "%d", v); for (char *p = (str+strlen(str))-3; p > str; p -= 3) { memmove(p+1, p, strlen(p)+1); diff --git a/library.json b/library.json index 95c4086..15bfce0 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "TFT_eSPI", - "version": "2.3.56", + "version": "2.3.57", "keywords": "Arduino, tft, ePaper, display, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9486, ST7789, RM68140", "description": "A TFT and ePaper SPI graphics library with optimisation for ESP8266, ESP32 and STM32", "repository": diff --git a/library.properties b/library.properties index 4f97eae..d2e1a9a 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=TFT_eSPI -version=2.3.56 +version=2.3.57 author=Bodmer maintainer=Bodmer sentence=TFT graphics library for Arduino processors with performance optimisation for STM32, ESP8266 and ESP32