From 90af737fa1275f630c31651f84f1750503eb981b Mon Sep 17 00:00:00 2001 From: Bodmer Date: Sun, 26 Apr 2020 17:05:19 +0100 Subject: [PATCH] Fix #606 inconsistency + others TFT_eFEX also needs updating so Rotated_Sprite_3 example renders correctly. pushImage for FLASH images updated so partly off-screen images are correctly rendered. --- Extensions/Sprite.cpp | 4 ++-- TFT_Drivers/ST7796_Init.h | 4 ++-- TFT_eSPI.cpp | 29 ++++++----------------------- TFT_eSPI.h | 2 +- library.json | 2 +- library.properties | 2 +- 6 files changed, 13 insertions(+), 30 deletions(-) diff --git a/Extensions/Sprite.cpp b/Extensions/Sprite.cpp index c940fb9..36a638d 100644 --- a/Extensions/Sprite.cpp +++ b/Extensions/Sprite.cpp @@ -829,7 +829,7 @@ void TFT_eSprite::pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint16_ for (int32_t xp = xo; xp < xo + ws; xp++) { uint16_t color = data[xp + yp * w]; - if(!_iswapBytes) color = color<<8 | color>>8; + if(_iswapBytes) color = color<<8 | color>>8; _img[x + ys * _iwidth] = color; x++; } @@ -934,7 +934,7 @@ void TFT_eSprite::pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const u for (int32_t xp = xo; xp < xo + ws; xp++) { uint16_t color = pgm_read_word(data + xp + yp * w); - if(!_iswapBytes) color = color<<8 | color>>8; + if(_iswapBytes) color = color<<8 | color>>8; _img[x + ys * _iwidth] = color; x++; } diff --git a/TFT_Drivers/ST7796_Init.h b/TFT_Drivers/ST7796_Init.h index 6764ba6..a112815 100644 --- a/TFT_Drivers/ST7796_Init.h +++ b/TFT_Drivers/ST7796_Init.h @@ -25,7 +25,7 @@ writedata(0x48); //X-Mirror, Top-Left to right-Buttom, RGB writecommand(0x3A); //Interface Pixel Format - writedata(0x05); //Control interface color format set to 16 + writedata(0x55); //Control interface color format set to 16 writecommand(0xB4); //Column inversion @@ -104,4 +104,4 @@ begin_tft_write(); writecommand(0x29); //Display on -} +} \ No newline at end of file diff --git a/TFT_eSPI.cpp b/TFT_eSPI.cpp index cb60d8b..77ec03e 100644 --- a/TFT_eSPI.cpp +++ b/TFT_eSPI.cpp @@ -989,7 +989,6 @@ void TFT_eSPI::pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *d ** Function name: pushImage - for FLASH (PROGMEM) stored images ** Description: plot 16 bit image ***************************************************************************************/ -#define PI_BUF_SIZE 128 void TFT_eSPI::pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const uint16_t *data) { // Requires 32 bit aligned access, so use PROGMEM 16 bit word functions @@ -1013,32 +1012,16 @@ void TFT_eSPI::pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const uint1 data += dx + dy * w; - uint16_t buffer[PI_BUF_SIZE]; - uint16_t* pix_buffer = buffer; + uint16_t buffer[dw]; setWindow(x, y, x + dw - 1, y + dh - 1); - // Work out the number whole buffers to send - uint16_t nb = (dw * dh) / PI_BUF_SIZE; - - // Fill and send "nb" buffers to TFT - for (int32_t i = 0; i < nb; i++) { - for (int32_t j = 0; j < PI_BUF_SIZE; j++) { - pix_buffer[j] = pgm_read_word(&data[i * PI_BUF_SIZE + j]); + // Fill and send line buffers to TFT + for (int32_t i = 0; i < dh; i++) { + for (int32_t j = 0; j < dw; j++) { + buffer[j] = pgm_read_word(&data[i * w + j]); } - pushPixels(pix_buffer, PI_BUF_SIZE); - } - - // Work out number of pixels not yet sent - uint16_t np = (dw * dh) % PI_BUF_SIZE; - - // Send any partial buffer left over - if (np) { - for (int32_t i = 0; i < np; i++) - { - pix_buffer[i] = pgm_read_word(&data[nb * PI_BUF_SIZE + i]); - } - pushPixels(pix_buffer, np); + pushPixels(buffer, dw); } inTransaction = false; diff --git a/TFT_eSPI.h b/TFT_eSPI.h index 6437700..af7642f 100644 --- a/TFT_eSPI.h +++ b/TFT_eSPI.h @@ -16,7 +16,7 @@ #ifndef _TFT_eSPIH_ #define _TFT_eSPIH_ -#define TFT_ESPI_VERSION "2.2.1" +#define TFT_ESPI_VERSION "2.2.2" /*************************************************************************************** ** Section 1: Load required header files diff --git a/library.json b/library.json index 229228c..12500ee 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "TFT_eSPI", - "version": "2.2.1", + "version": "2.2.2", "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 62e3802..680bd26 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=TFT_eSPI -version=2.2.1 +version=2.2.2 author=Bodmer maintainer=Bodmer sentence=TFT graphics library for Arduino processors with performance optimisation for STM32, ESP8266 and ESP32