diff --git a/BUILDS.md b/BUILDS.md index d721334d9..76d046070 100644 --- a/BUILDS.md +++ b/BUILDS.md @@ -251,7 +251,6 @@ Note: the `minimal` variant is not listed as it shouldn't be used outside of the | USE_DISPLAY_SSD1306 | - | - / - | - | - | - | x | | USE_DISPLAY_MATRIX | - | - / - | - | - | - | x | | USE_DISPLAY_SH1106 | - | - / - | - | - | - | x | -| USE_DISPLAY_ILI9341 | - | - / - | - | - | - | x | | USE_DISPLAY_EPAPER_29 | - | - / - | - | - | - | x | | USE_DISPLAY_EPAPER_42 | - | - / - | - | - | - | x | | USE_DISPLAY_SSD1351 | - | - / - | - | - | - | x | @@ -280,4 +279,6 @@ Note: the `minimal` variant is not listed as it shouldn't be used outside of the | USE_DINGTIAN_RELAY | | / - | | | | | | USE_MATTER_DEVICE | | / x | | | | | See SetOption151 | +The following specific display drivers are replaced with uDisplay, see [uDisplay/uTouch documentation](https://tasmota.github.io/docs/Universal-Display-Driver/#migrating-to-udisplay): `USE_DISPLAY_ILI9341` + - USE_MQTT_TLS is enabled by default in every ESP32 variants diff --git a/CHANGELOG.md b/CHANGELOG.md index 606d5951f..08ac396e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ All notable changes to this project will be documented in this file. ### Removed - Unused `#define MQTT_DATA_STRING` support +- ILI9341 driver replaced with uDisplay ## [13.4.0.3] 20240402 ### Added diff --git a/lib/lib_display/ILI9341-gemu-1.0/ILI9341_2.cpp b/lib/lib_display/ILI9341-gemu-1.0/ILI9341_2.cpp deleted file mode 100644 index 2da8d4091..000000000 --- a/lib/lib_display/ILI9341-gemu-1.0/ILI9341_2.cpp +++ /dev/null @@ -1,678 +0,0 @@ -/*! -* @file ILI9341_2.cpp -* -* @mainpage Adafruit ILI9341 TFT Displays -* -* @section intro_sec Introduction -* -* This is the documentation for Adafruit's ILI9341 driver for the -* Arduino platform. -* -* This library works with the Adafruit 2.8" Touch Shield V2 (SPI) -* http://www.adafruit.com/products/1651 -* -* Adafruit 2.4" TFT LCD with Touchscreen Breakout w/MicroSD Socket - ILI9341 -* https://www.adafruit.com/product/2478 -* -* 2.8" TFT LCD with Touchscreen Breakout Board w/MicroSD Socket - ILI9341 -* https://www.adafruit.com/product/1770 -* -* 2.2" 18-bit color TFT LCD display with microSD card breakout - ILI9340 -* https://www.adafruit.com/product/1770 -* -* TFT FeatherWing - 2.4" 320x240 Touchscreen For All Feathers -* https://www.adafruit.com/product/3315 -* -* These displays use SPI to communicate, 4 or 5 pins are required -* to interface (RST is optional). -* -* Adafruit invests time and resources providing this open source code, -* please support Adafruit and open-source hardware by purchasing -* products from Adafruit! -* -* @section dependencies Dependencies -* -* This library depends on -* Adafruit_GFX being present on your system. Please make sure you have -* installed the latest version before using this library. -* -* @section author Author -* -* Written by Limor "ladyada" Fried for Adafruit Industries. -* -* @section license License -* -* BSD license, all text here must be included in any redistribution. -* -*/ - -//#ifdef ESP32 -#include "ILI9341_2.h" -#include - - -// ESP32 uses 2. SPI BUS, ESP8266 uses software spi -#ifdef ESP32 -#include "esp8266toEsp32.h" -#undef ILI9341_2_DIMMER -#define ILI9341_2_DIMMER -#undef ESP32_PWM_CHANNEL -#define ESP32_PWM_CHANNEL 1 -#endif - -#define ILI9341_2_HWSPI - -#if defined (ILI9341_2_HWSPI) -#define SPI_BEGIN_TRANSACTION() if (_hwspi) spi2->beginTransaction(sspi2) -#define SPI_END_TRANSACTION() if (_hwspi) spi2->endTransaction() -#else -#define SPI_BEGIN_TRANSACTION() -#define SPI_END_TRANSACTION() -#endif - - - -const uint16_t ili9341_2_colors[]={ILI9341_BLACK,ILI9341_WHITE,ILI9341_RED,ILI9341_GREEN,ILI9341_BLUE,ILI9341_CYAN,ILI9341_MAGENTA,\ - ILI9341_YELLOW,ILI9341_NAVY,ILI9341_DARKGREEN,ILI9341_DARKCYAN,ILI9341_MAROON,ILI9341_PURPLE,ILI9341_OLIVE,\ -ILI9341_LIGHTGREY,ILI9341_DARKGREY,ILI9341_ORANGE,ILI9341_GREENYELLOW,ILI9341_PINK}; - -uint16_t ILI9341_2::GetColorFromIndex(uint8_t index) { - if (index >= sizeof(ili9341_2_colors) / 2) index = 0; - return ili9341_2_colors[index]; -} - -static const uint8_t PROGMEM ili9341_2_initcmd[] = { - 0xEF, 3, 0x03, 0x80, 0x02, - 0xCF, 3, 0x00, 0xC1, 0x30, - 0xED, 4, 0x64, 0x03, 0x12, 0x81, - 0xE8, 3, 0x85, 0x00, 0x78, - 0xCB, 5, 0x39, 0x2C, 0x00, 0x34, 0x02, - 0xF7, 1, 0x20, - 0xEA, 2, 0x00, 0x00, - ILI9341_2_PWCTR1 , 1, 0x23, // Power control VRH[5:0] - ILI9341_2_PWCTR2 , 1, 0x10, // Power control SAP[2:0];BT[3:0] - ILI9341_2_VMCTR1 , 2, 0x3e, 0x28, // VCM control - ILI9341_2_VMCTR2 , 1, 0x86, // VCM control2 - ILI9341_2_MADCTL , 1, 0x48, // Memory Access Control - ILI9341_2_VSCRSADD, 1, 0x00, // Vertical scroll zero - ILI9341_2_PIXFMT , 1, 0x55, - ILI9341_2_FRMCTR1 , 2, 0x00, 0x18, - ILI9341_2_DFUNCTR , 3, 0x08, 0x82, 0x27, // Display Function Control - 0xF2, 1, 0x00, // 3Gamma Function Disable - ILI9341_2_GAMMASET , 1, 0x01, // Gamma curve selected - ILI9341_2_GMCTRP1 , 15, 0x0F, 0x31, 0x2B, 0x0C, 0x0E, 0x08, // Set Gamma - 0x4E, 0xF1, 0x37, 0x07, 0x10, 0x03, 0x0E, 0x09, 0x00, - ILI9341_2_GMCTRN1 , 15, 0x00, 0x0E, 0x14, 0x03, 0x11, 0x07, // Set Gamma - 0x31, 0xC1, 0x48, 0x08, 0x0F, 0x0C, 0x31, 0x36, 0x0F, - ILI9341_2_SLPOUT , 0x80, // Exit Sleep - ILI9341_2_DISPON , 0x80, // Display on -// ILI9341_2_DISPOFF , 0x80, // Display on - 0x00 // End of list -}; - -static const uint8_t PROGMEM ili9342_initcmd[] = { - 0xEF, 3, 0x03, 0x80, 0x02, - 0xCF, 3, 0x00, 0xC1, 0x30, - 0xED, 4, 0x64, 0x03, 0x12, 0x81, - 0xE8, 3, 0x85, 0x00, 0x78, - 0xCB, 5, 0x39, 0x2C, 0x00, 0x34, 0x02, - 0xF7, 1, 0x20, - 0xEA, 2, 0x00, 0x00, - ILI9341_2_PWCTR1 , 1, 0x23, // Power control VRH[5:0] - ILI9341_2_PWCTR2 , 1, 0x10, // Power control SAP[2:0];BT[3:0] - ILI9341_2_VMCTR1 , 2, 0x2B, 0x2B, // 0x3e, 0x28, // VCM control - ILI9341_2_VMCTR2 , 1, 0xC0, // VCM control2 - ILI9341_2_MADCTL , 1, 0x48, // Memory Access Control - ILI9341_2_VSCRSADD, 1, 0x00, // Vertical scroll zero - ILI9341_2_PIXFMT , 1, 0x55, - ILI9341_2_FRMCTR1 , 2, 0x00, 0x1B, - ILI9341_2_DFUNCTR , 3, 0x08, 0x82, 0x27, // Display Function Control - 0xF2, 1, 0x00, // 3Gamma Function Disable - ILI9341_2_GAMMASET , 1, 0x01, // Gamma curve selected - ILI9341_2_GMCTRP1 , 15, 0x0F, 0x31, 0x2B, 0x0C, 0x0E, 0x08, 0x4E, 0xF1, 0x37, 0x07, 0x10, 0x03, 0x0E, 0x09, 0x00, - ILI9341_2_GMCTRN1 , 15, 0x00, 0x0E, 0x14, 0x03, 0x11, 0x07, 0x31, 0xC1, 0x48, 0x08, 0x0F, 0x0C, 0x31, 0x36, 0x0F, - ILI9341_2_INVON , 0x80, - ILI9341_2_SLPOUT , 0x80, // Exit Sleep - ILI9341_2_DISPON , 0x80, // Display on - 0x00 // End of list -}; - -ILI9341_2::ILI9341_2(int8_t cs, int8_t mosi, int8_t miso, int8_t sclk, int8_t res, int8_t dc, int8_t bp, int8_t spibus, uint8_t dtype) : Renderer(ILI9341_TFTWIDTH, ILI9341_TFTHEIGHT) { - _cs = cs; - _mosi = mosi; - _miso = miso; - _sclk = sclk; - _res = res; - _dc = dc; - _bp = bp; - _hwspi = dtype; // sign ili9341 or 2 - _spibus = spibus; -} - -// special init for ILI9342 uses SPI1 previously defined with SDCard -ILI9341_2::ILI9341_2(int8_t cs, int8_t res, int8_t dc, int8_t bp) : Renderer(ILI9341_TFTWIDTH, ILI9341_TFTHEIGHT) { - _cs = cs; - _res = res; - _dc = dc; - _bp = bp; - _hwspi = 2; // sign ili9342 - _spibus = 1; -} - -#define ILI9341_2_CS_LOW if (_cs>=0) digitalWrite( _cs, LOW); -#define ILI9341_2_CS_HIGH if (_cs>=0) digitalWrite( _cs, HIGH); - - -void ILI9341_2::writecmd(uint8_t d) { - digitalWrite( _dc, LOW); -#ifdef ILI9341_2_HWSPI - spi2->write(d); -#else - spiwrite(d); -#endif - digitalWrite( _dc, HIGH); -} - -void ILI9341_2::init(uint16_t width, uint16_t height) { - //sspi2 = SPISettings(2500000, MSBFIRST, SPI_MODE3); - - if (_hwspi >= 2) { - iwidth = ILI9341_TFTWIDTH; - iheight = ILI9341_TFTHEIGHT; - } else { - iwidth = ILI9341_TFTHEIGHT; - iheight = ILI9341_TFTWIDTH; - } - -#ifdef ILI9341_2_HWSPI - - sspi2 = SPISettings(40000000, MSBFIRST, SPI_MODE0); - - if (_hwspi >= 2) { - spi2 = &SPI; -#ifdef ESP32 - if (_hwspi > 2) { - spi2->begin(_sclk, _miso, _mosi, -1); - } -#else - SPI.begin(); -#endif // ESP32 - } else { -#ifdef ESP32 - if (_spibus == 2) { - spi2 = new SPIClass(HSPI); - } else { - spi2 = &SPI; - } - spi2->begin(_sclk, _miso, _mosi, -1); -#else - SPI.begin(); - spi2 = &SPI; -#endif - } - -#else - pinMode(_mosi, OUTPUT); - digitalWrite(_mosi,HIGH); - pinMode(_sclk, OUTPUT); - digitalWrite(_sclk,LOW); - pinMode(_miso, INPUT); -#endif - - pinMode(_cs, OUTPUT); - digitalWrite(_cs,HIGH); - - pinMode(_dc, OUTPUT); - digitalWrite(_dc,HIGH); - - if (_bp >= 0) { - pinMode(_bp, OUTPUT); - digitalWrite(_bp,HIGH); - } - - if (_res >= 0) { - pinMode(_res, OUTPUT); - digitalWrite(_res, HIGH); - delay(100); - digitalWrite(_res, LOW); - delay(100); - digitalWrite(_res, HIGH); - delay(200); - } else { - SPI_BEGIN_TRANSACTION(); - ILI9341_2_CS_LOW - writecmd(ILI9341_2_SWRESET); // software reset - ILI9341_2_CS_HIGH - SPI_END_TRANSACTION(); - delay(150); - } - - if (_bp >= 0) { -#ifdef ILI9341_2_DIMMER - analogWrite(_bp, 511); -#else - pinMode(_bp, OUTPUT); -#endif - } - - uint8_t cmd, x, numArgs; - const uint8_t *addr; - - if (_hwspi<2) { - addr = ili9341_2_initcmd; - } else { - addr = ili9342_initcmd; - } - - SPI_BEGIN_TRANSACTION(); - - while ((cmd = pgm_read_byte(addr++)) > 0) { - ILI9341_2_CS_LOW - writecmd(cmd); - x = pgm_read_byte(addr++); - numArgs = x & 0x7F; - -#ifdef ILI9341_2_HWSPI - while (numArgs--) spi2->write(pgm_read_byte(addr++)); -#else - while (numArgs--) spiwrite(pgm_read_byte(addr++)); -#endif - - ILI9341_2_CS_HIGH - if (x & 0x80) delay(120); - } - SPI_END_TRANSACTION(); -} - -void ILI9341_2::DisplayInit(int8_t p,int8_t size,int8_t rot,int8_t font) { -// SPI_BEGIN_TRANSACTION(); -// writecmd(ILI9341_2_INVOFF); -// SPI_END_TRANSACTION(); - setRotation(rot); - setTextFont(font&3); - setTextSize(size&7); - setTextColor(ILI9341_WHITE,ILI9341_BLACK); - setCursor(0,0); - fillScreen(ILI9341_BLACK); -} - -void ILI9341_2::setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) { - - if (!x0 && !y0 && !x1 && !y1) { - ILI9341_2_CS_HIGH - SPI_END_TRANSACTION(); - } else { - ILI9341_2_CS_LOW - SPI_BEGIN_TRANSACTION(); - setAddrWindow_int(x0,y0,x1-x0,y1-y0); - } -} - -void ILI9341_2::pushColors(uint16_t *data, uint16_t len, boolean first) { - uint16_t color; - - while (len--) { - color = *data++; -#ifdef ILI9341_2_HWSPI - spi2->write16(color); -#else - spiwrite16(color); -#endif - } - -} - -void ILI9341_2::setAddrWindow_int(uint16_t x, uint16_t y, uint16_t w, uint16_t h) { - uint32_t xa = ((uint32_t)x << 16) | (x+w-1); - uint32_t ya = ((uint32_t)y << 16) | (y+h-1); - - - writecmd(ILI9341_2_CASET); // Column addr set -#ifdef ILI9341_2_HWSPI - spi2->write32(xa); -#else - spiwrite32(xa); -#endif - writecmd(ILI9341_2_PASET); // Row addr set - -#ifdef ILI9341_2_HWSPI - spi2->write32(ya); -#else - spiwrite32(ya); -#endif - writecmd(ILI9341_2_RAMWR); // write to RAM - - -} - -void ILI9341_2::drawPixel(int16_t x, int16_t y, uint16_t color) { - - if((x < 0) ||(x >= _width) || (y < 0) || (y >= _height)) return; - - SPI_BEGIN_TRANSACTION(); - - ILI9341_2_CS_LOW - - setAddrWindow_int(x,y,1,1); - -#ifdef ILI9341_2_HWSPI - spi2->write16(color); -#else - spiwrite16(color); -#endif - - ILI9341_2_CS_HIGH - - SPI_END_TRANSACTION(); -} - - -void ILI9341_2::setRotation(uint8_t m) { - - if (_hwspi < 2) { - rotation = m % 4; // can't be higher than 3 - switch (rotation) { - case 0: - m = (MADCTL_2_MX | MADCTL_2_BGR); - _width = iwidth; - _height = iheight; - break; - case 1: - m = (MADCTL_2_MV | MADCTL_2_BGR); - _width = iheight; - _height = iwidth; - break; - case 2: - m = (MADCTL_2_MY | MADCTL_2_BGR); - _width = iwidth; - _height = iheight; - break; - case 3: - m = (MADCTL_2_MX | MADCTL_2_MY | MADCTL_2_MV | MADCTL_2_BGR); - _width = iheight; - _height = iwidth; - break; - } - -} else { - -#define MADCTL_MY 0x80 ///< Bottom to top -#define MADCTL_MX 0x40 ///< Right to left -#define MADCTL_MV 0x20 ///< Reverse Mode -#define MADCTL_ML 0x10 ///< LCD refresh Bottom to top -#define MADCTL_RGB 0x00 ///< Red-Green-Blue pixel order -#define MADCTL_BGR 0x08 ///< Blue-Green-Red pixel order -#define MADCTL_MH 0x04 ///< LCD refresh right to left - - rotation = m % 4; // can't be higher than 3 - switch (rotation) { - case 0: - m = (MADCTL_BGR); - _width = iwidth; - _height = iheight; - break; - case 1: - m = (MADCTL_MY | MADCTL_MV | MADCTL_BGR); - _width = iheight; - _height = iwidth; - break; - case 2: - m = (MADCTL_MY | MADCTL_MX | MADCTL_BGR); - _width = iwidth; - _height = iheight; - break; - case 3: - m = (MADCTL_MX | MADCTL_MV | MADCTL_BGR); - _width = iheight; - _height = iwidth; - break; - } - } - SPI_BEGIN_TRANSACTION(); - ILI9341_2_CS_LOW - writecmd(ILI9341_2_MADCTL); - spiwrite(m); - ILI9341_2_CS_HIGH - SPI_END_TRANSACTION(); -} - - -void ILI9341_2::drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color) { - - // Rudimentary clipping - if ((x >= _width) || (y >= _height)) return; - if ((y + h - 1) >= _height) h = _height - y; - - SPI_BEGIN_TRANSACTION(); - - ILI9341_2_CS_LOW - - setAddrWindow_int(x, y, 1, h); - - while (h--) { -#ifdef ILI9341_2_HWSPI - spi2->write16(color); -#else - spiwrite16(color); -#endif - } - - ILI9341_2_CS_HIGH - - SPI_END_TRANSACTION(); -} - -void ILI9341_2::drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color) { - - // Rudimentary clipping - if((x >= _width) || (y >= _height)) return; - if((x+w-1) >= _width) w = _width-x; - - - SPI_BEGIN_TRANSACTION(); - - ILI9341_2_CS_LOW - - setAddrWindow_int(x, y, w, 1); - - - while (w--) { -#ifdef ILI9341_2_HWSPI - spi2->write16(color); -#else - spiwrite16(color); -#endif - } - - ILI9341_2_CS_HIGH - - SPI_END_TRANSACTION(); -} - -void ILI9341_2::fillScreen(uint16_t color) { - fillRect(0, 0, _width, _height, color); -} - -// fill a rectangle -void ILI9341_2::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) { - - // rudimentary clipping (drawChar w/big text requires this) - if((x >= _width) || (y >= _height)) return; - if((x + w - 1) >= _width) w = _width - x; - if((y + h - 1) >= _height) h = _height - y; - - - SPI_BEGIN_TRANSACTION(); - - ILI9341_2_CS_LOW - - setAddrWindow_int(x, y, w, h); - - for (y=h; y>0; y--) { - for (x=w; x>0; x--) { -#ifdef ILI9341_2_HWSPI - spi2->write16(color); -#else - spiwrite16(color); -#endif - } - } - ILI9341_2_CS_HIGH - - SPI_END_TRANSACTION(); -} - - - -void ili9342_bpwr(uint8_t on); - -void ILI9341_2::DisplayOnff(int8_t on) { - - if ((_hwspi >= 2) && (_bp < 0)) { - //ili9342_bpwr(on); - if (pwr_cbp) { - pwr_cbp(on); - } - } - - if (on) { - SPI_BEGIN_TRANSACTION(); - ILI9341_2_CS_LOW - writecmd(ILI9341_2_DISPON); - ILI9341_2_CS_HIGH - SPI_END_TRANSACTION(); - if (_bp >= 0) { -#ifdef ILI9341_2_DIMMER - analogWrite(_bp, dimmer * 4); - // ledcWrite(ESP32_PWM_CHANNEL, dimmer); -#else - digitalWrite(_bp, HIGH); -#endif - } - } else { - SPI_BEGIN_TRANSACTION(); - ILI9341_2_CS_LOW - writecmd(ILI9341_2_DISPOFF); - ILI9341_2_CS_HIGH - SPI_END_TRANSACTION(); - if (_bp >= 0) { -#ifdef ILI9341_2_DIMMER - analogWrite(_bp, 0); - // ledcWrite(ESP32_PWM_CHANNEL, 0); -#else - digitalWrite(_bp, LOW); -#endif - } - } -} - -void ILI9341_2::invertDisplay(boolean i) { - SPI_BEGIN_TRANSACTION(); - ILI9341_2_CS_LOW - writecmd(i ? ILI9341_2_INVON : ILI9341_2_INVOFF); - ILI9341_2_CS_HIGH - SPI_END_TRANSACTION(); -} - -void ILI9341_2::reverseDisplay(boolean i) { - SPI_BEGIN_TRANSACTION(); - ILI9341_2_CS_LOW - if (i) { - writecmd(ILI9341_2_FRMCTR1); - spiwrite(0x00); - spiwrite(0x13); - writecmd(ILI9341_2_MADCTL); - spiwrite(0x01); - spiwrite(0x08); - } else { - writecmd(ILI9341_2_FRMCTR1); - spiwrite(0x00); - spiwrite(0x18); - writecmd(ILI9341_2_MADCTL); - spiwrite(0x01); - spiwrite(0x48); - } - ILI9341_2_CS_HIGH - SPI_END_TRANSACTION(); -} - -void ili9342_dimm(uint8_t dim); - -// dimmer 0-100 -void ILI9341_2::dim(uint8_t dim) { - dimmer = dim; - if (dimmer>15) dimmer=15; - dimmer=((float)dimmer/15.0)*255.0; -#ifdef ESP32 - if (_bp>=0) { - analogWrite(_bp, dimmer * 4); - // ledcWrite(ESP32_PWM_CHANNEL,dimmer); - } else { - if (_hwspi>=2) { - //ili9342_dimm(dim); - if (dim_cbp) { - dim_cbp(dim); - } - } - } -#endif -} - - -void ILI9341_2::spiwrite(uint8_t c) { - -#ifdef ILI9341_2_HWSPI - spi2->write(c); -#else - for (uint8_t bit = 0x80; bit; bit >>= 1) { - digitalWrite(_sclk, LOW); - if (c & bit) digitalWrite(_mosi, HIGH); - else digitalWrite(_mosi, LOW); - digitalWrite(_sclk, HIGH); - } -#endif - -} - -void ILI9341_2::spiwrite16(uint16_t c) { -#ifdef ILI9341_2_HWSPI - spi2->write16(c); -#else - spiwrite(c>>8); - spiwrite(c); -#endif -} - -void ILI9341_2::spiwrite32(uint32_t c) { -#ifdef ILI9341_2_HWSPI - spi2->write32(c); -#else - spiwrite(c>>24); - spiwrite(c>>16); - spiwrite(c>>8); - spiwrite(c); -#endif -} - -void ILI9341_2::setScrollMargins(uint16_t top, uint16_t bottom) { - uint16_t height = _height - (top + bottom); - SPI_BEGIN_TRANSACTION(); - ILI9341_2_CS_LOW - writecmd(0x33); - - spiwrite16(top); - spiwrite16(height); - spiwrite16(bottom); - ILI9341_2_CS_HIGH - SPI_END_TRANSACTION(); -} - - -void ILI9341_2::scrollTo(uint16_t y) { - SPI_BEGIN_TRANSACTION(); - ILI9341_2_CS_LOW - writecmd(ILI9341_2_VSCRSADD); - spiwrite16(y); - ILI9341_2_CS_HIGH - SPI_END_TRANSACTION(); -} diff --git a/lib/lib_display/ILI9341-gemu-1.0/ILI9341_2.h b/lib/lib_display/ILI9341-gemu-1.0/ILI9341_2.h deleted file mode 100644 index 88843016c..000000000 --- a/lib/lib_display/ILI9341-gemu-1.0/ILI9341_2.h +++ /dev/null @@ -1,163 +0,0 @@ -/*************************************************** - STM32 Support added by Jaret Burkett at OSHlab.com - - This is our library for the Adafruit ILI9341_2 Breakout and Shield - ----> http://www.adafruit.com/products/1651 - - Check out the links above for our tutorials and wiring diagrams - These displays use SPI to communicate, 4 or 5 pins are required to - interface (RST is optional) - Adafruit invests time and resources providing this open source code, - please support Adafruit and open-source hardware by purchasing - products from Adafruit! - - Written by Limor Fried/Ladyada for Adafruit Industries. - MIT license, all text above must be included in any redistribution - ****************************************************/ - -#ifndef _ILI9341_2H_ -#define _ILI9341_2H_ - -#include "Arduino.h" -#include -#include - -#define ILI9341_TFTWIDTH 320 -#define ILI9341_TFTHEIGHT 240 - -#define ILI9341_2_NOP 0x00 ///< No-op register -#define ILI9341_2_SWRESET 0x01 ///< Software reset register -#define ILI9341_2_RDDID 0x04 ///< Read display identification information -#define ILI9341_2_RDDST 0x09 ///< Read Display Status - -#define ILI9341_2_SLPIN 0x10 ///< Enter Sleep Mode -#define ILI9341_2_SLPOUT 0x11 ///< Sleep Out -#define ILI9341_2_PTLON 0x12 ///< Partial Mode ON -#define ILI9341_2_NORON 0x13 ///< Normal Display Mode ON - -#define ILI9341_2_RDMODE 0x0A ///< Read Display Power Mode -#define ILI9341_2_RDMADCTL 0x0B ///< Read Display MADCTL -#define ILI9341_2_RDPIXFMT 0x0C ///< Read Display Pixel Format -#define ILI9341_2_RDIMGFMT 0x0D ///< Read Display Image Format -#define ILI9341_2_RDSELFDIAG 0x0F ///< Read Display Self-Diagnostic Result - -#define ILI9341_2_INVOFF 0x20 ///< Display Inversion OFF -#define ILI9341_2_INVON 0x21 ///< Display Inversion ON -#define ILI9341_2_GAMMASET 0x26 ///< Gamma Set -#define ILI9341_2_DISPOFF 0x28 ///< Display OFF -#define ILI9341_2_DISPON 0x29 ///< Display ON - -#define ILI9341_2_CASET 0x2A ///< Column Address Set -#define ILI9341_2_PASET 0x2B ///< Page Address Set -#define ILI9341_2_RAMWR 0x2C ///< Memory Write -#define ILI9341_2_RAMRD 0x2E ///< Memory Read - -#define ILI9341_2_PTLAR 0x30 ///< Partial Area -#define ILI9341_2_MADCTL 0x36 ///< Memory Access Control -#define ILI9341_2_VSCRSADD 0x37 ///< Vertical Scrolling Start Address -#define ILI9341_2_PIXFMT 0x3A ///< COLMOD: Pixel Format Set - -#define ILI9341_2_FRMCTR1 0xB1 ///< Frame Rate Control (In Normal Mode/Full Colors) -#define ILI9341_2_FRMCTR2 0xB2 ///< Frame Rate Control (In Idle Mode/8 colors) -#define ILI9341_2_FRMCTR3 0xB3 ///< Frame Rate control (In Partial Mode/Full Colors) -#define ILI9341_2_INVCTR 0xB4 ///< Display Inversion Control -#define ILI9341_2_DFUNCTR 0xB6 ///< Display Function Control - -#define ILI9341_2_PWCTR1 0xC0 ///< Power Control 1 -#define ILI9341_2_PWCTR2 0xC1 ///< Power Control 2 -#define ILI9341_2_PWCTR3 0xC2 ///< Power Control 3 -#define ILI9341_2_PWCTR4 0xC3 ///< Power Control 4 -#define ILI9341_2_PWCTR5 0xC4 ///< Power Control 5 -#define ILI9341_2_VMCTR1 0xC5 ///< VCOM Control 1 -#define ILI9341_2_VMCTR2 0xC7 ///< VCOM Control 2 - -#define ILI9341_2_RDID1 0xDA ///< Read ID 1 -#define ILI9341_2_RDID2 0xDB ///< Read ID 2 -#define ILI9341_2_RDID3 0xDC ///< Read ID 3 -#define ILI9341_2_RDID4 0xDD ///< Read ID 4 - -#define ILI9341_2_GMCTRP1 0xE0 ///< Positive Gamma Correction -#define ILI9341_2_GMCTRN1 0xE1 ///< Negative Gamma Correction - - -// Color definitions -#define ILI9341_BLACK 0x0000 /* 0, 0, 0 */ -#define ILI9341_NAVY 0x000F /* 0, 0, 128 */ -#define ILI9341_DARKGREEN 0x03E0 /* 0, 128, 0 */ -#define ILI9341_DARKCYAN 0x03EF /* 0, 128, 128 */ -#define ILI9341_MAROON 0x7800 /* 128, 0, 0 */ -#define ILI9341_PURPLE 0x780F /* 128, 0, 128 */ -#define ILI9341_OLIVE 0x7BE0 /* 128, 128, 0 */ -#define ILI9341_LIGHTGREY 0xC618 /* 192, 192, 192 */ -#define ILI9341_DARKGREY 0x7BEF /* 128, 128, 128 */ -#define ILI9341_BLUE 0x001F /* 0, 0, 255 */ -#define ILI9341_GREEN 0x07E0 /* 0, 255, 0 */ -#define ILI9341_CYAN 0x07FF /* 0, 255, 255 */ -#define ILI9341_RED 0xF800 /* 255, 0, 0 */ -#define ILI9341_MAGENTA 0xF81F /* 255, 0, 255 */ -#define ILI9341_YELLOW 0xFFE0 /* 255, 255, 0 */ -#define ILI9341_WHITE 0xFFFF /* 255, 255, 255 */ -#define ILI9341_ORANGE 0xFD20 /* 255, 165, 0 */ -#define ILI9341_GREENYELLOW 0xAFE5 /* 173, 255, 47 */ -#define ILI9341_PINK 0xF81F - - -#define MADCTL_2_MY 0x80 ///< Bottom to top -#define MADCTL_2_MX 0x40 ///< Right to left -#define MADCTL_2_MV 0x20 ///< Reverse Mode -#define MADCTL_2_ML 0x10 ///< LCD refresh Bottom to top -#define MADCTL_2_RGB 0x00 ///< Red-Green-Blue pixel order -#define MADCTL_2_BGR 0x08 ///< Blue-Green-Red pixel order -#define MADCTL_2_MH 0x04 ///< LCD refresh right to left - - -class ILI9341_2 : public Renderer { - - public: - - ILI9341_2(int8_t cs, int8_t mosi, int8_t miso, int8_t sclk, int8_t res, int8_t dc, int8_t bp, int8_t spibus, uint8_t dtype); - ILI9341_2(int8_t cs, int8_t res, int8_t dc, int8_t bp); - - void init(uint16_t width, uint16_t height); - uint16_t GetColorFromIndex(uint8_t index); - - private: - SPIClass *spi2; - SPISettings sspi2; - void writecmd(uint8_t d); - void setAddrWindow(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2); - void setAddrWindow_int(uint16_t x, uint16_t y, uint16_t w, uint16_t h); - void drawPixel(int16_t x, int16_t y, uint16_t color); - void DisplayOnff(int8_t on); - void setRotation(uint8_t m); - void DisplayInit(int8_t p,int8_t size,int8_t rot,int8_t font); - void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color); - void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color); - void fillScreen(uint16_t color); - void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); - void dim(uint8_t dim); - void pushColors(uint16_t *data, uint16_t len, boolean first); - void invertDisplay(boolean i); - void reverseDisplay(boolean i); - void spiwrite(uint8_t c); - void spiwrite16(uint16_t c); - void spiwrite32(uint32_t c); - void setScrollMargins(uint16_t top, uint16_t bottom); - void scrollTo(uint16_t y); - - uint8_t tabcolor; - uint8_t dimmer; - int8_t _cs; - int8_t _mosi; - int8_t _miso; - int8_t _sclk; - int8_t _res; - int8_t _dc; - int8_t _bp; - int8_t _spibus; - int8_t _hwspi; - uint16_t iwidth; - uint16_t iheight; -}; - -#endif diff --git a/lib/lib_display/ILI9341-gemu-1.0/library.properties b/lib/lib_display/ILI9341-gemu-1.0/library.properties deleted file mode 100644 index 5373590b5..000000000 --- a/lib/lib_display/ILI9341-gemu-1.0/library.properties +++ /dev/null @@ -1,9 +0,0 @@ -name=ILI9341 -version=1.0.0 -author=Gerhard Mutz -maintainer=Gerhard Mutz -sentence=ILI9341 ESP8266 ESP32 display driver for Tasmota -paragraph=ILI9341 ESP8266 ESP32 display driver for Tasmota -category=Display -url=https://github.com/arendst/Tasmota -architectures=* diff --git a/tasmota/include/tasmota_template.h b/tasmota/include/tasmota_template.h index cd03a9b4c..cc0f34bba 100644 --- a/tasmota/include/tasmota_template.h +++ b/tasmota/include/tasmota_template.h @@ -658,10 +658,11 @@ const uint16_t kGpioNiceList[] PROGMEM = { AGPIO(GPIO_TS_RST), // Touch Reset AGPIO(GPIO_TS_IRQ), // Touch IRQ #endif // USE_UNIVERSAL_TOUCH -#ifdef USE_DISPLAY_ILI9341 - AGPIO(GPIO_ILI9341_CS), - AGPIO(GPIO_ILI9341_DC), -#endif // USE_DISPLAY_ILI9341 +// REMOVED +// #ifdef USE_DISPLAY_ILI9341 +// AGPIO(GPIO_ILI9341_CS), +// AGPIO(GPIO_ILI9341_DC), +// #endif // USE_DISPLAY_ILI9341 #ifdef USE_XPT2046 AGPIO(GPIO_XPT2046_CS), // XPT2046 SPI Chip Select diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index 564384320..056d8f030 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -804,7 +804,7 @@ https://rya.nc/tasmota-fingerprint.html" // #define USE_NRF24 // Add SPI support for NRF24L01(+) (+2k6 code) #define USE_MIBLE // BLE-bridge for some Mijia-BLE-sensors (+4k7 code) // #define USE_DISPLAY // Add SPI Display support for 320x240 and 480x320 TFT - #define USE_DISPLAY_ILI9341 // [DisplayModel 4] Enable ILI9341 Tft 480x320 display (+19k code) + // REMOVED -- #define USE_DISPLAY_ILI9341 // [DisplayModel 4] Enable ILI9341 Tft 480x320 display (+19k code) // #define USE_DISPLAY_EPAPER_29 // [DisplayModel 5] Enable e-paper 2.9 inch display (+19k code) // #define USE_DISPLAY_EPAPER_42 // [DisplayModel 6] Enable e-paper 4.2 inch display // #define USE_DISPLAY_SSD1351 // [DisplayModel 9] Enable SSD1351 module diff --git a/tasmota/tasmota_support/support_features.ino b/tasmota/tasmota_support/support_features.ino index d10272352..dcd317d16 100644 --- a/tasmota/tasmota_support/support_features.ino +++ b/tasmota/tasmota_support/support_features.ino @@ -151,9 +151,10 @@ constexpr uint32_t feature[] = { #if defined(USE_I2C) && defined(USE_DISPLAY) && defined(USE_DISPLAY_MATRIX) 0x00000200 | // xdsp_03_matrix.ino #endif -#if defined(USE_SPI) && defined(USE_DISPLAY) && defined(USE_DISPLAY_ILI9341) - 0x00000400 | // xdsp_04_ili9341.ino -#endif +// REMOVED +// #if defined(USE_SPI) && defined(USE_DISPLAY) && defined(USE_DISPLAY_ILI9341) +// 0x00000400 | // xdsp_04_ili9341.ino +// #endif #if defined(USE_SPI) && defined(USE_DISPLAY) && defined(USE_DISPLAY_EPAPER_29) 0x00000800 | // xdsp_05_epaper.ino #endif diff --git a/tasmota/tasmota_xdsp_display/xdsp_04_ili9341.ino b/tasmota/tasmota_xdsp_display/xdsp_04_ili9341.ino index 169e223c2..2265dc2df 100644 --- a/tasmota/tasmota_xdsp_display/xdsp_04_ili9341.ino +++ b/tasmota/tasmota_xdsp_display/xdsp_04_ili9341.ino @@ -17,397 +17,400 @@ along with this program. If not, see . */ -#ifdef USE_SPI -#ifdef USE_DISPLAY -#ifdef USE_DISPLAY_ILI9341 +// REMOVED +// DEPRECATED - USE UNIVERSAL DISPLAY INSTEAD, https://tasmota.github.io/docs/Universal-Display-Driver/#migrating-to-udisplay -#define XDSP_04 4 +// #ifdef USE_SPI +// #ifdef USE_DISPLAY +// #ifdef USE_DISPLAY_ILI9341 -enum IliModes { ILIMODE_9341 = 1, ILIMODE_9342, ILIMODE_MAX }; +// #define XDSP_04 4 -#include +// enum IliModes { ILIMODE_9341 = 1, ILIMODE_9342, ILIMODE_MAX }; -extern uint8_t color_type; -ILI9341_2 *ili9341_2; +// #include -#if defined(USE_FT5206) -#include -uint8_t ili9342_ctouch_counter = 0; -#elif defined(USE_XPT2046) -#include -uint8_t ili9342_ctouch_counter = 0; -#endif // USE_FT5206 +// extern uint8_t color_type; +// ILI9341_2 *ili9341_2; -bool tft_init_done = false; +// #if defined(USE_FT5206) +// #include +// uint8_t ili9342_ctouch_counter = 0; +// #elif defined(USE_XPT2046) +// #include +// uint8_t ili9342_ctouch_counter = 0; +// #endif // USE_FT5206 -void Core2DisplayPower(uint8_t on); -void Core2DisplayDim(uint8_t dim); +// bool tft_init_done = false; -//Settings->display_options.type = ILIMODE_9341; +// void Core2DisplayPower(uint8_t on); +// void Core2DisplayDim(uint8_t dim); -/*********************************************************************************************/ +// //Settings->display_options.type = ILIMODE_9341; -void ILI9341_InitDriver() -{ +// /*********************************************************************************************/ - // There are displays without CS - if (PinUsed(GPIO_ILI9341_CS) || PinUsed(GPIO_ILI9341_DC) && - (TasmotaGlobal.spi_enabled || TasmotaGlobal.soft_spi_enabled)) { +// void ILI9341_InitDriver() +// { - Settings->display_model = XDSP_04; +// // There are displays without CS +// if (PinUsed(GPIO_ILI9341_CS) || PinUsed(GPIO_ILI9341_DC) && +// (TasmotaGlobal.spi_enabled || TasmotaGlobal.soft_spi_enabled)) { - if (Settings->display_width != ILI9341_TFTWIDTH) { - Settings->display_width = ILI9341_TFTWIDTH; - } - if (Settings->display_height != ILI9341_TFTHEIGHT) { - Settings->display_height = ILI9341_TFTHEIGHT; - } +// Settings->display_model = XDSP_04; - if (!Settings->display_options.type || (Settings->display_options.type >= ILIMODE_MAX)) { - Settings->display_options.type = ILIMODE_9341; - } +// if (Settings->display_width != ILI9341_TFTWIDTH) { +// Settings->display_width = ILI9341_TFTWIDTH; +// } +// if (Settings->display_height != ILI9341_TFTHEIGHT) { +// Settings->display_height = ILI9341_TFTHEIGHT; +// } - // default colors - fg_color = ILI9341_WHITE; - bg_color = ILI9341_BLACK; +// if (!Settings->display_options.type || (Settings->display_options.type >= ILIMODE_MAX)) { +// Settings->display_options.type = ILIMODE_9341; +// } - // check for special case with 2 SPI busses (ESP32 bitcoin) - if (TasmotaGlobal.soft_spi_enabled) { - // Init renderer, may use hardware spi, however we use SSPI defintion because SD card uses SPI definition (2 spi busses) - if (PinUsed(GPIO_SSPI_MOSI) && PinUsed(GPIO_SSPI_MISO) && PinUsed(GPIO_SSPI_SCLK)) { - ili9341_2 = new ILI9341_2(Pin(GPIO_ILI9341_CS), Pin(GPIO_SSPI_MOSI), Pin(GPIO_SSPI_MISO), Pin(GPIO_SSPI_SCLK), Pin(GPIO_OLED_RESET), Pin(GPIO_ILI9341_DC), Pin(GPIO_BACKLIGHT), 2, Settings->display_options.type & 3); - } - } else if (TasmotaGlobal.spi_enabled) { - if (PinUsed(GPIO_ILI9341_DC)) { - ili9341_2 = new ILI9341_2(Pin(GPIO_ILI9341_CS), Pin(GPIO_SPI_MOSI), Pin(GPIO_SPI_MISO), Pin(GPIO_SPI_CLK), Pin(GPIO_OLED_RESET), Pin(GPIO_ILI9341_DC), Pin(GPIO_BACKLIGHT), 1, Settings->display_options.type & 3); - } - } +// // default colors +// fg_color = ILI9341_WHITE; +// bg_color = ILI9341_BLACK; - if (ili9341_2 == nullptr) { - AddLog(LOG_LEVEL_INFO, PSTR("DSP: ILI934x invalid GPIOs")); - return; - } +// // check for special case with 2 SPI busses (ESP32 bitcoin) +// if (TasmotaGlobal.soft_spi_enabled) { +// // Init renderer, may use hardware spi, however we use SSPI defintion because SD card uses SPI definition (2 spi busses) +// if (PinUsed(GPIO_SSPI_MOSI) && PinUsed(GPIO_SSPI_MISO) && PinUsed(GPIO_SSPI_SCLK)) { +// ili9341_2 = new ILI9341_2(Pin(GPIO_ILI9341_CS), Pin(GPIO_SSPI_MOSI), Pin(GPIO_SSPI_MISO), Pin(GPIO_SSPI_SCLK), Pin(GPIO_OLED_RESET), Pin(GPIO_ILI9341_DC), Pin(GPIO_BACKLIGHT), 2, Settings->display_options.type & 3); +// } +// } else if (TasmotaGlobal.spi_enabled) { +// if (PinUsed(GPIO_ILI9341_DC)) { +// ili9341_2 = new ILI9341_2(Pin(GPIO_ILI9341_CS), Pin(GPIO_SPI_MOSI), Pin(GPIO_SPI_MISO), Pin(GPIO_SPI_CLK), Pin(GPIO_OLED_RESET), Pin(GPIO_ILI9341_DC), Pin(GPIO_BACKLIGHT), 1, Settings->display_options.type & 3); +// } +// } - ili9341_2->init(Settings->display_width, Settings->display_height); - renderer = ili9341_2; +// if (ili9341_2 == nullptr) { +// AddLog(LOG_LEVEL_INFO, PSTR("DSP: ILI934x invalid GPIOs")); +// return; +// } -#ifdef USE_M5STACK_CORE2 - renderer->SetPwrCB(Core2DisplayPower); - renderer->SetDimCB(Core2DisplayDim); -#endif +// ili9341_2->init(Settings->display_width, Settings->display_height); +// renderer = ili9341_2; - renderer->DisplayInit(DISPLAY_INIT_MODE, Settings->display_size, Settings->display_rotate, Settings->display_font); - renderer->dim(GetDisplayDimmer16()); +// #ifdef USE_M5STACK_CORE2 +// renderer->SetPwrCB(Core2DisplayPower); +// renderer->SetDimCB(Core2DisplayDim); +// #endif -#ifdef SHOW_SPLASH - if (!Settings->flag5.display_no_splash) { - // Welcome text - renderer->setTextFont(2); - renderer->setTextSize(1); - renderer->setTextColor(ILI9341_WHITE, ILI9341_BLACK); - renderer->DrawStringAt(50, (Settings->display_height/2)-12, (Settings->display_options.type & 3)==ILIMODE_9341?"ILI9341 TFT!":"ILI9342 TFT!", ILI9341_WHITE, 0); - delay(1000); - } -#endif // SHOW_SPLASH +// renderer->DisplayInit(DISPLAY_INIT_MODE, Settings->display_size, Settings->display_rotate, Settings->display_font); +// renderer->dim(GetDisplayDimmer16()); - color_type = COLOR_COLOR; +// #ifdef SHOW_SPLASH +// if (!Settings->flag5.display_no_splash) { +// // Welcome text +// renderer->setTextFont(2); +// renderer->setTextSize(1); +// renderer->setTextColor(ILI9341_WHITE, ILI9341_BLACK); +// renderer->DrawStringAt(50, (Settings->display_height/2)-12, (Settings->display_options.type & 3)==ILIMODE_9341?"ILI9341 TFT!":"ILI9342 TFT!", ILI9341_WHITE, 0); +// delay(1000); +// } +// #endif // SHOW_SPLASH -#ifdef USE_DISPLAY_MODES1TO5 - if (Settings->display_rotate) { - DisplayAllocScreenBuffer(); - } - Ili9341InitMode(); -#endif // USE_DISPLAY_MODES1TO5 +// color_type = COLOR_COLOR; -#ifdef ESP32 -#ifdef USE_FT5206 - // start digitizer with fixed adress and pins for esp32 - #undef SDA_2 - #define SDA_2 21 - #undef SCL_2 - #define SCL_2 22 - Wire1.begin(SDA_2, SCL_2, (uint32_t)400000); - FT5206_Touch_Init(Wire1); -#endif // USE_FT5206 -#endif // ESP32 +// #ifdef USE_DISPLAY_MODES1TO5 +// if (Settings->display_rotate) { +// DisplayAllocScreenBuffer(); +// } +// Ili9341InitMode(); +// #endif // USE_DISPLAY_MODES1TO5 -#ifdef USE_XPT2046 - XPT2046_Touch_Init(Pin(GPIO_XPT2046_CS),-1,0); -#endif +// #ifdef ESP32 +// #ifdef USE_FT5206 +// // start digitizer with fixed adress and pins for esp32 +// #undef SDA_2 +// #define SDA_2 21 +// #undef SCL_2 +// #define SCL_2 22 +// Wire1.begin(SDA_2, SCL_2, (uint32_t)400000); +// FT5206_Touch_Init(Wire1); +// #endif // USE_FT5206 +// #endif // ESP32 - tft_init_done = true; - AddLog(LOG_LEVEL_INFO, PSTR("DSP: ILI9341")); - } -} +// #ifdef USE_XPT2046 +// XPT2046_Touch_Init(Pin(GPIO_XPT2046_CS),-1,0); +// #endif -#if defined(USE_FT5206) || defined(USE_XPT2046) -#ifdef USE_TOUCH_BUTTONS +// tft_init_done = true; +// AddLog(LOG_LEVEL_INFO, PSTR("DSP: ILI9341")); +// } +// } -#ifdef USE_FT5206 -void FT5206_TS_RotConvert(int16_t *x, int16_t *y) { +// #if defined(USE_FT5206) || defined(USE_XPT2046) +// #ifdef USE_TOUCH_BUTTONS -int16_t temp; - if (renderer) { - uint8_t rot = renderer->getRotation(); - switch (rot) { - case 0: - break; - case 1: - temp = *y; - *y = renderer->height() - *x; - *x = temp; - break; - case 2: - *x = renderer->width() - *x; - *y = renderer->height() - *y; - break; - case 3: - temp = *y; - *y = *x; - *x = renderer->width() - temp; - break; - } - } -} -#endif // USE_FT5206 +// #ifdef USE_FT5206 +// void FT5206_TS_RotConvert(int16_t *x, int16_t *y) { -#ifdef USE_XPT2046 -void XPT2046_TS_RotConvert(int16_t *x, int16_t *y) { +// int16_t temp; +// if (renderer) { +// uint8_t rot = renderer->getRotation(); +// switch (rot) { +// case 0: +// break; +// case 1: +// temp = *y; +// *y = renderer->height() - *x; +// *x = temp; +// break; +// case 2: +// *x = renderer->width() - *x; +// *y = renderer->height() - *y; +// break; +// case 3: +// temp = *y; +// *y = *x; +// *x = renderer->width() - temp; +// break; +// } +// } +// } +// #endif // USE_FT5206 -int16_t temp; - if (renderer) { - uint8_t rot = renderer->getRotation(); -// AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(" TS: before convert x:%d / y:%d screen r:%d / w:%d / h:%d"), *x, *y,rot,renderer->width(),renderer->height()); - temp = map(*x,XPT2046_MINX,XPT2046_MAXX, renderer->height(), 0); - *x = map(*y,XPT2046_MINY,XPT2046_MAXY, renderer->width(), 0); - *y = temp; - switch (rot) { - case 0: - break; - case 1: - temp = *y; - *y = renderer->width() - *x; - *x = temp; - break; - case 2: - *x = renderer->width() - *x; - *y = renderer->height() - *y; - break; - case 3: - temp = *y; - *y = *x; - *x = renderer->height() - temp; - break; - } - AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(" TS: after convert x:%d / y:%d screen r:%d / w:%d / h:%d"), *x, *y,rot,renderer->width(),renderer->height()); - } -} -#endif +// #ifdef USE_XPT2046 +// void XPT2046_TS_RotConvert(int16_t *x, int16_t *y) { -// check digitizer hit -void ili9342_CheckTouch() { -ili9342_ctouch_counter++; - if (2 == ili9342_ctouch_counter) { - // every 100 ms should be enough - ili9342_ctouch_counter = 0; -#ifdef USE_FT5206 - if (FT5206_found) { - Touch_Check(FT5206_TS_RotConvert); - } -#endif // USE_FT5206 -#ifdef USE_XPT2046 - if (XPT2046_found) { - Touch_Check(XPT2046_TS_RotConvert); - } -#endif // USE_XPT2046 - } -} -#endif // USE_TOUCH_BUTTONS -#endif // USE_FT5206 +// int16_t temp; +// if (renderer) { +// uint8_t rot = renderer->getRotation(); +// // AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(" TS: before convert x:%d / y:%d screen r:%d / w:%d / h:%d"), *x, *y,rot,renderer->width(),renderer->height()); +// temp = map(*x,XPT2046_MINX,XPT2046_MAXX, renderer->height(), 0); +// *x = map(*y,XPT2046_MINY,XPT2046_MAXY, renderer->width(), 0); +// *y = temp; +// switch (rot) { +// case 0: +// break; +// case 1: +// temp = *y; +// *y = renderer->width() - *x; +// *x = temp; +// break; +// case 2: +// *x = renderer->width() - *x; +// *y = renderer->height() - *y; +// break; +// case 3: +// temp = *y; +// *y = *x; +// *x = renderer->height() - temp; +// break; +// } +// AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(" TS: after convert x:%d / y:%d screen r:%d / w:%d / h:%d"), *x, *y,rot,renderer->width(),renderer->height()); +// } +// } +// #endif + +// // check digitizer hit +// void ili9342_CheckTouch() { +// ili9342_ctouch_counter++; +// if (2 == ili9342_ctouch_counter) { +// // every 100 ms should be enough +// ili9342_ctouch_counter = 0; +// #ifdef USE_FT5206 +// if (FT5206_found) { +// Touch_Check(FT5206_TS_RotConvert); +// } +// #endif // USE_FT5206 +// #ifdef USE_XPT2046 +// if (XPT2046_found) { +// Touch_Check(XPT2046_TS_RotConvert); +// } +// #endif // USE_XPT2046 +// } +// } +// #endif // USE_TOUCH_BUTTONS +// #endif // USE_FT5206 -#ifdef USE_DISPLAY_MODES1TO5 +// #ifdef USE_DISPLAY_MODES1TO5 -#define TFT_TOP 16 -#define TFT_BOTTOM 16 -#define TFT_FONT_WIDTH 6 -#define TFT_FONT_HEIGTH 8 // Adafruit minimal font heigth pixels +// #define TFT_TOP 16 +// #define TFT_BOTTOM 16 +// #define TFT_FONT_WIDTH 6 +// #define TFT_FONT_HEIGTH 8 // Adafruit minimal font heigth pixels -uint16_t tft_top = TFT_TOP; -uint16_t tft_bottom = TFT_BOTTOM; -uint16_t tft_scroll = TFT_TOP; -uint16_t tft_cols = 0; +// uint16_t tft_top = TFT_TOP; +// uint16_t tft_bottom = TFT_BOTTOM; +// uint16_t tft_scroll = TFT_TOP; +// uint16_t tft_cols = 0; -bool Ili9341Header(void) { - if (Settings->display_cols[0] != tft_cols) { - tft_cols = Settings->display_cols[0]; - if (tft_cols > 17) { - tft_top = TFT_TOP; - tft_bottom = TFT_BOTTOM; - } else { - tft_top = 0; - tft_bottom = 0; - } - tft_scroll = tft_top; - renderer->setScrollMargins(tft_top, tft_bottom); - } - return (tft_cols > 17); -} +// bool Ili9341Header(void) { +// if (Settings->display_cols[0] != tft_cols) { +// tft_cols = Settings->display_cols[0]; +// if (tft_cols > 17) { +// tft_top = TFT_TOP; +// tft_bottom = TFT_BOTTOM; +// } else { +// tft_top = 0; +// tft_bottom = 0; +// } +// tft_scroll = tft_top; +// renderer->setScrollMargins(tft_top, tft_bottom); +// } +// return (tft_cols > 17); +// } -void Ili9341InitMode(void) { -// renderer->setRotation(Settings->display_rotate); // 0 -#ifdef USE_DISPLAY_ILI9341 -// renderer->invertDisplay(0); -#endif - renderer->fillScreen(ILI9341_BLACK); - renderer->setTextWrap(false); // Allow text to run off edges - renderer->cp437(true); - if (!Settings->display_mode) { - renderer->setCursor(0, 0); - renderer->setTextColor(ILI9341_WHITE, ILI9341_BLACK); - renderer->setTextSize(1); - } else { - Ili9341Header(); - renderer->setCursor(0, 0); - renderer->setTextColor(ILI9341_YELLOW, ILI9341_BLACK); - renderer->setTextSize(2); -// tft->println("HEADER"); - } -} +// void Ili9341InitMode(void) { +// // renderer->setRotation(Settings->display_rotate); // 0 +// #ifdef USE_DISPLAY_ILI9341 +// // renderer->invertDisplay(0); +// #endif +// renderer->fillScreen(ILI9341_BLACK); +// renderer->setTextWrap(false); // Allow text to run off edges +// renderer->cp437(true); +// if (!Settings->display_mode) { +// renderer->setCursor(0, 0); +// renderer->setTextColor(ILI9341_WHITE, ILI9341_BLACK); +// renderer->setTextSize(1); +// } else { +// Ili9341Header(); +// renderer->setCursor(0, 0); +// renderer->setTextColor(ILI9341_YELLOW, ILI9341_BLACK); +// renderer->setTextSize(2); +// // tft->println("HEADER"); +// } +// } -void Ili9341PrintLog(void) { - disp_refresh--; - if (!disp_refresh) { - disp_refresh = Settings->display_refresh; - if (Settings->display_rotate) { - if (!disp_screen_buffer_cols) { DisplayAllocScreenBuffer(); } - } +// void Ili9341PrintLog(void) { +// disp_refresh--; +// if (!disp_refresh) { +// disp_refresh = Settings->display_refresh; +// if (Settings->display_rotate) { +// if (!disp_screen_buffer_cols) { DisplayAllocScreenBuffer(); } +// } - char* txt = DisplayLogBuffer('\370'); - if (txt != nullptr) { - uint8_t size = Settings->display_size; - uint16_t theight = size * TFT_FONT_HEIGTH; +// char* txt = DisplayLogBuffer('\370'); +// if (txt != nullptr) { +// uint8_t size = Settings->display_size; +// uint16_t theight = size * TFT_FONT_HEIGTH; - renderer->setTextSize(size); - renderer->setTextColor(ILI9341_CYAN, ILI9341_BLACK); // Add background color to solve flicker - if (!Settings->display_rotate) { // Use hardware scroll - renderer->setCursor(0, tft_scroll); - renderer->fillRect(0, tft_scroll, renderer->width(), theight, ILI9341_BLACK); // Erase line - renderer->print(txt); - tft_scroll += theight; - if (tft_scroll >= (renderer->height() - tft_bottom)) { - tft_scroll = tft_top; - } - renderer->scrollTo(tft_scroll); - } else { - uint8_t last_row = Settings->display_rows -1; +// renderer->setTextSize(size); +// renderer->setTextColor(ILI9341_CYAN, ILI9341_BLACK); // Add background color to solve flicker +// if (!Settings->display_rotate) { // Use hardware scroll +// renderer->setCursor(0, tft_scroll); +// renderer->fillRect(0, tft_scroll, renderer->width(), theight, ILI9341_BLACK); // Erase line +// renderer->print(txt); +// tft_scroll += theight; +// if (tft_scroll >= (renderer->height() - tft_bottom)) { +// tft_scroll = tft_top; +// } +// renderer->scrollTo(tft_scroll); +// } else { +// uint8_t last_row = Settings->display_rows -1; - tft_scroll = (tft_top) ? theight : 0; // Start below header - renderer->setCursor(0, tft_scroll); - for (uint32_t i = 0; i < last_row; i++) { - strlcpy(disp_screen_buffer[i], disp_screen_buffer[i +1], disp_screen_buffer_cols); -// tft->fillRect(0, tft_scroll, tft->width(), theight, ILI9341_BLACK); // Erase line - renderer->print(disp_screen_buffer[i]); - tft_scroll += theight; - renderer->setCursor(0, tft_scroll); - delay(1); // Fix background runs heap usage due to long runtime of this loop (up to 1 second) - } - strlcpy(disp_screen_buffer[last_row], txt, disp_screen_buffer_cols); - DisplayFillScreen(last_row); - renderer->print(disp_screen_buffer[last_row]); - } - AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "[%s]"), txt); - } - } -} +// tft_scroll = (tft_top) ? theight : 0; // Start below header +// renderer->setCursor(0, tft_scroll); +// for (uint32_t i = 0; i < last_row; i++) { +// strlcpy(disp_screen_buffer[i], disp_screen_buffer[i +1], disp_screen_buffer_cols); +// // tft->fillRect(0, tft_scroll, tft->width(), theight, ILI9341_BLACK); // Erase line +// renderer->print(disp_screen_buffer[i]); +// tft_scroll += theight; +// renderer->setCursor(0, tft_scroll); +// delay(1); // Fix background runs heap usage due to long runtime of this loop (up to 1 second) +// } +// strlcpy(disp_screen_buffer[last_row], txt, disp_screen_buffer_cols); +// DisplayFillScreen(last_row); +// renderer->print(disp_screen_buffer[last_row]); +// } +// AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "[%s]"), txt); +// } +// } +// } -void ILI9341_Refresh(void) { // Every second - if (Settings->display_mode) { // Mode 0 is User text - // 24-04-2017 13:45:43 = 19 + 1 ('\0') = 20 - // 24-04-2017 13:45 = 16 + 1 ('\0') = 17 +// void ILI9341_Refresh(void) { // Every second +// if (Settings->display_mode) { // Mode 0 is User text +// // 24-04-2017 13:45:43 = 19 + 1 ('\0') = 20 +// // 24-04-2017 13:45 = 16 + 1 ('\0') = 17 - if (Ili9341Header()) { - char tftdt[Settings->display_cols[0] +1]; - char date4[11]; // 24-04-2017 - uint8_t time_size = (Settings->display_cols[0] >= 20) ? 9 : 6; // 13:45:43 or 13:45 - char spaces[Settings->display_cols[0] - (8 + time_size)]; - char time[time_size]; // 13:45:43 +// if (Ili9341Header()) { +// char tftdt[Settings->display_cols[0] +1]; +// char date4[11]; // 24-04-2017 +// uint8_t time_size = (Settings->display_cols[0] >= 20) ? 9 : 6; // 13:45:43 or 13:45 +// char spaces[Settings->display_cols[0] - (8 + time_size)]; +// char time[time_size]; // 13:45:43 - renderer->setTextSize(Settings->display_size); - renderer->setTextColor(ILI9341_YELLOW, ILI9341_RED); // Add background color to solve flicker - renderer->setCursor(0, 0); +// renderer->setTextSize(Settings->display_size); +// renderer->setTextColor(ILI9341_YELLOW, ILI9341_RED); // Add background color to solve flicker +// renderer->setCursor(0, 0); - snprintf_P(date4, sizeof(date4), PSTR("%02d" D_MONTH_DAY_SEPARATOR "%02d" D_YEAR_MONTH_SEPARATOR "%04d"), RtcTime.day_of_month, RtcTime.month, RtcTime.year); - memset(spaces, 0x20, sizeof(spaces)); - spaces[sizeof(spaces) -1] = '\0'; - snprintf_P(time, sizeof(time), PSTR("%02d" D_HOUR_MINUTE_SEPARATOR "%02d" D_MINUTE_SECOND_SEPARATOR "%02d"), RtcTime.hour, RtcTime.minute, RtcTime.second); - snprintf_P(tftdt, sizeof(tftdt), PSTR("%s%s%s"), date4, spaces, time); +// snprintf_P(date4, sizeof(date4), PSTR("%02d" D_MONTH_DAY_SEPARATOR "%02d" D_YEAR_MONTH_SEPARATOR "%04d"), RtcTime.day_of_month, RtcTime.month, RtcTime.year); +// memset(spaces, 0x20, sizeof(spaces)); +// spaces[sizeof(spaces) -1] = '\0'; +// snprintf_P(time, sizeof(time), PSTR("%02d" D_HOUR_MINUTE_SEPARATOR "%02d" D_MINUTE_SECOND_SEPARATOR "%02d"), RtcTime.hour, RtcTime.minute, RtcTime.second); +// snprintf_P(tftdt, sizeof(tftdt), PSTR("%s%s%s"), date4, spaces, time); - renderer->print(tftdt); - } else { - renderer->setCursor(0, 0); - } +// renderer->print(tftdt); +// } else { +// renderer->setCursor(0, 0); +// } - switch (Settings->display_mode) { - case 1: // Text - case 2: // Local - case 3: // Local - case 4: // Mqtt - case 5: // Mqtt - Ili9341PrintLog(); - break; - } - } -} -#endif // USE_DISPLAY_MODES1TO5 +// switch (Settings->display_mode) { +// case 1: // Text +// case 2: // Local +// case 3: // Local +// case 4: // Mqtt +// case 5: // Mqtt +// Ili9341PrintLog(); +// break; +// } +// } +// } +// #endif // USE_DISPLAY_MODES1TO5 -/*********************************************************************************************/ -/*********************************************************************************************\ - * Interface -\*********************************************************************************************/ -bool Xdsp04(uint32_t function) -{ - bool result = false; +// /*********************************************************************************************/ +// /*********************************************************************************************\ +// * Interface +// \*********************************************************************************************/ +// bool Xdsp04(uint32_t function) +// { +// bool result = false; - if (FUNC_DISPLAY_INIT_DRIVER == function) { - ILI9341_InitDriver(); - } - else if (tft_init_done && (XDSP_04 == Settings->display_model)) { - switch (function) { - case FUNC_DISPLAY_MODEL: - result = true; - break; - case FUNC_DISPLAY_TEXT_SIZE: - case FUNC_DISPLAY_FONT_SIZE: - case DISPLAY_INIT_MODE: - renderer->clearDisplay(); - break; -#if defined(USE_FT5206) || defined(USE_XPT2046) -#ifdef USE_TOUCH_BUTTONS - case FUNC_DISPLAY_EVERY_50_MSECOND: -#if defined(USE_FT5206) - if (FT5206_found) { -#elif defined(USE_XPT2046) - if (XPT2046_found) { -#endif +// if (FUNC_DISPLAY_INIT_DRIVER == function) { +// ILI9341_InitDriver(); +// } +// else if (tft_init_done && (XDSP_04 == Settings->display_model)) { +// switch (function) { +// case FUNC_DISPLAY_MODEL: +// result = true; +// break; +// case FUNC_DISPLAY_TEXT_SIZE: +// case FUNC_DISPLAY_FONT_SIZE: +// case DISPLAY_INIT_MODE: +// renderer->clearDisplay(); +// break; +// #if defined(USE_FT5206) || defined(USE_XPT2046) +// #ifdef USE_TOUCH_BUTTONS +// case FUNC_DISPLAY_EVERY_50_MSECOND: +// #if defined(USE_FT5206) +// if (FT5206_found) { +// #elif defined(USE_XPT2046) +// if (XPT2046_found) { +// #endif - ili9342_CheckTouch(); - } - break; -#endif // USE_TOUCH_BUTTONS -#endif // USE_FT5206 -#ifdef USE_DISPLAY_MODES1TO5 - case FUNC_DISPLAY_EVERY_SECOND: - ILI9341_Refresh(); - break; -#endif // USE_DISPLAY_MODES1TO5 +// ili9342_CheckTouch(); +// } +// break; +// #endif // USE_TOUCH_BUTTONS +// #endif // USE_FT5206 +// #ifdef USE_DISPLAY_MODES1TO5 +// case FUNC_DISPLAY_EVERY_SECOND: +// ILI9341_Refresh(); +// break; +// #endif // USE_DISPLAY_MODES1TO5 - } - } - return result; -} +// } +// } +// return result; +// } -#endif // USE_DISPLAY_ILI9341 -#endif // USE_DISPLAY -#endif // USE_SPI +// #endif // USE_DISPLAY_ILI9341 +// #endif // USE_DISPLAY +// #endif // USE_SPI