mirror of
https://github.com/Bodmer/TFT_eSPI.git
synced 2025-08-15 02:21:18 +02:00
Fix RP2040 with RPi type display
RPi display requires 16 bit commands and slower DC and CS strobe timings.
This commit is contained in:
@@ -59,9 +59,14 @@
|
|||||||
#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)
|
||||||
|
#if defined (RPI_DISPLAY_TYPE)
|
||||||
|
#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_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)
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Define the CS (TFT chip select) pin drive code
|
// Define the CS (TFT chip select) pin drive code
|
||||||
@@ -69,10 +74,15 @@
|
|||||||
#ifndef TFT_CS
|
#ifndef TFT_CS
|
||||||
#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
|
||||||
|
#if defined (RPI_DISPLAY_TYPE)
|
||||||
|
#define CS_L digitalWrite(TFT_CS, LOW);
|
||||||
|
#define CS_H digitalWrite(TFT_CS, HIGH);
|
||||||
#else
|
#else
|
||||||
#define CS_L sio_hw->gpio_clr = (1ul << TFT_CS)
|
#define CS_L sio_hw->gpio_clr = (1ul << TFT_CS)
|
||||||
#define CS_H sio_hw->gpio_set = (1ul << TFT_CS)
|
#define CS_H sio_hw->gpio_set = (1ul << TFT_CS)
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Make sure TFT_RD is defined if not used to avoid an error message
|
// Make sure TFT_RD is defined if not used to avoid an error message
|
||||||
|
12
TFT_eSPI.cpp
12
TFT_eSPI.cpp
@@ -3093,8 +3093,12 @@ 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)
|
||||||
|
#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);
|
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;
|
||||||
|
|
||||||
while (spi_get_hw(spi0)->sr & SPI_SSPSR_BSY_BITS) {};
|
while (spi_get_hw(spi0)->sr & SPI_SSPSR_BSY_BITS) {};
|
||||||
@@ -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;
|
||||||
|
#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);
|
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,9 +3325,13 @@ 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;
|
||||||
|
#if defined (RPI_DISPLAY_TYPE) // RPi TFT type always needs 16 bit transfers
|
||||||
|
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>>8;
|
||||||
spi_get_hw(spi0)->dr = (uint32_t)color;
|
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...
|
||||||
// Drain RX FIFO, then wait for shifting to finish (which may be *after*
|
// Drain RX FIFO, then wait for shifting to finish (which may be *after*
|
||||||
|
@@ -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
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"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":
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
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
|
||||||
|
Reference in New Issue
Block a user