Commit 0ad6de91 authored by Bodmer's avatar Bodmer

Fix RP2040 with RPi type display

RPi display requires 16 bit commands and slower DC and CS strobe timings.
parent 9d33b3ea
...@@ -59,8 +59,13 @@ ...@@ -59,8 +59,13 @@
#else #else
//#define DC_C sio_hw->gpio_clr = (1ul << TFT_DC) //#define DC_C sio_hw->gpio_clr = (1ul << TFT_DC)
//#define DC_D sio_hw->gpio_set = (1ul << TFT_DC) //#define DC_D sio_hw->gpio_set = (1ul << TFT_DC)
#define DC_C sio_hw->gpio_clr = (1ul << TFT_DC) #if defined (RPI_DISPLAY_TYPE)
#define DC_D sio_hw->gpio_set = (1ul << TFT_DC) #define DC_C digitalWrite(TFT_DC, LOW);
#define DC_D digitalWrite(TFT_DC, HIGH);
#else
#define DC_C sio_hw->gpio_clr = (1ul << TFT_DC)
#define DC_D sio_hw->gpio_set = (1ul << TFT_DC)
#endif
#endif #endif
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
...@@ -70,8 +75,13 @@ ...@@ -70,8 +75,13 @@
#define CS_L // No macro allocated so it generates no code #define CS_L // No macro allocated so it generates no code
#define CS_H // No macro allocated so it generates no code #define CS_H // No macro allocated so it generates no code
#else #else
#define CS_L sio_hw->gpio_clr = (1ul << TFT_CS) #if defined (RPI_DISPLAY_TYPE)
#define CS_H sio_hw->gpio_set = (1ul << TFT_CS) #define CS_L digitalWrite(TFT_CS, LOW);
#define CS_H digitalWrite(TFT_CS, HIGH);
#else
#define CS_L sio_hw->gpio_clr = (1ul << TFT_CS)
#define CS_H sio_hw->gpio_set = (1ul << TFT_CS)
#endif
#endif #endif
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
......
...@@ -3093,7 +3093,11 @@ void TFT_eSPI::setWindow(int32_t x0, int32_t y0, int32_t x1, int32_t y1) ...@@ -3093,7 +3093,11 @@ void TFT_eSPI::setWindow(int32_t x0, int32_t y0, int32_t x1, int32_t y1)
while (spi_get_hw(spi0)->sr & SPI_SSPSR_BSY_BITS) {}; while (spi_get_hw(spi0)->sr & SPI_SSPSR_BSY_BITS) {};
DC_C; DC_C;
#if !defined (SPI_18BIT_DRIVER) #if !defined (SPI_18BIT_DRIVER)
spi_set_format(spi0, 8, (spi_cpol_t)0, (spi_cpha_t)0, SPI_MSB_FIRST); #if defined (RPI_DISPLAY_TYPE) // RPi TFT type always needs 16 bit transfers
spi_set_format(spi0, 16, (spi_cpol_t)0, (spi_cpha_t)0, SPI_MSB_FIRST);
#else
spi_set_format(spi0, 8, (spi_cpol_t)0, (spi_cpha_t)0, SPI_MSB_FIRST);
#endif
#endif #endif
spi_get_hw(spi0)->dr = (uint32_t)TFT_CASET; spi_get_hw(spi0)->dr = (uint32_t)TFT_CASET;
...@@ -3282,7 +3286,11 @@ void TFT_eSPI::drawPixel(int32_t x, int32_t y, uint32_t color) ...@@ -3282,7 +3286,11 @@ void TFT_eSPI::drawPixel(int32_t x, int32_t y, uint32_t color)
// a busy check is not needed. // a busy check is not needed.
while (spi_get_hw(spi0)->sr & SPI_SSPSR_BSY_BITS) {}; while (spi_get_hw(spi0)->sr & SPI_SSPSR_BSY_BITS) {};
DC_C; DC_C;
spi_set_format(spi0, 8, (spi_cpol_t)0, (spi_cpha_t)0, SPI_MSB_FIRST); #if defined (RPI_DISPLAY_TYPE) // RPi TFT type always needs 16 bit transfers
spi_set_format(spi0, 16, (spi_cpol_t)0, (spi_cpha_t)0, SPI_MSB_FIRST);
#else
spi_set_format(spi0, 8, (spi_cpol_t)0, (spi_cpha_t)0, SPI_MSB_FIRST);
#endif
spi_get_hw(spi0)->dr = (uint32_t)TFT_CASET; spi_get_hw(spi0)->dr = (uint32_t)TFT_CASET;
while (spi_get_hw(spi0)->sr & SPI_SSPSR_BSY_BITS){}; while (spi_get_hw(spi0)->sr & SPI_SSPSR_BSY_BITS){};
...@@ -3317,8 +3325,12 @@ void TFT_eSPI::drawPixel(int32_t x, int32_t y, uint32_t color) ...@@ -3317,8 +3325,12 @@ void TFT_eSPI::drawPixel(int32_t x, int32_t y, uint32_t color)
#else #else
while (spi_get_hw(spi0)->sr & SPI_SSPSR_BSY_BITS) {}; while (spi_get_hw(spi0)->sr & SPI_SSPSR_BSY_BITS) {};
DC_D; DC_D;
spi_get_hw(spi0)->dr = (uint32_t)color>>8; #if defined (RPI_DISPLAY_TYPE) // RPi TFT type always needs 16 bit transfers
spi_get_hw(spi0)->dr = (uint32_t)color; spi_get_hw(spi0)->dr = (uint32_t)color;
#else
spi_get_hw(spi0)->dr = (uint32_t)color>>8;
spi_get_hw(spi0)->dr = (uint32_t)color;
#endif
#endif #endif
/* /*
// Subsequent pixel reads work OK without draining the FIFO... // Subsequent pixel reads work OK without draining the FIFO...
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#ifndef _TFT_eSPIH_ #ifndef _TFT_eSPIH_
#define _TFT_eSPIH_ #define _TFT_eSPIH_
#define TFT_ESPI_VERSION "2.3.72" #define TFT_ESPI_VERSION "2.3.73"
// Bit level feature flags // Bit level feature flags
// Bit 0 set: viewport capability // Bit 0 set: viewport capability
......
{ {
"name": "TFT_eSPI", "name": "TFT_eSPI",
"version": "2.3.72", "version": "2.3.73",
"keywords": "Arduino, tft, ePaper, display, Pico, RP2040, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9481, ILI9486, ILI9488, ST7789, RM68140, SSD1351, SSD1963, ILI9225, HX8357D", "keywords": "Arduino, tft, ePaper, display, Pico, RP2040, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9481, ILI9486, ILI9488, ST7789, RM68140, SSD1351, SSD1963, ILI9225, HX8357D",
"description": "A TFT and ePaper SPI graphics library with optimisation for Raspberry Pi Pico, ESP8266, ESP32 and STM32", "description": "A TFT and ePaper SPI graphics library with optimisation for Raspberry Pi Pico, ESP8266, ESP32 and STM32",
"repository": "repository":
......
name=TFT_eSPI name=TFT_eSPI
version=2.3.72 version=2.3.73
author=Bodmer author=Bodmer
maintainer=Bodmer maintainer=Bodmer
sentence=TFT graphics library for Arduino processors with performance optimisation for RP2040, STM32, ESP8266 and ESP32 sentence=TFT graphics library for Arduino processors with performance optimisation for RP2040, STM32, ESP8266 and ESP32
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment