From 8480f39a9c0e62a6024c63c482d82c665a8fb36a Mon Sep 17 00:00:00 2001 From: Bodmer Date: Thu, 17 Mar 2022 14:12:10 +0000 Subject: [PATCH] Various updates - raise to version 2.4.43 Sprite class uses TFT_eSPI setBitmapColor - fn deleted Small performance improvement to RP2040 SPI PIO Typo corrections Correct (unused) tft_Write_32 for STM32 Update HX8357D rotation code Enable software reset for ILI9486 Add preliminary RM68120 support --- Extensions/Sprite.cpp | 12 ------------ Extensions/Sprite.h | 3 --- Processors/TFT_eSPI_ESP32.h | 6 +++--- Processors/TFT_eSPI_STM32.h | 4 ++-- Processors/pio_SPI.pio | 6 +++--- Processors/pio_SPI.pio.h | 4 ++-- TFT_Drivers/HX8357D_Rotation.h | 16 +++++++-------- TFT_Drivers/ILI9486_Init.h | 2 +- TFT_eSPI.cpp | 36 ++++++++++++++++++++++++++++++++++ TFT_eSPI.h | 12 ++++++++---- library.json | 2 +- library.properties | 2 +- 12 files changed, 65 insertions(+), 40 deletions(-) diff --git a/Extensions/Sprite.cpp b/Extensions/Sprite.cpp index b1fea96..2e4ab2e 100644 --- a/Extensions/Sprite.cpp +++ b/Extensions/Sprite.cpp @@ -335,18 +335,6 @@ int8_t TFT_eSprite::getColorDepth(void) } -/*************************************************************************************** -** Function name: setBitmapColor -** Description: Set the 1bpp foreground foreground and background colour -***************************************************************************************/ -void TFT_eSprite::setBitmapColor(uint16_t c, uint16_t b) -{ - if (c == b) b = ~c; - _tft->bitmap_fg = c; - _tft->bitmap_bg = b; -} - - /*************************************************************************************** ** Function name: setPaletteColor ** Description: Set the 4bpp palette color at the given index diff --git a/Extensions/Sprite.h b/Extensions/Sprite.h index 8e27259..51fc123 100644 --- a/Extensions/Sprite.h +++ b/Extensions/Sprite.h @@ -49,9 +49,6 @@ class TFT_eSprite : public TFT_eSPI { // Get the color at the given palette index uint16_t getPaletteColor(uint8_t index); - // Set foreground and background colours for 1 bit per pixel Sprite - void setBitmapColor(uint16_t fg, uint16_t bg); - void drawPixel(int32_t x, int32_t y, uint32_t color); void drawChar(int32_t x, int32_t y, uint16_t c, uint32_t color, uint32_t bg, uint8_t font), diff --git a/Processors/TFT_eSPI_ESP32.h b/Processors/TFT_eSPI_ESP32.h index e65c8d5..841730c 100644 --- a/Processors/TFT_eSPI_ESP32.h +++ b/Processors/TFT_eSPI_ESP32.h @@ -478,7 +478,7 @@ SPI3_HOST = 2 // Write 8 bits #define tft_Write_8(C) TFT_WRITE_BITS((C)<<8, 16) - // Write 16 bits with corrected endianess for 16 bit colours + // Write 16 bits with corrected endianness for 16 bit colours #define tft_Write_16(C) TFT_WRITE_BITS((C)<<8 | (C)>>8, 16) // Future option for transfer without wait @@ -513,7 +513,7 @@ SPI3_HOST = 2 // Write 8 bits #define tft_Write_8(C) TFT_WRITE_BITS(C, 8) - // Write 16 bits with corrected endianess for 16 bit colours + // Write 16 bits with corrected endianness for 16 bit colours #define tft_Write_16(C) TFT_WRITE_BITS((C)<<8 | (C)>>8, 16) // Write 16 bits @@ -537,7 +537,7 @@ SPI3_HOST = 2 // Write 8 bits #define tft_Write_8(C) TFT_WRITE_BITS(C, 8) - // Write 16 bits with corrected endianess for 16 bit colours + // Write 16 bits with corrected endianness for 16 bit colours #define tft_Write_16(C) TFT_WRITE_BITS((C)<<8 | (C)>>8, 16) // Future option for transfer without wait diff --git a/Processors/TFT_eSPI_STM32.h b/Processors/TFT_eSPI_STM32.h index 31f2d23..2b23a58 100644 --- a/Processors/TFT_eSPI_STM32.h +++ b/Processors/TFT_eSPI_STM32.h @@ -1010,8 +1010,8 @@ HAL_SPI_Transmit(&spiHal, spiBuffer, 2, 10); } #define tft_Write_32(C) \ - { spiBuffer[1] = ((C)>>24); spiBuffer[3] = ((C)>>16); spiBuffer[5] = ((C)>>8); spiBuffer[7] = C; \ - HAL_SPI_Transmit(&spiHal, spiBuffer, 8, 10); } + { spiBuffer[0] = (C)>>24; spiBuffer[1] = (C)>>16; spiBuffer[2] = (C)>>8; spiBuffer[3] = C; \ + HAL_SPI_Transmit(&spiHal, spiBuffer, 4, 10); } #define tft_Write_32C(C,D) \ { spiBuffer[1] = ((C)>>8); spiBuffer[3] = (C); spiBuffer[5] = ((D)>>8); spiBuffer[7] = D; \ diff --git a/Processors/pio_SPI.pio b/Processors/pio_SPI.pio index 95f6ef9..63d44b1 100644 --- a/Processors/pio_SPI.pio +++ b/Processors/pio_SPI.pio @@ -16,10 +16,10 @@ public start_8: // Pull the next 32 bit value from the TX FIFO. pull side 0 - // Lose the top 24 bits - out null, 24 + // Lose the top 24 bits, send 1st bit + out pins, 25 // Now send remaining bits - jmp spi_out side 0 + jmp spi_out side 1 public set_addr_window: // Loop count in x for caset, paset and ramwr diff --git a/Processors/pio_SPI.pio.h b/Processors/pio_SPI.pio.h index a3d1199..ce72f22 100644 --- a/Processors/pio_SPI.pio.h +++ b/Processors/pio_SPI.pio.h @@ -22,8 +22,8 @@ static const uint16_t tft_io_program_instructions[] = { 0x90a0, // 0: pull block side 0 - 0x6078, // 1: out null, 24 - 0x101e, // 2: jmp 30 side 0 + 0x6019, // 1: out pins, 25 + 0x181e, // 2: jmp 30 side 1 0xf022, // 3: set x, 2 side 0 0xe000, // 4: set pins, 0 0x90a0, // 5: pull block side 0 diff --git a/TFT_Drivers/HX8357D_Rotation.h b/TFT_Drivers/HX8357D_Rotation.h index befe91a..f54eaef 100644 --- a/TFT_Drivers/HX8357D_Rotation.h +++ b/TFT_Drivers/HX8357D_Rotation.h @@ -5,22 +5,22 @@ switch (rotation) { case 0: // Portrait writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER); - _width = TFT_WIDTH; - _height = TFT_HEIGHT; + _width = _init_width; + _height = _init_height; break; case 1: // Landscape (Portrait + 90) writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_COLOR_ORDER); - _width = TFT_HEIGHT; - _height = TFT_WIDTH; + _width = _init_height; + _height = _init_width; break; case 2: // Inverter portrait writedata(TFT_MAD_COLOR_ORDER); - _width = TFT_WIDTH; - _height = TFT_HEIGHT; + _width = _init_width; + _height = _init_height; break; case 3: // Inverted landscape writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_COLOR_ORDER); - _width = TFT_HEIGHT; - _height = TFT_WIDTH; + _width = _init_height; + _height = _init_width; break; } diff --git a/TFT_Drivers/ILI9486_Init.h b/TFT_Drivers/ILI9486_Init.h index 3ac74ac..483e5f9 100644 --- a/TFT_Drivers/ILI9486_Init.h +++ b/TFT_Drivers/ILI9486_Init.h @@ -10,7 +10,7 @@ writecommand(0x01); // SW reset delay(120); - + writecommand(0x11); // Sleep out, also SW reset delay(120); diff --git a/TFT_eSPI.cpp b/TFT_eSPI.cpp index a4fb3c8..b7d7a89 100644 --- a/TFT_eSPI.cpp +++ b/TFT_eSPI.cpp @@ -737,6 +737,9 @@ void TFT_eSPI::init(uint8_t tc) #elif defined (ILI9225_DRIVER) #include "TFT_Drivers/ILI9225_Init.h" +#elif defined (RM68120_DRIVER) + #include "TFT_Drivers/RM68120_Init.h" + #endif #ifdef TFT_INVERSION_ON @@ -825,6 +828,9 @@ void TFT_eSPI::setRotation(uint8_t m) #elif defined (ILI9225_DRIVER) #include "TFT_Drivers/ILI9225_Rotation.h" +#elif defined (RM68120_DRIVER) + #include "TFT_Drivers/RM68120_Rotation.h" + #endif delayMicroseconds(10); @@ -889,6 +895,7 @@ void TFT_eSPI::spiwrite(uint8_t c) ** Function name: writecommand ** Description: Send an 8 bit command to the TFT ***************************************************************************************/ +#ifndef RM68120_DRIVER void TFT_eSPI::writecommand(uint8_t c) { begin_tft_write(); @@ -902,7 +909,36 @@ void TFT_eSPI::writecommand(uint8_t c) end_tft_write(); } +#else +void TFT_eSPI::writecommand(uint16_t c) +{ + begin_tft_write(); + DC_C; + + tft_Write_16(c); + + DC_D; + + end_tft_write(); + +} +void TFT_eSPI::writeRegister(uint16_t c, uint8_t d) +{ + begin_tft_write(); + + DC_C; + + tft_Write_16(c); + + DC_D; + + tft_Write_8(d); + + end_tft_write(); + +} +#endif /*************************************************************************************** ** Function name: writedata diff --git a/TFT_eSPI.h b/TFT_eSPI.h index 3ed10af..6f35911 100644 --- a/TFT_eSPI.h +++ b/TFT_eSPI.h @@ -16,7 +16,7 @@ #ifndef _TFT_eSPIH_ #define _TFT_eSPIH_ -#define TFT_ESPI_VERSION "2.4.42" +#define TFT_ESPI_VERSION "2.4.43" // Bit level feature flags // Bit 0 set: viewport capability @@ -620,9 +620,13 @@ class TFT_eSPI : public Print { friend class TFT_eSprite; // Sprite class has ac // Low level read/write void spiwrite(uint8_t); // legacy support only - - void writecommand(uint8_t c), // Send a command, function resets DC/RS high ready for data - writedata(uint8_t d); // Send data with DC/RS set high +#ifndef RM68120_DRIVER + void writecommand(uint8_t c); // Send a command, function resets DC/RS high ready for data +#else + void writecommand(uint16_t c); // Send a command, function resets DC/RS high ready for data + void writeRegister(uint16_t c, uint8_t d); // Write data to 16 bit command register +#endif + void writedata(uint8_t d); // Send data with DC/RS set high void commandList(const uint8_t *addr); // Send a initialisation sequence to TFT stored in FLASH diff --git a/library.json b/library.json index 8410d46..540c13d 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "TFT_eSPI", - "version": "2.4.42", + "version": "2.4.43", "keywords": "Arduino, tft, display, ttgo, LilyPi, WT32_SC01, ePaper, display, Pico, RP2040_Nano_Connect, RP2040, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9481, ILI9486, ILI9488, ST7789, ST7796, RM68140, SSD1351, SSD1963, ILI9225, HX8357D, GC9A01, R61581", "description": "A TFT and ePaper SPI graphics library with optimisation for Raspberry Pi Pico, RP2040, ESP8266, ESP32 and STM32", "repository": diff --git a/library.properties b/library.properties index f7bd743..5310ee3 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=TFT_eSPI -version=2.4.42 +version=2.4.43 author=Bodmer maintainer=Bodmer sentence=TFT graphics library for Arduino processors with performance optimisation for RP2040, STM32, ESP8266 and ESP32