mirror of
https://github.com/Bodmer/TFT_eSPI.git
synced 2025-08-11 00:24:44 +02:00
Add parallel TFT readRectRGB(), fix #548
This commit is contained in:
44
TFT_eSPI.cpp
44
TFT_eSPI.cpp
@@ -650,7 +650,9 @@ uint16_t TFT_eSPI::readPixel(int32_t x0, int32_t y0)
|
|||||||
{
|
{
|
||||||
#if defined(TFT_PARALLEL_8_BIT)
|
#if defined(TFT_PARALLEL_8_BIT)
|
||||||
|
|
||||||
readAddrWindow(x0, y0, 1, 1); // Sets CS low
|
CS_L;
|
||||||
|
|
||||||
|
readAddrWindow(x0, y0, 1, 1);
|
||||||
|
|
||||||
// Set masked pins D0- D7 to input
|
// Set masked pins D0- D7 to input
|
||||||
busDir(dir_mask, INPUT);
|
busDir(dir_mask, INPUT);
|
||||||
@@ -673,7 +675,7 @@ uint16_t TFT_eSPI::readPixel(int32_t x0, int32_t y0)
|
|||||||
|
|
||||||
return rgb;
|
return rgb;
|
||||||
|
|
||||||
#else // ILI9481 16 bit read
|
#else // ILI9481 or ILI9486 16 bit read
|
||||||
|
|
||||||
// Fetch the 16 bit BRG pixel
|
// Fetch the 16 bit BRG pixel
|
||||||
uint16_t bgr = (readByte() << 8) | readByte();
|
uint16_t bgr = (readByte() << 8) | readByte();
|
||||||
@@ -683,10 +685,15 @@ uint16_t TFT_eSPI::readPixel(int32_t x0, int32_t y0)
|
|||||||
// Set masked pins D0- D7 to output
|
// Set masked pins D0- D7 to output
|
||||||
busDir(dir_mask, OUTPUT);
|
busDir(dir_mask, OUTPUT);
|
||||||
|
|
||||||
|
#ifdef ILI9486_DRIVER
|
||||||
|
return bgr;
|
||||||
|
#else
|
||||||
// Swap Red and Blue (could check MADCTL setting to see if this is needed)
|
// Swap Red and Blue (could check MADCTL setting to see if this is needed)
|
||||||
return (bgr>>11) | (bgr<<11) | (bgr & 0x7E0);
|
return (bgr>>11) | (bgr<<11) | (bgr & 0x7E0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#else // Not TFT_PARALLEL_8_BIT
|
#else // Not TFT_PARALLEL_8_BIT
|
||||||
|
|
||||||
// This function can get called during antialiased font rendering
|
// This function can get called during antialiased font rendering
|
||||||
@@ -755,7 +762,9 @@ void TFT_eSPI::readRect(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *da
|
|||||||
|
|
||||||
#if defined(TFT_PARALLEL_8_BIT)
|
#if defined(TFT_PARALLEL_8_BIT)
|
||||||
|
|
||||||
readAddrWindow(x, y, w, h); // Sets CS low
|
CS_L;
|
||||||
|
|
||||||
|
readAddrWindow(x, y, w, h);
|
||||||
|
|
||||||
// Set masked pins D0- D7 to input
|
// Set masked pins D0- D7 to input
|
||||||
busDir(dir_mask, INPUT);
|
busDir(dir_mask, INPUT);
|
||||||
@@ -778,14 +787,17 @@ void TFT_eSPI::readRect(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *da
|
|||||||
#else // ILI9481 reads as 16 bits
|
#else // ILI9481 reads as 16 bits
|
||||||
// Fetch the 16 bit BRG pixels
|
// Fetch the 16 bit BRG pixels
|
||||||
while (len--) {
|
while (len--) {
|
||||||
|
#ifdef ILI9486_DRIVER
|
||||||
|
// Read the RGB 16 bit colour
|
||||||
|
*data++ = readByte() | (readByte() << 8);
|
||||||
|
#else
|
||||||
// Read the BRG 16 bit colour
|
// Read the BRG 16 bit colour
|
||||||
uint16_t bgr = (readByte() << 8) | readByte();
|
uint16_t bgr = (readByte() << 8) | readByte();
|
||||||
|
|
||||||
// Swap Red and Blue (could check MADCTL setting to see if this is needed)
|
// Swap Red and Blue (could check MADCTL setting to see if this is needed)
|
||||||
uint16_t rgb = (bgr>>11) | (bgr<<11) | (bgr & 0x7E0);
|
uint16_t rgb = (bgr>>11) | (bgr<<11) | (bgr & 0x7E0);
|
||||||
|
|
||||||
// Swapped byte order for compatibility with pushRect()
|
// Swapped byte order for compatibility with pushRect()
|
||||||
*data++ = (rgb<<8) | (rgb>>8);
|
*data++ = (rgb<<8) | (rgb>>8);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -798,7 +810,7 @@ void TFT_eSPI::readRect(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *da
|
|||||||
|
|
||||||
begin_tft_read();
|
begin_tft_read();
|
||||||
|
|
||||||
readAddrWindow(x, y, w, h); // Sets CS low
|
readAddrWindow(x, y, w, h);
|
||||||
|
|
||||||
#ifdef TFT_SDA_READ
|
#ifdef TFT_SDA_READ
|
||||||
begin_SDA_Read();
|
begin_SDA_Read();
|
||||||
@@ -1508,7 +1520,20 @@ void TFT_eSPI::readRectRGB(int32_t x0, int32_t y0, int32_t w, int32_t h, uint8_
|
|||||||
{
|
{
|
||||||
#if defined(TFT_PARALLEL_8_BIT)
|
#if defined(TFT_PARALLEL_8_BIT)
|
||||||
|
|
||||||
// Parallel bus not supported yet
|
uint32_t len = w * h;
|
||||||
|
uint8_t* buf565 = data + len;
|
||||||
|
|
||||||
|
readRect(x0, y0, w, h, (uint16_t*)buf565);
|
||||||
|
|
||||||
|
while (len--) {
|
||||||
|
uint16_t pixel565 = (*buf565++)<<8 | (*buf565++);
|
||||||
|
uint8_t red = (pixel565 & 0xF800) >> 8; red |= red >> 5;
|
||||||
|
uint8_t green = (pixel565 & 0x07E0) >> 3; green |= green >> 6;
|
||||||
|
uint8_t blue = (pixel565 & 0x001F) << 3; blue |= blue >> 5;
|
||||||
|
*data++ = red;
|
||||||
|
*data++ = green;
|
||||||
|
*data++ = blue;
|
||||||
|
}
|
||||||
|
|
||||||
#else // Not TFT_PARALLEL_8_BIT
|
#else // Not TFT_PARALLEL_8_BIT
|
||||||
|
|
||||||
@@ -2618,9 +2643,10 @@ void TFT_eSPI::setWindow(int32_t x0, int32_t y0, int32_t x1, int32_t y1)
|
|||||||
** Function name: readAddrWindow
|
** Function name: readAddrWindow
|
||||||
** Description: define an area to read a stream of pixels
|
** Description: define an area to read a stream of pixels
|
||||||
***************************************************************************************/
|
***************************************************************************************/
|
||||||
// Chip select stays low
|
|
||||||
void TFT_eSPI::readAddrWindow(int32_t xs, int32_t ys, int32_t w, int32_t h)
|
void TFT_eSPI::readAddrWindow(int32_t xs, int32_t ys, int32_t w, int32_t h)
|
||||||
{
|
{
|
||||||
|
//begin_tft_write(); // Must be called before readAddrWindow or CS set low
|
||||||
|
|
||||||
int32_t xe = xs + w - 1;
|
int32_t xe = xs + w - 1;
|
||||||
int32_t ye = ys + h - 1;
|
int32_t ye = ys + h - 1;
|
||||||
|
|
||||||
@@ -2646,6 +2672,8 @@ void TFT_eSPI::readAddrWindow(int32_t xs, int32_t ys, int32_t w, int32_t h)
|
|||||||
DC_C; tft_Write_8(TFT_RAMRD);
|
DC_C; tft_Write_8(TFT_RAMRD);
|
||||||
|
|
||||||
DC_D;
|
DC_D;
|
||||||
|
|
||||||
|
//end_tft_write(); // Must be called after readAddrWindow or CS set high
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
#ifndef _TFT_eSPIH_
|
#ifndef _TFT_eSPIH_
|
||||||
#define _TFT_eSPIH_
|
#define _TFT_eSPIH_
|
||||||
|
|
||||||
#define TFT_ESPI_VERSION "2.1.2"
|
#define TFT_ESPI_VERSION "2.1.3"
|
||||||
|
|
||||||
/***************************************************************************************
|
/***************************************************************************************
|
||||||
** Section 1: Load required header files
|
** Section 1: Load required header files
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "TFT_eSPI",
|
"name": "TFT_eSPI",
|
||||||
"version": "2.1.2",
|
"version": "2.1.3",
|
||||||
"keywords": "Arduino, tft, ePaper, display, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9486, ST7789, RM68140",
|
"keywords": "Arduino, tft, ePaper, display, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9486, ST7789, RM68140",
|
||||||
"description": "A TFT and ePaper SPI graphics library with optimisation for ESP8266, ESP32 and STM32",
|
"description": "A TFT and ePaper SPI graphics library with optimisation for ESP8266, ESP32 and STM32",
|
||||||
"repository":
|
"repository":
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
name=TFT_eSPI
|
name=TFT_eSPI
|
||||||
version=2.1.2
|
version=2.1.3
|
||||||
author=Bodmer
|
author=Bodmer
|
||||||
maintainer=Bodmer
|
maintainer=Bodmer
|
||||||
sentence=TFT graphics library for Arduino processors with performance optimisation for STM32, ESP8266 and ESP32
|
sentence=TFT graphics library for Arduino processors with performance optimisation for STM32, ESP8266 and ESP32
|
||||||
|
Reference in New Issue
Block a user