diff --git a/BUILDS.md b/BUILDS.md index 4a55f1498..483ac04c8 100644 --- a/BUILDS.md +++ b/BUILDS.md @@ -218,7 +218,6 @@ m = minimal, l = lite, t = tasmota, k = knx, s = sensors, i = ir, d = display | USE_DISPLAY_ILI9341 | - | - | - / - | - | - | - | x | | USE_DISPLAY_EPAPER_29 | - | - | - / - | - | - | - | x | | USE_DISPLAY_EPAPER_42 | - | - | - / - | - | - | - | x | -| USE_DISPLAY_ILI9488 | - | - | - / - | - | - | - | x | | USE_DISPLAY_SSD1351 | - | - | - / - | - | - | - | x | | USE_DISPLAY_RA8876 | - | - | - / - | - | - | - | x | | USE_DISPLAY_ST7789 | - | - | - / - | - | - | - | x | diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d3711803..98b1365fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file. ### Changed - ESP8266 Gratuitous ARP enabled and set to 60 seconds (#13623) +- Removed ILI9488 driver in favor of Unversal Display Driver ## [10.0.0.2] 20211113 ### Added diff --git a/lib/lib_display/JaretBurkett_ILI9488-gemu-1.0/ILI9488.cpp b/lib/lib_display/JaretBurkett_ILI9488-gemu-1.0/ILI9488.cpp deleted file mode 100644 index 8b801feb1..000000000 --- a/lib/lib_display/JaretBurkett_ILI9488-gemu-1.0/ILI9488.cpp +++ /dev/null @@ -1,1164 +0,0 @@ -/*************************************************** - STM32 Support added by Jaret Burkett at OSHlab.com - - This is our library for the Adafruit ILI9488 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 - ****************************************************/ -#include -#include "ILI9488.h" -#include - -// if using software spi this optimizes the code - -#ifdef ESP32 -#define ILI9488_DIMMER -#undef ESP32_PWM_CHANNEL -#define ESP32_PWM_CHANNEL 1 -#endif - -#define ILI9488_START start(); -#define ILI9488_STOP stop(); - -const uint16_t ili9488_colors[]={ILI9488_BLACK,ILI9488_WHITE,ILI9488_RED,ILI9488_GREEN,ILI9488_BLUE,ILI9488_CYAN,ILI9488_MAGENTA,\ - ILI9488_YELLOW,ILI9488_NAVY,ILI9488_DARKGREEN,ILI9488_DARKCYAN,ILI9488_MAROON,ILI9488_PURPLE,ILI9488_OLIVE,\ -ILI9488_LIGHTGREY,ILI9488_DARKGREY,ILI9488_ORANGE,ILI9488_GREENYELLOW,ILI9488_PINK}; - -// Constructor when using software SPI. All output pins are configurable. -ILI9488::ILI9488(int8_t cs,int8_t mosi,int8_t sclk,int8_t bp) : Renderer(ILI9488_TFTWIDTH, ILI9488_TFTHEIGHT) { - _cs = cs; - _mosi = mosi; - _sclk = sclk; - _bp = bp; - _hwspi = 0; -} - -/* - -CPU Clock = 80 Mhz -max clock of display is 15 Mhz (66ns sclk cycle) -so cpu/8 => 10 Mhz should be ok - -HSPI CLK 5 GPIO14 -HSPI /CS 8 GPIO15 -HSPI MOSI 7 GPIO13 -HSPI MISO 6 GPIO12 - - -GPIO names for your easy reference: -GPIO0: PERIPHS_IO_MUX_GPIO0_U -GPIO1: PERIPHS_IO_MUX_U0TXD_U -GPIO2: PERIPHS_IO_MUX_GPIO2_U -GPIO3: PERIPHS_IO_MUX_U0RXD_U -GPIO4: PERIPHS_IO_MUX_GPIO4_U -GPIO5: PERIPHS_IO_MUX_GPIO5_U -GPIO6: PERIPHS_IO_MUX_SD_CLK_U -GPIO7: PERIPHS_IO_MUX_SD_DATA0_U -GPIO8: PERIPHS_IO_MUX_SD_DATA1_U -GPIO9: PERIPHS_IO_MUX_SD_DATA2_U -GPIO10: PERIPHS_IO_MUX_SD_DATA3_U -GPIO11: PERIPHS_IO_MUX_SD_CMD_U -GPIO12: PERIPHS_IO_MUX_MTDI_U -GPIO13: PERIPHS_IO_MUX_MTCK_U -GPIO14: PERIPHS_IO_MUX_MTMS_U -GPIO15: PERIPHS_IO_MUX_MTDO_U -*/ - -uint8_t ili9488_start; - -#ifndef ESP32 -// ESP8266 -#include "spi_register.h" -#define SWSPI_OPTMODE -// this enables the 27 bit packed mode -#define RGB_PACK_MODE - -uint32_t ili9488_clock; -uint32_t ili9488_usr; -uint32_t ili9488_usr1; -uint32_t ili9488_usr2; -uint32_t ili9488_spi1c; -uint32_t ili9488_spi1c1; -uint32_t ili9488_spi1p; -uint32_t ili9488_gpmux; -uint32_t ili9488_mtdo; - - -uint32_t ili9488_clock_prev; -uint32_t ili9488_usr_prev; -uint32_t ili9488_usr1_prev; -uint32_t ili9488_usr2_prev; -uint32_t ili9488_spi1c_prev; -uint32_t ili9488_spi1c1_prev; -uint32_t ili9488_spi1p_prev; -uint32_t ili9488_gpmux_prev; -uint32_t ili9488_mtdo_prev; - -// code from espressif SDK -/****************************************************************************** - * FunctionName : spi_lcd_mode_init - * Description : SPI master initial function for driving LCD 3 wire spi -*******************************************************************************/ -void ILI9488::spi_lcd_mode_init(void) { - - ili9488_clock_prev=SPI1CLK; - ili9488_usr_prev=SPI1U; - ili9488_usr1_prev=SPI1U1; - ili9488_usr2_prev=SPI1U2; - ili9488_spi1c_prev=SPI1C; - ili9488_spi1c1_prev=SPI1C1; - ili9488_spi1p_prev=SPI1P; - ili9488_gpmux_prev=GPMUX; - ili9488_mtdo_prev=READ_PERI_REG(PERIPHS_IO_MUX_MTDO_U); - - SPI1U = SPIUMOSI | SPIUDUPLEX | SPIUSSE; - SPI1U1=0; - SPI1C = 0; - SPI1C1 = 0; - - //bit9 of PERIPHS_IO_MUX should be cleared when HSPI clock doesn't equal CPU clock - //bit8 of PERIPHS_IO_MUX should be cleared when SPI clock doesn't equal CPU clock - - WRITE_PERI_REG(PERIPHS_IO_MUX, 0x105); //clear bit9 - //PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U, 2);//configure miso to spi mode - PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, 2);//configure mosi to spi mode - PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTMS_U, 2);//configure sclk to spi mode - PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, 2);//configure cs to spi mode - -// the current implementation leaves about 1 us between transfers ???? -// due to lack of documentation i could not find the reason -// skipping this would double the speed !!! - - //SET_PERI_REG_MASK(SPI_USER(1), SPI_CS_SETUP|SPI_CS_HOLD|SPI_USR_COMMAND); - - SET_PERI_REG_MASK(SPI_USER(1), SPI_USR_COMMAND); - - CLEAR_PERI_REG_MASK(SPI_USER(1), SPI_FLASH_MODE); - // SPI clock=CPU clock/8 => 10 Mhz - /* - WRITE_PERI_REG(SPI_CLOCK(1), - ((1&SPI_CLKDIV_PRE)<>1)&0x7f; - - ILI9488_START - - regvalue= ((8&SPI_USR_COMMAND_BITLEN)<>1)|0x80; - - ILI9488_START - - regvalue= ((8&SPI_USR_COMMAND_BITLEN)<>= 1) { - WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_sclk); - if(d&bit) WRITE_PERI_REG( PIN_OUT_SET, 1<<_mosi); - else WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_mosi); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_sclk); - } - WRITE_PERI_REG( PIN_OUT_SET, 1<<_cs); -} -#else -// ESP32 section -void ILI9488::writedata(uint8_t d) { - ILI9488_START - fastSPIwrite(d,1); -} - -void ILI9488::writecommand(uint8_t c) { - ILI9488_START - fastSPIwrite(c,0); -} - -#include "soc/spi_reg.h" -#include "soc/spi_struct.h" -#include "esp32-hal-spi.h" -#include "esp32-hal.h" -#include "soc/spi_struct.h" - -#define RGB_PACK_MODE - -// since ardunio transferBits ia completely disfunctional -// we use our own hardware driver for 9 bit spi -void ILI9488::fastSPIwrite(uint8_t d,uint8_t dc) { - digitalWrite( _cs, LOW); - - uint32_t regvalue=d>>1; - if (dc) regvalue|=0x80; - else regvalue&=0x7f; - if (d&1) regvalue|=0x8000; - - REG_SET_BIT(SPI_USER_REG(3), SPI_USR_MOSI); - REG_WRITE(SPI_MOSI_DLEN_REG(3), 9 - 1); - uint32_t *dp=(uint32_t*)SPI_W0_REG(3); - *dp=regvalue; - REG_SET_BIT(SPI_CMD_REG(3), SPI_USR); - while (REG_GET_FIELD(SPI_CMD_REG(3), SPI_USR)); - - digitalWrite( _cs, HIGH); -} - -SPISettings ili9488_spiSettings; - -void ILI9488::start(void) { - if (ili9488_start) return; - SPI.beginTransaction(ili9488_spiSettings); - ili9488_start=1; -} -void ILI9488::stop(void) { - if (!ili9488_start) return; - SPI.endTransaction(); - ili9488_start=0; -} -#endif - - -uint16_t ILI9488::GetColorFromIndex(uint8_t index) { - if (index>=sizeof(ili9488_colors)/2) index=0; - return ili9488_colors[index]; -} - -void ILI9488::DisplayInit(int8_t p,int8_t size,int8_t rot,int8_t font) { - setRotation(rot); - invertDisplay(false); - setTextWrap(false); // Allow text to run off edges - cp437(true); - setTextFont(font&3); - setTextSize(size&7); - setTextColor(ILI9488_WHITE,ILI9488_BLACK); - setCursor(0,0); - fillScreen(ILI9488_BLACK); - ILI9488_STOP -} - -void ILI9488::DisplayOnff(int8_t on) { - if (on) { - writecommand(ILI9488_DISPON); //Display on - - if (_bp>=0) { - #ifdef ILI9488_DIMMER - ledcWrite(ESP32_PWM_CHANNEL,dimmer); - #else - digitalWrite(_bp,HIGH); - #endif - /* - writecommand(ILI9488_WRCTRLD); - writedata(0x0c); - writecommand(ILI9488_CAPC9); - writedata(0x3f);*/ - } - } else { - writecommand(ILI9488_DISPOFF); - - if (_bp>=0) { -#ifdef ILI9488_DIMMER - ledcWrite(ESP32_PWM_CHANNEL,0); -#else - digitalWrite(_bp,LOW); -#endif - } - //writecommand(ILI9488_WRCTRLD); - //writedata(0x04); - - } - ILI9488_STOP -} - -// dimmer 0-100 -void ILI9488::dim(uint8_t dim) { - dimmer = dim; - if (dimmer>15) dimmer=15; - dimmer=((float)dimmer/15.0)*255.0; -#ifdef ESP32 - ledcWrite(ESP32_PWM_CHANNEL,dimmer); -#endif -} - -void ILI9488::begin(void) { - pinMode(_cs, OUTPUT); - digitalWrite(_cs,HIGH); - pinMode(_sclk, OUTPUT); - pinMode(_mosi, OUTPUT); - if (_bp>=0) { -#ifdef ILI9488_DIMMER - ledcSetup(ESP32_PWM_CHANNEL,4000,8); - ledcAttachPin(_bp,ESP32_PWM_CHANNEL); - ledcWrite(ESP32_PWM_CHANNEL,128); -#else - pinMode(_bp, OUTPUT); - digitalWrite(_bp,HIGH); -#endif - } - -#ifndef ESP32 - if ((_sclk==14) && (_mosi==13) && (_cs==15)) { - // we use hardware spi - SPI.begin(); - _hwspi=1; - spi_lcd_mode_init(); - } else { - // we must use software spi - _hwspi=0; - } -#else - SPI.begin(_sclk,-1,_mosi, -1); - ili9488_spiSettings = SPISettings(10000000, MSBFIRST, SPI_MODE3); - _hwspi=1; -#endif - - ILI9488_START - delay(1); - - writecommand(0xE0); - writedata(0x00); - writedata(0x03); - writedata(0x09); - writedata(0x08); - writedata(0x16); - writedata(0x0A); - writedata(0x3F); - writedata(0x78); - writedata(0x4C); - writedata(0x09); - writedata(0x0A); - writedata(0x08); - writedata(0x16); - writedata(0x1A); - writedata(0x0F); - - - writecommand(0XE1); - writedata(0x00); - writedata(0x16); - writedata(0x19); - writedata(0x03); - writedata(0x0F); - writedata(0x05); - writedata(0x32); - writedata(0x45); - writedata(0x46); - writedata(0x04); - writedata(0x0E); - writedata(0x0D); - writedata(0x35); - writedata(0x37); - writedata(0x0F); - - writecommand(0XC0); //Power Control 1 - writedata(0x17); //Vreg1out - writedata(0x15); //Verg2out - - writecommand(0xC1); //Power Control 2 - writedata(0x41); //VGH,VGL - - writecommand(0xC5); //Power Control 3 - writedata(0x00); - writedata(0x12); //Vcom - writedata(0x80); - - writecommand(0x36); //Memory Access - writedata(0x48); - - writecommand(0x3A); // Interface Pixel Format - writedata(0x66); //18 bit - - writecommand(0XB0); // Interface Mode Control - writedata(0x80); //SDO NOT USE - - writecommand(0xB1); //Frame rate - writedata(0xA0); //60Hz - - writecommand(0xB4); //Display Inversion Control - writedata(0x02); //2-dot - - writecommand(0XB6); //Display Function Control RGB/MCU Interface Control - writedata(0x02); //MCU - writedata(0x02); //Source,Gate scan dieection - - writecommand(0XE9); // Set Image Functio - writedata(0x00); // Disable 24 bit data - - writecommand(0xF7); // Adjust Control - writedata(0xA9); - writedata(0x51); - writedata(0x2C); - writedata(0x82); // D7 stream, loose - - writecommand(ILI9488_SLPOUT); //Exit Sleep - delay(120); - writecommand(ILI9488_DISPON); //Display on - - ILI9488_STOP -} -/* -void ILI9488::setScrollArea(uint16_t topFixedArea, uint16_t bottomFixedArea){ - writecommand(0x33); // Vertical scroll definition - writedata(topFixedArea >> 8); - writedata(topFixedArea); - writedata((_height - topFixedArea - bottomFixedArea) >> 8); - writedata(_height - topFixedArea - bottomFixedArea); - writedata(bottomFixedArea >> 8); - writedata(bottomFixedArea); - ILI9488_STOP -} -void ILI9488::scroll(uint16_t pixels){ - writecommand(0x37); // Vertical scrolling start address - writedata(pixels >> 8); - writedata(pixels); - ILI9488_STOP -}*/ - -void ILI9488::setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) { - if (!x0 && !y0 && !x1 && !y1) { - x0=0; - y0=0; - x1=_width; - y1=_height; - } - setAddrWindow_int(x0, y0, x1-1, y1-1); -} - -void ILI9488::setAddrWindow_int(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) { -uint8_t flag=0; - - if (!x0 && !y0 && !x1 && !y1) { - x0=0; - y0=0; - x1=_width; - y1=_height; - flag=1; - } - - if (x1>_width) x1=_width; - if (y1>_height) y1=_height; - - writecommand(ILI9488_CASET); // Column addr set - writedata(x0 >> 8); - writedata(x0 & 0xFF); // XSTART - writedata(x1 >> 8); - writedata(x1 & 0xFF); // XEND - - writecommand(ILI9488_PASET); // Row addr set - writedata(y0>>8); - writedata(y0 &0xff); // YSTART - writedata(y1>>8); - writedata(y1 &0xff); // YEND - - writecommand(ILI9488_RAMWR); // write to RAM - if (flag) ILI9488_STOP -} - -/* -void ILI9488::drawImage(const uint8_t* img, uint16_t x, uint16_t y, uint16_t w, uint16_t h){ -return; - // 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; - - setAddrWindow(x, y, x+w-1, y+h-1); - - // uint8_t hi = color >> 8, lo = color; - - #if defined(USE_FAST_PINIO) && !defined (_VARIANT_ARDUINO_STM32_) - *dcport |= dcpinmask; - *csport &= ~cspinmask; - #else - digitalWrite(_dc, HIGH); - digitalWrite(_cs, LOW); - #endif - uint8_t linebuff[w*3+1]; - uint16_t pixels = w*h; - // uint16_t count = 0; - uint32_t count = 0; - for (uint16_t i = 0; i < h; i++) { - uint16_t pixcount = 0; - for (uint16_t o = 0; o < w; o++) { - uint8_t b1 = img[count]; - count++; - uint8_t b2 = img[count]; - count++; - uint16_t color = b1 << 8 | b2; - linebuff[pixcount] = (((color & 0xF800) >> 11)* 255) / 31; - pixcount++; - linebuff[pixcount] = (((color & 0x07E0) >> 5) * 255) / 63; - pixcount++; - linebuff[pixcount] = ((color & 0x001F)* 255) / 31; - pixcount++; - } // for row - #if defined (__STM32F1__) - SPI.dmaSend(linebuff, w*3); - #else - for(uint16_t b = 0; b < w*3; b++){ - spiwrite(linebuff[b]); - } - #endif - - }// for col - #if defined(USE_FAST_PINIO) && !defined (_VARIANT_ARDUINO_STM32_) - *csport |= cspinmask; - #else - digitalWrite(_cs, HIGH); - #endif - - if (hwSPI) spi_end(); -} -*/ - -void ILI9488::pushColor(uint16_t color) { - write16BitColor(color); - ILI9488_STOP -} - -#if 1 -void ILI9488::pushColors(uint16_t *data, uint16_t len, boolean first) { - uint16_t color; - uint8_t buff[len*3+1]; - uint16_t count = 0; - uint8_t lencount = len; - while(lencount--) { - color = *data++; - buff[count] = (((color & 0xF800) >> 11)* 255) / 31; - count++; - buff[count] = (((color & 0x07E0) >> 5) * 255) / 63; - count++; - buff[count] = ((color & 0x001F)* 255) / 31; - count++; - } - - for(uint16_t b = 0; b < len*3; b++){ - writedata(buff[b]); - } - - ILI9488_STOP - -} -#else - -void ILI9488::pushColors(uint16_t *data, uint8_t len, boolean first) { - uint16_t color; - - while (len--) { - write16BitColor(*data++); - } - ILI9488_STOP -} -#endif - -void ILI9488::write16BitColor(uint16_t color){ - // #if (__STM32F1__) - // uint8_t buff[4] = { - // (((color & 0xF800) >> 11)* 255) / 31, - // (((color & 0x07E0) >> 5) * 255) / 63, - // ((color & 0x001F)* 255) / 31 - // }; - // SPI.dmaSend(buff, 3); - // #else - uint8_t r = (color & 0xF800) >> 11; - uint8_t g = (color & 0x07E0) >> 5; - uint8_t b = color & 0x001F; - - r = (r * 255) / 31; - g = (g * 255) / 63; - b = (b * 255) / 31; - - #ifndef SWSPI_OPTMODE - writedata(r); - writedata(g); - writedata(b); - #else - if (_hwspi) { - writedata(r); - writedata(g); - writedata(b); - } else { - WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_cs); - WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_sclk); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_mosi); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_sclk); - - for(uint8_t bit = 0x80; bit; bit >>= 1) { - WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_sclk); - if(r&bit) WRITE_PERI_REG( PIN_OUT_SET, 1<<_mosi); - else WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_mosi); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_sclk); - } - - WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_sclk); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_mosi); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_sclk); - - for(uint8_t bit = 0x80; bit; bit >>= 1) { - WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_sclk); - if(g&bit) WRITE_PERI_REG( PIN_OUT_SET, 1<<_mosi); - else WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_mosi); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_sclk); - } - - WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_sclk); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_mosi); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_sclk); - - for(uint8_t bit = 0x80; bit; bit >>= 1) { - WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_sclk); - if(b&bit) WRITE_PERI_REG( PIN_OUT_SET, 1<<_mosi); - else WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_mosi); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_sclk); - } - WRITE_PERI_REG( PIN_OUT_SET, 1<<_cs); - } - - #endif - ILI9488_STOP -} - -void ILI9488::drawPixel(int16_t x, int16_t y, uint16_t color) { - - if((x < 0) ||(x >= _width) || (y < 0) || (y >= _height)) return; - - setAddrWindow_int(x,y,x+1,y+1); - write16BitColor(color); - ILI9488_STOP -} - -void ILI9488::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; - - setAddrWindow_int(x, y, x, y+h-1); - - uint8_t r = (color & 0xF800) >> 11; - uint8_t g = (color & 0x07E0) >> 5; - uint8_t b = color & 0x001F; - - r = (r * 255) / 31; - g = (g * 255) / 63; - b = (b * 255) / 31; - - while (h--) { - #ifndef SWSPI_OPTMODE - writedata(r); - writedata(g); - writedata(b); - #else - if (_hwspi) { - writedata(r); - writedata(g); - writedata(b); - } else { - WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_cs); - WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_sclk); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_mosi); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_sclk); - - for(uint8_t bit = 0x80; bit; bit >>= 1) { - WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_sclk); - if(r&bit) WRITE_PERI_REG( PIN_OUT_SET, 1<<_mosi); - else WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_mosi); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_sclk); - } - - WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_sclk); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_mosi); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_sclk); - - for(uint8_t bit = 0x80; bit; bit >>= 1) { - WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_sclk); - if(g&bit) WRITE_PERI_REG( PIN_OUT_SET, 1<<_mosi); - else WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_mosi); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_sclk); - } - - WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_sclk); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_mosi); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_sclk); - - for(uint8_t bit = 0x80; bit; bit >>= 1) { - WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_sclk); - if(b&bit) WRITE_PERI_REG( PIN_OUT_SET, 1<<_mosi); - else WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_mosi); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_sclk); - } - WRITE_PERI_REG( PIN_OUT_SET, 1<<_cs); - } - #endif - } - ILI9488_STOP -} - -void ILI9488::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; - - setAddrWindow_int(x, y, x+w-1, y); - - uint8_t r = (color & 0xF800) >> 11; - uint8_t g = (color & 0x07E0) >> 5; - uint8_t b = color & 0x001F; - - r = (r * 255) / 31; - g = (g * 255) / 63; - b = (b * 255) / 31; - - while (w--) { -#ifndef SWSPI_OPTMODE - writedata(r); - writedata(g); - writedata(b); -#else - if (_hwspi) { - writedata(r); - writedata(g); - writedata(b); - } else { - WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_cs); - WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_sclk); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_mosi); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_sclk); - - for(uint8_t bit = 0x80; bit; bit >>= 1) { - WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_sclk); - if(r&bit) WRITE_PERI_REG( PIN_OUT_SET, 1<<_mosi); - else WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_mosi); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_sclk); - } - - WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_sclk); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_mosi); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_sclk); - - for(uint8_t bit = 0x80; bit; bit >>= 1) { - WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_sclk); - if(g&bit) WRITE_PERI_REG( PIN_OUT_SET, 1<<_mosi); - else WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_mosi); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_sclk); - } - - WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_sclk); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_mosi); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_sclk); - - for(uint8_t bit = 0x80; bit; bit >>= 1) { - WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_sclk); - if(b&bit) WRITE_PERI_REG( PIN_OUT_SET, 1<<_mosi); - else WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_mosi); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_sclk); - } - WRITE_PERI_REG( PIN_OUT_SET, 1<<_cs); - } -#endif - } - ILI9488_STOP -} - -// this moves 460 kbytes -// now at 475 ms with 13,3 Mhz clock -void ILI9488::fillScreen(uint16_t color) { - //uint32_t time=millis(); - fillRect(0, 0, _width, _height, color); - //time=millis()-time; - //Serial.printf("time %d ms\n",time); - ILI9488_STOP -} - - -//#define WAIT_9BITS asm_nop_9bits(); -#define WAIT_9BITS -//#define WAIT_BEFORE while(*((uint32_t *)0x60000100)&SPI_USR); //waiting for spi module available -#define WAIT_SPI_READY while(READ_PERI_REG(SPI_CMD(1))&SPI_USR); - -//#define WAIT_SPI_READY - -//#define DIAG_PIN_SET WRITE_PERI_REG( PIN_OUT_SET, 1<<2); -//#define DIAG_PIN_CLR WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<2); -#define DIAG_PIN_SET -#define DIAG_PIN_CLR - -//#define WRITE_PERI_REG(addr, val) (*((volatile uint32_t *)ETS_UNCACHED_ADDR(addr))) = (uint32_t)(val) - - -// CMD 0x60000200-1*0x100 -// SPI_USER2 0x60000200-1*0x100 + 0x24 - -//#define WRITE_SPI_REG WRITE_PERI_REG(0x60000124, regvalue_r);SET_PERI_REG_MASK(0x60000100, SPI_USR); -// THIS TAKES 1 us => 80 cpu clock cycles !!!!!!!!!!!!!!!!!!!!!!!!!! -// probably the memw causes this delay -#define WRITE_SPI_REG(A) WRITE_PERI_REG(SPI_USER2(1), A); SET_PERI_REG_MASK(SPI_CMD(1), SPI_USR); - -//#define WRITE_SPI_REG(A) *((uint32_t *)0x60000124)=A; *((uint32_t *)0x60000100)|=SPI_USR; - -//#define WRITE_SPI_REG - - - -// extremely strange => if this code is merged into pack_rgb() the software crashes -// swap bytes -uint32_t ulswap(uint32_t data) { -union { - uint32_t l; - uint8_t b[4]; -} data_; - - data_.l = data; - // MSBFIRST Byte first - data = (data_.b[3] | (data_.b[2] << 8) | (data_.b[1] << 16) | (data_.b[0] << 24)); - return data; -} - -// pack RGB into uint32 -uint32_t pack_rgb(uint32_t r, uint32_t g, uint32_t b) { - uint32_t data; - data=r<<23; - data|=g<<14; - data|=b<<5; - data|=0b10000000010000000010000000000000; - return ulswap(data); -} - -#ifndef ESP32 -// fill a rectangle -void ILI9488::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) { - - ILI9488_START - // 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; - - setAddrWindow_int(x, y, x+w-1, y+h-1); - //ILI9488_START - - uint8_t r = (color & 0xF800) >> 11; - uint8_t g = (color & 0x07E0) >> 5; - uint8_t b = color & 0x001F; - - r = (r * 255) / 31; - g = (g * 255) / 63; - b = (b * 255) / 31; - - uint32_t regvalue_r,regvalue_g,regvalue_b; - uint32_t data; - - if (_hwspi) { - // precalculate the register values for rgb - -#ifndef RGB_PACK_MODE - uint8_t bytetemp; - bytetemp=(r>>1)|0x80; - regvalue_r= ((8&SPI_USR_COMMAND_BITLEN)<>1)|0x80; - regvalue_g= ((8&SPI_USR_COMMAND_BITLEN)<>1)|0x80; - regvalue_b= ((8&SPI_USR_COMMAND_BITLEN)< MSBFIRST - SPI1U = SPIUMOSI; - SPI1C1 = 0; - data=pack_rgb(r,g,b); - -#endif - } - - for(y=h; y>0; y--) { - delay(0); - for(x=w; x>0; x--) { - -#ifndef SWSPI_OPTMODE - writedata(r); - writedata(g); - writedata(b); -#else - if (_hwspi) { - //noInterrupts(); -#ifdef RGB_PACK_MODE - while(SPI1CMD & SPIBUSY) {} - SPI1W0 = data; - SPI1CMD |= SPIBUSY; -#else - DIAG_PIN_CLR - WAIT_SPI_READY - DIAG_PIN_SET - - WRITE_SPI_REG(regvalue_r) - WAIT_9BITS - - DIAG_PIN_CLR - WAIT_SPI_READY - DIAG_PIN_SET - - WRITE_SPI_REG(regvalue_g) - WAIT_9BITS - - DIAG_PIN_CLR - WAIT_SPI_READY - DIAG_PIN_SET - - WRITE_SPI_REG(regvalue_b) - WAIT_9BITS - - //interrupts(); -#endif - } else { - WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_cs); - - WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_sclk); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_mosi); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_sclk); - - for(uint8_t bit = 0x80; bit; bit >>= 1) { - WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_sclk); - if(r&bit) WRITE_PERI_REG( PIN_OUT_SET, 1<<_mosi); - else WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_mosi); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_sclk); - } - - WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_sclk); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_mosi); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_sclk); - - for(uint8_t bit = 0x80; bit; bit >>= 1) { - WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_sclk); - if(g&bit) WRITE_PERI_REG( PIN_OUT_SET, 1<<_mosi); - else WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_mosi); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_sclk); - } - - WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_sclk); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_mosi); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_sclk); - - for(uint8_t bit = 0x80; bit; bit >>= 1) { - WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_sclk); - if(b&bit) WRITE_PERI_REG( PIN_OUT_SET, 1<<_mosi); - else WRITE_PERI_REG( PIN_OUT_CLEAR, 1<<_mosi); - WRITE_PERI_REG( PIN_OUT_SET, 1<<_sclk); - } - WRITE_PERI_REG( PIN_OUT_SET, 1<<_cs); - } - #endif - - } - - } -#ifdef RGB_PACK_MODE - // reinit old mode - while(SPI1CMD & SPIBUSY) {} - ILI9488_STOP - //spi_lcd_mode_init(); -#endif - -} -#else -// ESP32 -void ILI9488::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; - - setAddrWindow_int(x, y, x+w-1, y+h-1); - - uint8_t r = (color & 0xF800) >> 11; - uint8_t g = (color & 0x07E0) >> 5; - uint8_t b = color & 0x001F; - - r = (r * 255) / 31; - g = (g * 255) / 63; - b = (b * 255) / 31; - -#ifdef RGB_PACK_MODE - // init 27 bit mode - uint32_t data=pack_rgb(r,g,b); - REG_SET_BIT(SPI_USER_REG(3), SPI_USR_MOSI); - REG_WRITE(SPI_MOSI_DLEN_REG(3), 27 - 1); - uint32_t *dp=(uint32_t*)SPI_W0_REG(3); - digitalWrite( _cs, LOW); -#endif - - for(y=h; y>0; y--) { - for(x=w; x>0; x--) { - #ifndef RGB_PACK_MODE - writedata(r); - writedata(g); - writedata(b); - #else - while (REG_GET_FIELD(SPI_CMD_REG(3), SPI_USR)); - *dp=data; - REG_SET_BIT(SPI_CMD_REG(3), SPI_USR); - #endif - } - } - -#ifdef RGB_PACK_MODE - while (REG_GET_FIELD(SPI_CMD_REG(3), SPI_USR)); - digitalWrite( _cs, HIGH); -#endif - - ILI9488_STOP -} -#endif - - -// Pass 8-bit (each) R,G,B, get back 16-bit packed color -uint16_t ILI9488::color565(uint8_t r, uint8_t g, uint8_t b) { - return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3); -} - - -#define MADCTL_MY 0x80 -#define MADCTL_MX 0x40 -#define MADCTL_MV 0x20 -#define MADCTL_ML 0x10 -#define MADCTL_RGB 0x00 -#define MADCTL_BGR 0x08 -#define MADCTL_MH 0x04 - -void ILI9488::setRotation(uint8_t m) { - - writecommand(ILI9488_MADCTL); - rotation = m % 4; // can't be higher than 3 - switch (rotation) { - case 0: - writedata(MADCTL_MX | MADCTL_BGR); - _width = ILI9488_TFTWIDTH; - _height = ILI9488_TFTHEIGHT; - break; - case 1: - writedata(MADCTL_MV | MADCTL_BGR); - _width = ILI9488_TFTHEIGHT; - _height = ILI9488_TFTWIDTH; - break; - case 2: - writedata(MADCTL_MY | MADCTL_BGR); - _width = ILI9488_TFTWIDTH; - _height = ILI9488_TFTHEIGHT; - break; - case 3: - writedata(MADCTL_MX | MADCTL_MY | MADCTL_MV | MADCTL_BGR); - _width = ILI9488_TFTHEIGHT; - _height = ILI9488_TFTWIDTH; - break; - } - ILI9488_STOP -} - - -void ILI9488::invertDisplay(boolean i) { - writecommand(i ? ILI9488_INVON : ILI9488_INVOFF); - ILI9488_STOP -} diff --git a/lib/lib_display/JaretBurkett_ILI9488-gemu-1.0/ILI9488.h b/lib/lib_display/JaretBurkett_ILI9488-gemu-1.0/ILI9488.h deleted file mode 100644 index bed25c5f8..000000000 --- a/lib/lib_display/JaretBurkett_ILI9488-gemu-1.0/ILI9488.h +++ /dev/null @@ -1,174 +0,0 @@ -/*************************************************** - STM32 Support added by Jaret Burkett at OSHlab.com - - This is our library for the Adafruit ILI9488 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 _ILI9488H_ -#define _ILI9488H_ - -#if ARDUINO >= 100 - #include "Arduino.h" - #include "Print.h" -#else - #include "WProgram.h" -#endif -#include -#ifdef __AVR - #include -#elif defined(ESP8266) - #include -#endif - -#ifdef ARDUINO_STM32_FEATHER -typedef volatile uint32 RwReg; -#endif -#if defined (__AVR__) || defined(TEENSYDUINO) || defined (__arm__) || defined (__STM32F1__) -#define USE_FAST_PINIO -#endif - -#define ILI9488_TFTWIDTH 320 -#define ILI9488_TFTHEIGHT 480 - -#define ILI9488_NOP 0x00 -#define ILI9488_SWRESET 0x01 -#define ILI9488_RDDID 0x04 -#define ILI9488_RDDST 0x09 - -#define ILI9488_SLPIN 0x10 -#define ILI9488_SLPOUT 0x11 -#define ILI9488_PTLON 0x12 -#define ILI9488_NORON 0x13 - -#define ILI9488_RDMODE 0x0A -#define ILI9488_RDMADCTL 0x0B -#define ILI9488_RDPIXFMT 0x0C -#define ILI9488_RDIMGFMT 0x0D -#define ILI9488_RDSELFDIAG 0x0F - -#define ILI9488_INVOFF 0x20 -#define ILI9488_INVON 0x21 -#define ILI9488_GAMMASET 0x26 -#define ILI9488_DISPOFF 0x28 -#define ILI9488_DISPON 0x29 - -#define ILI9488_CASET 0x2A -#define ILI9488_PASET 0x2B -#define ILI9488_RAMWR 0x2C -#define ILI9488_RAMRD 0x2E - -#define ILI9488_PTLAR 0x30 -#define ILI9488_MADCTL 0x36 -#define ILI9488_PIXFMT 0x3A - -#define ILI9488_WRCTRLD 0x53 -#define ILI9488_CAPC9 0xCF - -#define ILI9488_FRMCTR1 0xB1 -#define ILI9488_FRMCTR2 0xB2 -#define ILI9488_FRMCTR3 0xB3 -#define ILI9488_INVCTR 0xB4 -#define ILI9488_DFUNCTR 0xB6 - -#define ILI9488_PWCTR1 0xC0 -#define ILI9488_PWCTR2 0xC1 -#define ILI9488_PWCTR3 0xC2 -#define ILI9488_PWCTR4 0xC3 -#define ILI9488_PWCTR5 0xC4 -#define ILI9488_VMCTR1 0xC5 -#define ILI9488_VMCTR2 0xC7 - -#define ILI9488_RDID1 0xDA -#define ILI9488_RDID2 0xDB -#define ILI9488_RDID3 0xDC -#define ILI9488_RDID4 0xDD - -#define ILI9488_GMCTRP1 0xE0 -#define ILI9488_GMCTRN1 0xE1 -/* -#define ILI9488_PWCTR6 0xFC - -*/ - -#define PIN_OUT_SET 0x60000304 -#define PIN_OUT_CLEAR 0x60000308 - -// Color definitions -#define ILI9488_BLACK 0x0000 /* 0, 0, 0 */ -#define ILI9488_NAVY 0x000F /* 0, 0, 128 */ -#define ILI9488_DARKGREEN 0x03E0 /* 0, 128, 0 */ -#define ILI9488_DARKCYAN 0x03EF /* 0, 128, 128 */ -#define ILI9488_MAROON 0x7800 /* 128, 0, 0 */ -#define ILI9488_PURPLE 0x780F /* 128, 0, 128 */ -#define ILI9488_OLIVE 0x7BE0 /* 128, 128, 0 */ -#define ILI9488_LIGHTGREY 0xC618 /* 192, 192, 192 */ -#define ILI9488_DARKGREY 0x7BEF /* 128, 128, 128 */ -#define ILI9488_BLUE 0x001F /* 0, 0, 255 */ -#define ILI9488_GREEN 0x07E0 /* 0, 255, 0 */ -#define ILI9488_CYAN 0x07FF /* 0, 255, 255 */ -#define ILI9488_RED 0xF800 /* 255, 0, 0 */ -#define ILI9488_MAGENTA 0xF81F /* 255, 0, 255 */ -#define ILI9488_YELLOW 0xFFE0 /* 255, 255, 0 */ -#define ILI9488_WHITE 0xFFFF /* 255, 255, 255 */ -#define ILI9488_ORANGE 0xFD20 /* 255, 165, 0 */ -#define ILI9488_GREENYELLOW 0xAFE5 /* 173, 255, 47 */ -#define ILI9488_PINK 0xF81F - - - - -class ILI9488 : public Renderer { - - public: - - ILI9488(int8_t cs,int8_t mosi,int8_t sclk,int8_t bp); - - void begin(void); - void DisplayInit(int8_t p,int8_t size,int8_t rot,int8_t font); - void setAddrWindow_int(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1); - void setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1); - void setScrollArea(uint16_t topFixedArea, uint16_t bottomFixedArea); - void scroll(uint16_t pixels); - void pushColor(uint16_t color); - void pushColors(uint16_t *data, uint16_t len, boolean first); - //void drawImage(const uint8_t* img, uint16_t x, uint16_t y, uint16_t w, uint16_t h); - void fillScreen(uint16_t color); - void drawPixel(int16_t x, int16_t y, uint16_t color); - 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 fillRect(int16_t x, int16_t y, int16_t w, int16_t h,uint16_t color); - void setRotation(uint8_t r); - void invertDisplay(boolean i); - uint16_t color565(uint8_t r, uint8_t g, uint8_t b); - uint16_t GetColorFromIndex(uint8_t index); - void DisplayOnff(int8_t on); - void writecommand(uint8_t c); - void writedata(uint8_t d); - void write16BitColor(uint16_t color); - void commandList(uint8_t *addr); - void hw_spi_init(); - void dim(uint8_t contrast); - - private: - uint8_t tabcolor; - uint8_t dimmer; - void fastSPIwrite(uint8_t d,uint8_t dc); - void spi_lcd_mode_init(void); - void start(void); - void stop(void); - int8_t _cs, _mosi, _sclk, _bp, _hwspi; - -}; - -#endif diff --git a/lib/lib_display/JaretBurkett_ILI9488-gemu-1.0/README.md b/lib/lib_display/JaretBurkett_ILI9488-gemu-1.0/README.md deleted file mode 100644 index fd203455b..000000000 --- a/lib/lib_display/JaretBurkett_ILI9488-gemu-1.0/README.md +++ /dev/null @@ -1,8 +0,0 @@ -### ILI9488 Arduino Library -This library is for support for the 320x480 tft controller over 4 wire SPI. It is based heavily on the [Adafruit_ILI9341](https://github.com/adafruit/Adafruit_ILI9341) library and is designed to work with the [Adafruit_GFX library](https://github.com/adafruit/Adafruit-GFX-Library). - -I have made some heavy modifications, as the typical Adafruit TFT libraries are designed to work with 16bit color (RGB565), and the ILI9488 can only do 24bit (RGB888) color in 4 wire SPI mode. You can still use the library EXACTLY like you would for 16bit mode color, the colors are converted before sending to the display. What this means is, things will be slower than normal. Not only do you have to write twice as many pixels as a normal 240x320 display, 153,600px (320x480) vs 76,800px (240x320), but you also have to do a lightweight conversion on each color, and write 3 bytes vs 2bytes per pixel. - -For this reason, I do not recommend an AVR based Arduino for this library, although it will still work. I highly recommend a faster microcontroller based on ARM such as the Teensy, [STM32duino](https://github.com/rogerclarkmelbourne/Arduino_STM32), Arduino Zero, or the Arduing Due. - -On the STM32duino, DMA is supported and is therefore much faster. \ No newline at end of file diff --git a/lib/lib_display/JaretBurkett_ILI9488-gemu-1.0/examples/graphicstest/graphicstest.ino b/lib/lib_display/JaretBurkett_ILI9488-gemu-1.0/examples/graphicstest/graphicstest.ino deleted file mode 100644 index 30b0cbd9a..000000000 --- a/lib/lib_display/JaretBurkett_ILI9488-gemu-1.0/examples/graphicstest/graphicstest.ino +++ /dev/null @@ -1,350 +0,0 @@ -/*************************************************** - This is our GFX example for the Adafruit ILI9488 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 - ****************************************************/ - - -#include "SPI.h" -#include -#include - -#define TFT_CS PA1 -#define TFT_DC PB3 -#define TFT_LED PB0 -#define TFT_RST PB4 - -// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC -ILI9488 tft = ILI9488(TFT_CS, TFT_DC, TFT_RST); -// If using the breakout, change pins as desired -//Adafruit_ILI9488 tft = Adafruit_ILI9488(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO); - -void setup() { - Serial.begin(9600); - Serial.println("ILI9488 Test!"); - - tft.begin(); - - // read diagnostics (optional but can help debug problems) - uint8_t x = tft.readcommand8(ILI9488_RDMODE); - Serial.print("Display Power Mode: 0x"); Serial.println(x, HEX); - x = tft.readcommand8(ILI9488_RDMADCTL); - Serial.print("MADCTL Mode: 0x"); Serial.println(x, HEX); - x = tft.readcommand8(ILI9488_RDPIXFMT); - Serial.print("Pixel Format: 0x"); Serial.println(x, HEX); - x = tft.readcommand8(ILI9488_RDIMGFMT); - Serial.print("Image Format: 0x"); Serial.println(x, HEX); - x = tft.readcommand8(ILI9488_RDSELFDIAG); - Serial.print("Self Diagnostic: 0x"); Serial.println(x, HEX); - - Serial.println(F("Benchmark Time (microseconds)")); - - Serial.print(F("Screen fill ")); - Serial.println(testFillScreen()); - delay(500); - - Serial.print(F("Text ")); - Serial.println(testText()); - delay(3000); - - Serial.print(F("Lines ")); - Serial.println(testLines(ILI9488_CYAN)); - delay(500); - - Serial.print(F("Horiz/Vert Lines ")); - Serial.println(testFastLines(ILI9488_RED, ILI9488_BLUE)); - delay(500); - - Serial.print(F("Rectangles (outline) ")); - Serial.println(testRects(ILI9488_GREEN)); - delay(500); - - Serial.print(F("Rectangles (filled) ")); - Serial.println(testFilledRects(ILI9488_YELLOW, ILI9488_MAGENTA)); - delay(500); - - Serial.print(F("Circles (filled) ")); - Serial.println(testFilledCircles(10, ILI9488_MAGENTA)); - - Serial.print(F("Circles (outline) ")); - Serial.println(testCircles(10, ILI9488_WHITE)); - delay(500); - - Serial.print(F("Triangles (outline) ")); - Serial.println(testTriangles()); - delay(500); - - Serial.print(F("Triangles (filled) ")); - Serial.println(testFilledTriangles()); - delay(500); - - Serial.print(F("Rounded rects (outline) ")); - Serial.println(testRoundRects()); - delay(500); - - Serial.print(F("Rounded rects (filled) ")); - Serial.println(testFilledRoundRects()); - delay(500); - - Serial.println(F("Done!")); - -} - - -void loop(void) { - for(uint8_t rotation=0; rotation<4; rotation++) { - tft.setRotation(rotation); - testText(); - delay(1000); - } -} - -unsigned long testFillScreen() { - unsigned long start = micros(); - tft.fillScreen(ILI9488_BLACK); - tft.fillScreen(ILI9488_RED); - tft.fillScreen(ILI9488_GREEN); - tft.fillScreen(ILI9488_BLUE); - tft.fillScreen(ILI9488_BLACK); - return micros() - start; -} - -unsigned long testText() { - tft.fillScreen(ILI9488_BLACK); - unsigned long start = micros(); - tft.setCursor(0, 0); - tft.setTextColor(ILI9488_WHITE); tft.setTextSize(1); - tft.println("Hello World!"); - tft.setTextColor(ILI9488_YELLOW); tft.setTextSize(2); - tft.println(1234.56); - tft.setTextColor(ILI9488_RED); tft.setTextSize(3); - tft.println(0xDEADBEEF, HEX); - tft.println(); - tft.setTextColor(ILI9488_GREEN); - tft.setTextSize(5); - tft.println("Groop"); - tft.setTextSize(2); - tft.println("I implore thee,"); - tft.setTextSize(1); - tft.println("my foonting turlingdromes."); - tft.println("And hooptiously drangle me"); - tft.println("with crinkly bindlewurdles,"); - tft.println("Or I will rend thee"); - tft.println("in the gobberwarts"); - tft.println("with my blurglecruncheon,"); - tft.println("see if I don't!"); - return micros() - start; -} - -unsigned long testLines(uint16_t color) { - unsigned long start, t; - int x1, y1, x2, y2, - w = tft.width(), - h = tft.height(); - - tft.fillScreen(ILI9488_BLACK); - - x1 = y1 = 0; - y2 = h - 1; - start = micros(); - for(x2=0; x20; i-=6) { - i2 = i / 2; - start = micros(); - tft.fillRect(cx-i2, cy-i2, i, i, color1); - t += micros() - start; - // Outlines are not included in timing results - tft.drawRect(cx-i2, cy-i2, i, i, color2); - } - - return t; -} - -unsigned long testFilledCircles(uint8_t radius, uint16_t color) { - unsigned long start; - int x, y, w = tft.width(), h = tft.height(), r2 = radius * 2; - - tft.fillScreen(ILI9488_BLACK); - start = micros(); - for(x=radius; x10; i-=5) { - start = micros(); - tft.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i, - tft.color565(0, i, i)); - t += micros() - start; - tft.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i, - tft.color565(i, i, 0)); - } - - return t; -} - -unsigned long testRoundRects() { - unsigned long start; - int w, i, i2, - cx = tft.width() / 2 - 1, - cy = tft.height() / 2 - 1; - - tft.fillScreen(ILI9488_BLACK); - w = min(tft.width(), tft.height()); - start = micros(); - for(i=0; i20; i-=6) { - i2 = i / 2; - tft.fillRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(0, i, 0)); - } - - return micros() - start; -} diff --git a/lib/lib_display/JaretBurkett_ILI9488-gemu-1.0/keywords.txt b/lib/lib_display/JaretBurkett_ILI9488-gemu-1.0/keywords.txt deleted file mode 100644 index 44c83b06f..000000000 --- a/lib/lib_display/JaretBurkett_ILI9488-gemu-1.0/keywords.txt +++ /dev/null @@ -1,30 +0,0 @@ -####################################### -# Syntax Coloring Map -####################################### - -####################################### -# Datatypes (KEYWORD1) -####################################### - -ILI9488 KEYWORD1 - - -####################################### -# Methods and Functions (KEYWORD2) -####################################### - -setRotation KEYWORD2 -setAddrWindow KEYWORD2 -pushColor KEYWORD2 -drawPixel KEYWORD2 -drawFastVLine KEYWORD2 -drawFastHLine KEYWORD2 -fillRect KEYWORD2 -setRotation KEYWORD2 -setRotation KEYWORD2 -height KEYWORD2 -width KEYWORD2 -invertDisplay KEYWORD2 -drawImage KEYWORD2 -setScrollArea KEYWORD2 -scroll KEYWORD2 diff --git a/lib/lib_display/JaretBurkett_ILI9488-gemu-1.0/library.properties b/lib/lib_display/JaretBurkett_ILI9488-gemu-1.0/library.properties deleted file mode 100644 index a8ae043a7..000000000 --- a/lib/lib_display/JaretBurkett_ILI9488-gemu-1.0/library.properties +++ /dev/null @@ -1,9 +0,0 @@ -name=ILI9488 -version=1.0.2 -author=Jaret Burkett -maintainer=Jaret Burkett -sentence=Library for ILI9488 displays -paragraph=Library for ILI9488 displays -category=Display -url=https://github.com/jaretburkett/ILI9488 -architectures=* diff --git a/lib/lib_display/JaretBurkett_ILI9488-gemu-1.0/spi_register.h b/lib/lib_display/JaretBurkett_ILI9488-gemu-1.0/spi_register.h deleted file mode 100644 index 340559ae1..000000000 --- a/lib/lib_display/JaretBurkett_ILI9488-gemu-1.0/spi_register.h +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright (c) 2010 - 2011 Espressif System - * - */ - -#ifndef SPI_REGISTER_H_INCLUDED -#define SPI_REGISTER_H_INCLUDED - -#define REG_SPI_BASE(i) (0x60000200-i*0x100) -#define SPI_CMD(i) (REG_SPI_BASE(i) + 0x0) -#define SPI_USR (BIT(18)) - -#define SPI_ADDR(i) (REG_SPI_BASE(i) + 0x4) - -#define SPI_CTRL(i) (REG_SPI_BASE(i) + 0x8) -#define SPI_WR_BIT_ORDER (BIT(26)) -#define SPI_RD_BIT_ORDER (BIT(25)) -#define SPI_QIO_MODE (BIT(24)) -#define SPI_DIO_MODE (BIT(23)) -#define SPI_QOUT_MODE (BIT(20)) -#define SPI_DOUT_MODE (BIT(14)) -#define SPI_FASTRD_MODE (BIT(13)) - - - -#define SPI_RD_STATUS(i) (REG_SPI_BASE(i) + 0x10) - -#define SPI_CTRL2(i) (REG_SPI_BASE(i) + 0x14) - -#define SPI_CS_DELAY_NUM 0x0000000F -#define SPI_CS_DELAY_NUM_S 28 -#define SPI_CS_DELAY_MODE 0x00000003 -#define SPI_CS_DELAY_MODE_S 26 -#define SPI_MOSI_DELAY_NUM 0x00000007 -#define SPI_MOSI_DELAY_NUM_S 23 -#define SPI_MOSI_DELAY_MODE 0x00000003 -#define SPI_MOSI_DELAY_MODE_S 21 -#define SPI_MISO_DELAY_NUM 0x00000007 -#define SPI_MISO_DELAY_NUM_S 18 -#define SPI_MISO_DELAY_MODE 0x00000003 -#define SPI_MISO_DELAY_MODE_S 16 -#define SPI_CK_OUT_HIGH_MODE 0x0000000F -#define SPI_CK_OUT_HIGH_MODE_S 12 -#define SPI_CK_OUT_LOW_MODE 0x0000000F -#define SPI_CK_OUT_LOW_MODE_S 8 - -#define SPI_CLOCK(i) (REG_SPI_BASE(i) + 0x18) -#define SPI_CLK_EQU_SYSCLK (BIT(31)) -#define SPI_CLKDIV_PRE 0x00001FFF -#define SPI_CLKDIV_PRE_S 18 -#define SPI_CLKCNT_N 0x0000003F -#define SPI_CLKCNT_N_S 12 -#define SPI_CLKCNT_H 0x0000003F -#define SPI_CLKCNT_H_S 6 -#define SPI_CLKCNT_L 0x0000003F -#define SPI_CLKCNT_L_S 0 - -#define SPI_USER(i) (REG_SPI_BASE(i) + 0x1C) -#define SPI_USR_COMMAND (BIT(31)) -#define SPI_USR_ADDR (BIT(30)) -#define SPI_USR_DUMMY (BIT(29)) -#define SPI_USR_MISO (BIT(28)) -#define SPI_USR_MOSI (BIT(27)) - -#define SPI_USR_MOSI_HIGHPART (BIT(25)) -#define SPI_USR_MISO_HIGHPART (BIT(24)) - - -#define SPI_SIO (BIT(16)) -#define SPI_FWRITE_QIO (BIT(15)) -#define SPI_FWRITE_DIO (BIT(14)) -#define SPI_FWRITE_QUAD (BIT(13)) -#define SPI_FWRITE_DUAL (BIT(12)) -#define SPI_WR_BYTE_ORDER (BIT(11)) -#define SPI_RD_BYTE_ORDER (BIT(10)) -#define SPI_CK_OUT_EDGE (BIT(7)) -#define SPI_CK_I_EDGE (BIT(6)) -#define SPI_CS_SETUP (BIT(5)) -#define SPI_CS_HOLD (BIT(4)) -#define SPI_FLASH_MODE (BIT(2)) -#define SPI_DOUTDIN (BIT(0)) - -#define SPI_USER1(i) (REG_SPI_BASE(i) + 0x20) -#define SPI_USR_ADDR_BITLEN 0x0000003F -#define SPI_USR_ADDR_BITLEN_S 26 -#define SPI_USR_MOSI_BITLEN 0x000001FF -#define SPI_USR_MOSI_BITLEN_S 17 -#define SPI_USR_MISO_BITLEN 0x000001FF -#define SPI_USR_MISO_BITLEN_S 8 - -#define SPI_USR_DUMMY_CYCLELEN 0x000000FF -#define SPI_USR_DUMMY_CYCLELEN_S 0 - -#define SPI_USER2(i) (REG_SPI_BASE(i) + 0x24) -#define SPI_USR_COMMAND_BITLEN 0x0000000F -#define SPI_USR_COMMAND_BITLEN_S 28 -#define SPI_USR_COMMAND_VALUE 0x0000FFFF -#define SPI_USR_COMMAND_VALUE_S 0 - -#define SPI_WR_STATUS(i) (REG_SPI_BASE(i) + 0x28) -#define SPI_PIN(i) (REG_SPI_BASE(i) + 0x2C) -#define SPI_CS2_DIS (BIT(2)) -#define SPI_CS1_DIS (BIT(1)) -#define SPI_CS0_DIS (BIT(0)) -#define SPI_IDLE_EDGE (BIT(29)) - -#define SPI_SLAVE(i) (REG_SPI_BASE(i) + 0x30) -#define SPI_SYNC_RESET (BIT(31)) -#define SPI_SLAVE_MODE (BIT(30)) -#define SPI_SLV_WR_RD_BUF_EN (BIT(29)) -#define SPI_SLV_WR_RD_STA_EN (BIT(28)) -#define SPI_SLV_CMD_DEFINE (BIT(27)) -#define SPI_TRANS_CNT 0x0000000F -#define SPI_TRANS_CNT_S 23 -#define SPI_TRANS_DONE_EN (BIT(9)) -#define SPI_SLV_WR_STA_DONE_EN (BIT(8)) -#define SPI_SLV_RD_STA_DONE_EN (BIT(7)) -#define SPI_SLV_WR_BUF_DONE_EN (BIT(6)) -#define SPI_SLV_RD_BUF_DONE_EN (BIT(5)) - - - -#define SLV_SPI_INT_EN 0x0000001f -#define SLV_SPI_INT_EN_S 5 - -#define SPI_TRANS_DONE (BIT(4)) -#define SPI_SLV_WR_STA_DONE (BIT(3)) -#define SPI_SLV_RD_STA_DONE (BIT(2)) -#define SPI_SLV_WR_BUF_DONE (BIT(1)) -#define SPI_SLV_RD_BUF_DONE (BIT(0)) - -#define SPI_SLAVE1(i) (REG_SPI_BASE(i) + 0x34) -#define SPI_SLV_STATUS_BITLEN 0x0000001F -#define SPI_SLV_STATUS_BITLEN_S 27 -#define SPI_SLV_BUF_BITLEN 0x000001FF -#define SPI_SLV_BUF_BITLEN_S 16 -#define SPI_SLV_RD_ADDR_BITLEN 0x0000003F -#define SPI_SLV_RD_ADDR_BITLEN_S 10 -#define SPI_SLV_WR_ADDR_BITLEN 0x0000003F -#define SPI_SLV_WR_ADDR_BITLEN_S 4 - -#define SPI_SLV_WRSTA_DUMMY_EN (BIT(3)) -#define SPI_SLV_RDSTA_DUMMY_EN (BIT(2)) -#define SPI_SLV_WRBUF_DUMMY_EN (BIT(1)) -#define SPI_SLV_RDBUF_DUMMY_EN (BIT(0)) - - - -#define SPI_SLAVE2(i) (REG_SPI_BASE(i) + 0x38) -#define SPI_SLV_WRBUF_DUMMY_CYCLELEN 0X000000FF -#define SPI_SLV_WRBUF_DUMMY_CYCLELEN_S 24 -#define SPI_SLV_RDBUF_DUMMY_CYCLELEN 0X000000FF -#define SPI_SLV_RDBUF_DUMMY_CYCLELEN_S 16 -#define SPI_SLV_WRSTR_DUMMY_CYCLELEN 0X000000FF -#define SPI_SLV_WRSTR_DUMMY_CYCLELEN_S 8 -#define SPI_SLV_RDSTR_DUMMY_CYCLELEN 0x000000FF -#define SPI_SLV_RDSTR_DUMMY_CYCLELEN_S 0 - -#define SPI_SLAVE3(i) (REG_SPI_BASE(i) + 0x3C) -#define SPI_SLV_WRSTA_CMD_VALUE 0x000000FF -#define SPI_SLV_WRSTA_CMD_VALUE_S 24 -#define SPI_SLV_RDSTA_CMD_VALUE 0x000000FF -#define SPI_SLV_RDSTA_CMD_VALUE_S 16 -#define SPI_SLV_WRBUF_CMD_VALUE 0x000000FF -#define SPI_SLV_WRBUF_CMD_VALUE_S 8 -#define SPI_SLV_RDBUF_CMD_VALUE 0x000000FF -#define SPI_SLV_RDBUF_CMD_VALUE_S 0 - -#define SPI_W0(i) (REG_SPI_BASE(i) +0x40) -#define SPI_W1(i) (REG_SPI_BASE(i) +0x44) -#define SPI_W2(i) (REG_SPI_BASE(i) +0x48) -#define SPI_W3(i) (REG_SPI_BASE(i) +0x4C) -#define SPI_W4(i) (REG_SPI_BASE(i) +0x50) -#define SPI_W5(i) (REG_SPI_BASE(i) +0x54) -#define SPI_W6(i) (REG_SPI_BASE(i) +0x58) -#define SPI_W7(i) (REG_SPI_BASE(i) +0x5C) -#define SPI_W8(i) (REG_SPI_BASE(i) +0x60) -#define SPI_W9(i) (REG_SPI_BASE(i) +0x64) -#define SPI_W10(i) (REG_SPI_BASE(i) +0x68) -#define SPI_W11(i) (REG_SPI_BASE(i) +0x6C) -#define SPI_W12(i) (REG_SPI_BASE(i) +0x70) -#define SPI_W13(i) (REG_SPI_BASE(i) +0x74) -#define SPI_W14(i) (REG_SPI_BASE(i) +0x78) -#define SPI_W15(i) (REG_SPI_BASE(i) +0x7C) - -#define SPI_EXT3(i) (REG_SPI_BASE(i) + 0xFC) -#define SPI_INT_HOLD_ENA 0x00000003 -#define SPI_INT_HOLD_ENA_S 0 -#endif // SPI_REGISTER_H_INCLUDED diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index f8a78dc96..bf887ff19 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -704,7 +704,6 @@ #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_ILI9488 // [DisplayModel 8] [I2cDriver38] (Touch) // #define USE_DISPLAY_SSD1351 // [DisplayModel 9] Enable SSD1351 module // #define USE_DISPLAY_RA8876 // [DisplayModel 10] [I2cDriver39] (Touch) // #define USE_DISPLAY_ST7789 // [DisplayModel 12] Enable ST7789 module diff --git a/tasmota/support_features.ino b/tasmota/support_features.ino index 6ed9eff6f..9236a511b 100644 --- a/tasmota/support_features.ino +++ b/tasmota/support_features.ino @@ -673,9 +673,9 @@ void ResponseAppendFeatures(void) #if defined(USE_SPI) && defined(USE_DISPLAY) && defined(USE_DISPLAY_EPAPER_42) feature7 |= 0x00008000; // xdsp_06_epaper_42.ino #endif -#if defined(USE_SPI) && defined(USE_DISPLAY) && defined(USE_DISPLAY_ILI9488) - feature7 |= 0x00010000; // xdsp_08_ILI9488.ino -#endif +// #if defined(USE_SPI) && defined(USE_DISPLAY) && defined(USE_DISPLAY_ILI9488) +// feature7 |= 0x00010000; // xdsp_08_ILI9488.ino +// #endif #if defined(USE_SPI) && defined(USE_DISPLAY) && defined(USE_DISPLAY_SSD1351) feature7 |= 0x00020000; // xdsp_09_SSD1351.ino #endif diff --git a/tasmota/tasmota_configurations.h b/tasmota/tasmota_configurations.h index f2fe27392..8dc302dad 100644 --- a/tasmota/tasmota_configurations.h +++ b/tasmota/tasmota_configurations.h @@ -330,7 +330,7 @@ #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_ILI9488 // [DisplayModel 8] + // #define USE_DISPLAY_ILI9488 // [DisplayModel 8] #define USE_DISPLAY_SSD1351 // [DisplayModel 9] #define USE_DISPLAY_RA8876 // [DisplayModel 10] #define USE_DISPLAY_ST7789 // [DisplayModel 12] Enable ST7789 module diff --git a/tasmota/xdrv_13_display.ino b/tasmota/xdrv_13_display.ino index 636d0e1ce..4b4a988cf 100755 --- a/tasmota/xdrv_13_display.ino +++ b/tasmota/xdrv_13_display.ino @@ -67,7 +67,7 @@ struct MULTI_DISP { uint8_t used; } displays[MAX_MULTI_DISPLAYS]; uint8_t cur_display; -Renderer *Init_uDisplay(const char *desc, int8_t cs = -1); +Renderer *Init_uDisplay(const char *desc); void Set_display(uint8_t index) { displays[index].display = renderer; diff --git a/tasmota/xdrv_52_3_berry_display.ino b/tasmota/xdrv_52_3_berry_display.ino index cb5b47846..ed930301d 100644 --- a/tasmota/xdrv_52_3_berry_display.ino +++ b/tasmota/xdrv_52_3_berry_display.ino @@ -24,7 +24,7 @@ #include #ifdef USE_UNIVERSAL_DISPLAY -Renderer *Init_uDisplay(const char *desc, int8_t cs = -1); +Renderer *Init_uDisplay(const char *desc); #endif // USE_UNIVERSAL_DISPLAY /*********************************************************************************************\ diff --git a/tasmota/xdsp_08_ILI9488.ino b/tasmota/xdsp_08_ILI9488.ino deleted file mode 100644 index 5c3cd2f5d..000000000 --- a/tasmota/xdsp_08_ILI9488.ino +++ /dev/null @@ -1,167 +0,0 @@ -/* - xdsp_08_ILI9488.ino - Display ILI9488 support for Tasmota - - Copyright (C) 2021 Theo Arends, Gerhard Mutz - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifdef USE_SPI -#ifdef USE_DISPLAY -#ifdef USE_DISPLAY_ILI9488 - -#define XDSP_08 8 -#define XI2C_38 38 // See I2CDEVICES.md - -#define COLORED 1 -#define UNCOLORED 0 - -// using font 8 is opional (num=3) -// very badly readable, but may be useful for graphs -#define USE_TINY_FONT - - -#include -uint8_t ili9488_ctouch_counter = 0; -bool ili9488_init_done = false; - -// currently fixed -#define BACKPLANE_PIN 2 - -extern uint8_t color_type; -ILI9488 *ili9488; -extern const uint16_t picture[]; - -/*********************************************************************************************/ - -void ILI9488_InitDriver(void) { - if (PinUsed(GPIO_ILI9488_CS) && (TasmotaGlobal.spi_enabled & SPI_MOSI)) { - - Settings->display_model = XDSP_08; - - if (Settings->display_width != ILI9488_TFTWIDTH) { - Settings->display_width = ILI9488_TFTWIDTH; - } - if (Settings->display_height != ILI9488_TFTHEIGHT) { - Settings->display_height = ILI9488_TFTHEIGHT; - } - - // default colors - fg_color = ILI9488_WHITE; - bg_color = ILI9488_BLACK; - - int8_t bppin = BACKPLANE_PIN; - if (PinUsed(GPIO_BACKLIGHT)) { - bppin = Pin(GPIO_BACKLIGHT); - } - - // init renderer, must use hardware spi - ili9488 = new ILI9488(Pin(GPIO_ILI9488_CS), Pin(GPIO_SPI_MOSI), Pin(GPIO_SPI_CLK), bppin); - - ili9488->begin(); - renderer = ili9488; - renderer->DisplayInit(DISPLAY_INIT_MODE,Settings->display_size,Settings->display_rotate,Settings->display_font); - renderer->dim(GetDisplayDimmer16()); - -#ifdef SHOW_SPLASH - // Welcome text - renderer->setTextFont(2); - renderer->setTextColor(ILI9488_WHITE,ILI9488_BLACK); - renderer->DrawStringAt(50, 50, "ILI9488 TFT Display!", ILI9488_WHITE,0); - delay(1000); - - //renderer->drawRGBBitmap(100,100, picture,51,34); -#endif - - color_type = COLOR_COLOR; - // start digitizer -#ifdef USE_FT5206 - FT5206_Touch_Init(Wire); -#endif - - ili9488_init_done = true; - AddLog(LOG_LEVEL_INFO, PSTR("DSP: ILI9488")); - } -} - -#ifdef USE_FT5206 -#ifdef USE_TOUCH_BUTTONS - -void ILI9488_RotConvert(int16_t *x, int16_t *y) { -int16_t temp; - if (renderer) { - uint8_t rot=renderer->getRotation(); - switch (rot) { - case 0: - temp=*y; - *y=renderer->height()-*x; - *x=temp; - break; - case 1: - break; - case 2: - break; - case 3: - temp=*y; - *y=*x; - *x=renderer->width()-temp; - break; - } - } -} - -// check digitizer hit -void ILI9488_CheckTouch(void) { - ili9488_ctouch_counter++; - if (2 == ili9488_ctouch_counter) { - // every 100 ms should be enough - ili9488_ctouch_counter = 0; - Touch_Check(ILI9488_RotConvert); - } -} -#endif // USE_TOUCH_BUTTONS -#endif // USE_FT5206 - - -/*********************************************************************************************/ -/*********************************************************************************************\ - * Interface -\*********************************************************************************************/ -bool Xdsp08(uint8_t function) -{ - bool result = false; - - if (FUNC_DISPLAY_INIT_DRIVER == function) { - ILI9488_InitDriver(); - } - else if (ili9488_init_done && (XDSP_08 == Settings->display_model)) { - switch (function) { - case FUNC_DISPLAY_MODEL: - result = true; - break; - case FUNC_DISPLAY_EVERY_50_MSECOND: -#ifdef USE_TOUCH_BUTTONS - if (FT5206_found) { - ILI9488_CheckTouch(); - } -#endif - break; - } - } - return result; -} - -#endif // USE_DISPLAY_ILI9488 -#endif // USE_DISPLAY -#endif // USE_SPI diff --git a/tasmota/xdsp_08_ILI9488_UD.ino b/tasmota/xdsp_08_ILI9488_UD.ino deleted file mode 100644 index 712f2fac3..000000000 --- a/tasmota/xdsp_08_ILI9488_UD.ino +++ /dev/null @@ -1,111 +0,0 @@ -/* - xdsp_08_ILI9488.ino - Display ILI9488 support for Tasmota - - Copyright (C) 2021 Theo Arends, Gerhard Mutz - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifdef USE_SPI -#ifdef USE_DISPLAY -#ifdef USE_DISPLAY_ILI9488_UD -#ifdef USE_UNIVERSAL_DISPLAY - -#define XDSP_08 8 - -bool ili9488_init_done = false; - -Renderer *Init_uDisplay(const char *desc, int8_t cs = -1); -void udisp_CheckTouch(void); - -/*********************************************************************************************/ - -const char ILI9488_DESC[] PROGMEM = -":H,ILI9488,480,320,16,SPI,1,*,*,*,*,*,*,*,10\n" -":S,2,1,1,0,40,20\n" -":I\n" -"E0,0F,00,03,09,08,16,0A,3F,78,4C,09,0A,08,16,1A,0F\n" -"E1,0F,00,16,19,03,0F,05,32,45,46,04,0E,0D,35,37,0F\n" -"C0,2,17,15\n" -"C1,1,41\n" -"C5,3,00,12,80\n" -"36,1,48\n" -"3A,1,66\n" -"B0,1,80\n" -"B1,1,A0\n" -"B4,1,02\n" -"B6,2,02,02\n" -"E9,1,00\n" -"F7,4,A9,51,2C,82\n" -"11,80\n" -"29,0\n" -":o,28\n" -":O,29\n" -":A,2A,2B,2C,16\n" -":R,36\n" -";:0,48,00,00,00\n" -":0,28,00,00,01\n" -":1,28,00,00,00\n" -":2,E8,00,00,03\n" -":3,88,00,00,02\n" -":P,18\n" -":i,20,21\n" -":TI1,38,*,*\n" -"#\n"; - -void ILI9488_InitDriver(void) { - if (PinUsed(GPIO_ILI9488_CS) && (TasmotaGlobal.spi_enabled & SPI_MOSI)) { - - renderer = Init_uDisplay(ILI9488_DESC, Pin(GPIO_ILI9488_CS)); - - if (!renderer) return; - - Settings->display_model = XDSP_08; - - ili9488_init_done = true; - } -} - -/*********************************************************************************************/ -/*********************************************************************************************\ - * Interface -\*********************************************************************************************/ -bool Xdsp08(uint8_t function) -{ - bool result = false; - - if (FUNC_DISPLAY_INIT_DRIVER == function) { - ILI9488_InitDriver(); - } - else if (ili9488_init_done && (XDSP_08 == Settings->display_model)) { - switch (function) { - case FUNC_DISPLAY_MODEL: - result = true; - break; - case FUNC_DISPLAY_EVERY_50_MSECOND: -#ifdef USE_FT5206 - if (FT5206_found) { - udisp_CheckTouch(); - } -#endif - break; - } - } - return result; -} - -#endif // USE_UNIVERSAL_DISPLAY -#endif // USE_DISPLAY_ILI9488 -#endif // USE_DISPLAY -#endif // USE_SPI diff --git a/tasmota/xdsp_17_universal.ino b/tasmota/xdsp_17_universal.ino index 16a886661..b80205029 100644 --- a/tasmota/xdsp_17_universal.ino +++ b/tasmota/xdsp_17_universal.ino @@ -62,10 +62,11 @@ void Core2DisplayDim(uint8_t dim); const char DSP_SAMPLE_DESC[] PROGMEM = DSP_ROM_DESC #endif // DSP_ROM_DESC /*********************************************************************************************/ -Renderer *Init_uDisplay(const char *desc, int8_t cs) { +Renderer *Init_uDisplay(const char *desc) { char *ddesc = 0; char *fbuff; uDisplay *udisp; +int8_t cs; if (TasmotaGlobal.gpio_optiona.udisplay_driver || desc) { @@ -185,18 +186,16 @@ uDisplay *udisp; cp += 4; //; 7 params nr,cs,sclk,mosi,dc,bl,reset,miso //SPI,*,*,*,*,*,*,* - if (cs < 0) { - switch (*cp) { - case '1': - cs = Pin(GPIO_SPI_CS); - break; - case '2': - cs = Pin(GPIO_SPI_CS, 1); - break; - default: - cs = Pin(GPIO_SSPI_CS); - break; - } + switch (*cp) { + case '1': + cs = Pin(GPIO_SPI_CS); + break; + case '2': + cs = Pin(GPIO_SPI_CS, 1); + break; + default: + cs = Pin(GPIO_SSPI_CS); + break; } if (*cp == '1') { cp+=2;