From d3210a7ee62eec0270bdcc157f6604e99f399057 Mon Sep 17 00:00:00 2001 From: Bodmer Date: Mon, 7 Oct 2019 17:56:11 +0100 Subject: [PATCH] Fix #417 and add for 135x240 display Setup 135 is for TTGO T Display (ESP32) Plus minor tweaks to avoid some warnings --- Extensions/Sprite.cpp | 18 +++++++-- TFT_eSPI.cpp | 4 +- User_Setup_Select.h | 1 + User_Setups/Setup25_TTGO_T_Display.h | 38 +++++++++++++++++++ .../One_bit_Yin_Yang/One_bit_Yin_Yang.ino | 2 +- library.json | 2 +- library.properties | 2 +- 7 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 User_Setups/Setup25_TTGO_T_Display.h diff --git a/Extensions/Sprite.cpp b/Extensions/Sprite.cpp index dae49d1..6e734bd 100644 --- a/Extensions/Sprite.cpp +++ b/Extensions/Sprite.cpp @@ -464,7 +464,13 @@ void TFT_eSprite::pushSprite(int32_t x, int32_t y) { if (!_created) return; - if (_bpp == 16) _tft->pushImage(x, y, _iwidth, _iheight, _img ); + if (_bpp == 16) + { + bool oldSwapBytes = _tft->getSwapBytes(); + _tft->setSwapBytes(false); + _tft->pushImage(x, y, _iwidth, _iheight, _img ); + _tft->setSwapBytes(oldSwapBytes); + } else _tft->pushImage(x, y, _dwidth, _dheight, _img8, (bool)(_bpp == 8)); } @@ -478,7 +484,13 @@ void TFT_eSprite::pushSprite(int32_t x, int32_t y, uint16_t transp) { if (!_created) return; - if (_bpp == 16) _tft->pushImage(x, y, _iwidth, _iheight, _img, transp ); + if (_bpp == 16) + { + bool oldSwapBytes = _tft->getSwapBytes(); + _tft->setSwapBytes(false); + _tft->pushImage(x, y, _iwidth, _iheight, _img, transp ); + _tft->setSwapBytes(oldSwapBytes); + } else if (_bpp == 8) { transp = (uint8_t)((transp & 0xE000)>>8 | (transp & 0x0700)>>6 | (transp & 0x0018)>>3); @@ -716,7 +728,7 @@ void TFT_eSprite::pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const u uint32_t ww = (w+7) & 0xFFF8; for (int32_t yp = 0; yp // Setup file for ESP32 and TTGO T4 (BTC) ILI9341 SPI bus TFT //#include // Setup file for ESP32 and TTGO TM ST7789 SPI bus TFT //#include // Setup file configured for ST7789 240 x 240 +//#include // Setup file for ESP32 and TTGO T-Display ST7789V SPI bus TFT //#include // Setup file configured for my ST7735S 80x160 diff --git a/User_Setups/Setup25_TTGO_T_Display.h b/User_Setups/Setup25_TTGO_T_Display.h new file mode 100644 index 0000000..18a0c2d --- /dev/null +++ b/User_Setups/Setup25_TTGO_T_Display.h @@ -0,0 +1,38 @@ +// Setup for the TTGO T4 ("Bitcoin Tracker") ESP32 board with 2.2" ILI9341 display + +// See SetupX_Template.h for all options available + +#define ST7789_DRIVER + +#define TFT_WIDTH 135 +#define TFT_HEIGHT 240 + +#define CGRAM_OFFSET // Library will add offsets required + +//#define TFT_MISO -1 + +#define TFT_MOSI 19 +#define TFT_SCLK 18 +#define TFT_CS 5 +#define TFT_DC 16 +#define TFT_RST 23 + +#define TFT_BL 4 // Display backlight control pin + +#define TFT_BACKLIGHT_ON HIGH // HIGH or LOW are options + +#define LOAD_GLCD +#define LOAD_FONT2 +#define LOAD_FONT4 +#define LOAD_FONT6 +#define LOAD_FONT7 +#define LOAD_FONT8 +#define LOAD_GFXFF + +#define SMOOTH_FONT + +//#define SPI_FREQUENCY 27000000 + #define SPI_FREQUENCY 40000000 // Maximum for ILI9341 + + +#define SPI_READ_FREQUENCY 6000000 // 6 MHz is the maximum SPI read speed for the ST7789V diff --git a/examples/Sprite/One_bit_Yin_Yang/One_bit_Yin_Yang.ino b/examples/Sprite/One_bit_Yin_Yang/One_bit_Yin_Yang.ino index 40fccb4..7067f7a 100644 --- a/examples/Sprite/One_bit_Yin_Yang/One_bit_Yin_Yang.ino +++ b/examples/Sprite/One_bit_Yin_Yang/One_bit_Yin_Yang.ino @@ -66,7 +66,7 @@ void loop() { // start_angle = 0 - 359 // r = radius -int yinyang(int x, int y, int start_angle, int r) +void yinyang(int x, int y, int start_angle, int r) { int x1 = 0; // getCoord() will update these int y1 = 0; diff --git a/library.json b/library.json index 0134170..bb138b6 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "TFT_eSPI", - "version": "1.4.16", + "version": "1.4.17", "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 3be6902..63a12ef 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=TFT_eSPI -version=1.4.16 +version=1.4.17 author=Bodmer maintainer=Bodmer sentence=A fast TFT graphics library for ESP8266 and ESP32 processors for the Arduino IDE