Update TFT_eSPI to v2.5.43
This commit is contained in:
@@ -24,9 +24,6 @@
|
||||
DMA_HandleTypeDef dmaHal;
|
||||
#endif
|
||||
|
||||
// Buffer for SPI transmit byte padding and byte order manipulation
|
||||
uint8_t spiBuffer[8];
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
#if defined (TFT_SDA_READ) && !defined (TFT_PARALLEL_8_BIT)
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -76,7 +73,7 @@ void TFT_eSPI::end_SDA_Read(void)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
#if defined (TFT_PARALLEL_8_BIT) // Code for STM32 8 bit parallel
|
||||
#if defined (TFT_PARALLEL_8_BIT) // Code for STM32 8-bit parallel
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/***************************************************************************************
|
||||
@@ -286,7 +283,7 @@ void TFT_eSPI::pushPixels(const void* data_in, uint32_t len)
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
#elif defined (SPI_18BIT_DRIVER) // SPI 18 bit colour
|
||||
#elif defined (SPI_18BIT_DRIVER) // SPI 18-bit colour
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/***************************************************************************************
|
||||
@@ -296,34 +293,19 @@ void TFT_eSPI::pushPixels(const void* data_in, uint32_t len)
|
||||
#define BUF_SIZE 240*3
|
||||
void TFT_eSPI::pushBlock(uint16_t color, uint32_t len)
|
||||
{
|
||||
uint8_t col[BUF_SIZE];
|
||||
//uint8_t col[BUF_SIZE];
|
||||
// Always using swapped bytes is a peculiarity of this function...
|
||||
//color = color>>8 | color<<8;
|
||||
uint8_t r = (color & 0xF800)>>8; // Red
|
||||
uint8_t g = (color & 0x07E0)>>3; // Green
|
||||
uint8_t b = (color & 0x001F)<<3; // Blue
|
||||
|
||||
if (len<BUF_SIZE/3) {
|
||||
for (uint32_t i = 0; i < len*3; i++) {
|
||||
col[i] = r;
|
||||
col[++i] = g;
|
||||
col[++i] = b;
|
||||
}
|
||||
HAL_SPI_Transmit(&spiHal, col, len*3, HAL_MAX_DELAY);
|
||||
return;
|
||||
while(len--) {
|
||||
TX_FIFO = (r);
|
||||
TX_FIFO = (g);
|
||||
TX_FIFO = (b);
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < BUF_SIZE; i++) {
|
||||
col[i] = r;
|
||||
col[++i] = g;
|
||||
col[++i] = b;
|
||||
}
|
||||
do {
|
||||
HAL_SPI_Transmit(&spiHal, col, BUF_SIZE, HAL_MAX_DELAY);
|
||||
len -= BUF_SIZE/3;
|
||||
} while ( len>=BUF_SIZE/3 ) ;
|
||||
// Send remaining pixels
|
||||
if (len) HAL_SPI_Transmit(&spiHal, col, len*3, HAL_MAX_DELAY); //*/
|
||||
SPI_BUSY_CHECK;
|
||||
}
|
||||
/***************************************************************************************
|
||||
** Function name: pushPixels - for STM32 and 3 byte RGB display
|
||||
@@ -333,30 +315,29 @@ void TFT_eSPI::pushPixels(const void* data_in, uint32_t len)
|
||||
{
|
||||
uint16_t *data = (uint16_t*)data_in;
|
||||
|
||||
if(_swapBytes) {
|
||||
if(!_swapBytes) {
|
||||
while ( len-- ) {
|
||||
// Split out the colours
|
||||
spiBuffer[0] = (*data & 0xF8); // Red
|
||||
spiBuffer[1] = (*data & 0xE000)>>11 | (*data & 0x07)<<5; // Green
|
||||
spiBuffer[2] = (*data & 0x1F00)>>5; // Blue
|
||||
TX_FIFO = (*data & 0xF8); // Red
|
||||
TX_FIFO = (*data & 0xE000)>>11 | (*data & 0x07)<<5; // Green
|
||||
TX_FIFO = (*data & 0x1F00)>>5; // Blue
|
||||
data++;
|
||||
HAL_SPI_Transmit(&spiHal, spiBuffer, 3, HAL_MAX_DELAY);
|
||||
}
|
||||
}
|
||||
else {
|
||||
while ( len-- ) {
|
||||
// Split out the colours
|
||||
spiBuffer[0] = (*data & 0xF800)>>8; // Red
|
||||
spiBuffer[1] = (*data & 0x07E0)>>3; // Green
|
||||
spiBuffer[2] = (*data & 0x001F)<<3; // Blue
|
||||
TX_FIFO = (*data & 0xF800)>>8; // Red
|
||||
TX_FIFO = (*data & 0x07E0)>>3; // Green
|
||||
TX_FIFO = (*data & 0x001F)<<3; // Blue
|
||||
data++;
|
||||
HAL_SPI_Transmit(&spiHal, spiBuffer, 3, HAL_MAX_DELAY);
|
||||
}
|
||||
}
|
||||
SPI_BUSY_CHECK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
#else // Standard SPI 16 bit colour TFT All Tested
|
||||
#else // Standard SPI 16-bit colour TFT All Tested
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/***************************************************************************************
|
||||
@@ -364,6 +345,7 @@ void TFT_eSPI::pushPixels(const void* data_in, uint32_t len)
|
||||
** Description: Write a block of pixels of the same colour
|
||||
***************************************************************************************/
|
||||
#define BUF_SIZE 480
|
||||
/*
|
||||
void TFT_eSPI::pushBlock(uint16_t color, uint32_t len)
|
||||
{
|
||||
uint16_t col[BUF_SIZE];
|
||||
@@ -381,7 +363,47 @@ void TFT_eSPI::pushBlock(uint16_t color, uint32_t len)
|
||||
len -= BUF_SIZE;
|
||||
} while ( len>=BUF_SIZE ) ;
|
||||
// Send remaining pixels
|
||||
if (len) HAL_SPI_Transmit(&spiHal, (uint8_t*)col, len<<1, HAL_MAX_DELAY); //*/
|
||||
if (len) HAL_SPI_Transmit(&spiHal, (uint8_t*)col, len<<1, HAL_MAX_DELAY);
|
||||
}
|
||||
//*/
|
||||
void TFT_eSPI::pushBlock(uint16_t color, uint32_t len){
|
||||
// Loop unrolling improves speed dramatically graphics test 0.634s => 0.374s
|
||||
while (len>31) {
|
||||
#if !defined (SSD1963_DRIVER)
|
||||
// 32D macro writes 16 bits twice
|
||||
tft_Write_32D(color); tft_Write_32D(color);
|
||||
tft_Write_32D(color); tft_Write_32D(color);
|
||||
tft_Write_32D(color); tft_Write_32D(color);
|
||||
tft_Write_32D(color); tft_Write_32D(color);
|
||||
tft_Write_32D(color); tft_Write_32D(color);
|
||||
tft_Write_32D(color); tft_Write_32D(color);
|
||||
tft_Write_32D(color); tft_Write_32D(color);
|
||||
tft_Write_32D(color); tft_Write_32D(color);
|
||||
#else
|
||||
tft_Write_16(color); tft_Write_16(color); tft_Write_16(color); tft_Write_16(color);
|
||||
tft_Write_16(color); tft_Write_16(color); tft_Write_16(color); tft_Write_16(color);
|
||||
tft_Write_16(color); tft_Write_16(color); tft_Write_16(color); tft_Write_16(color);
|
||||
tft_Write_16(color); tft_Write_16(color); tft_Write_16(color); tft_Write_16(color);
|
||||
tft_Write_16(color); tft_Write_16(color); tft_Write_16(color); tft_Write_16(color);
|
||||
tft_Write_16(color); tft_Write_16(color); tft_Write_16(color); tft_Write_16(color);
|
||||
tft_Write_16(color); tft_Write_16(color); tft_Write_16(color); tft_Write_16(color);
|
||||
tft_Write_16(color); tft_Write_16(color); tft_Write_16(color); tft_Write_16(color);
|
||||
#endif
|
||||
len-=32;
|
||||
}
|
||||
|
||||
while (len>7) {
|
||||
#if !defined (SSD1963_DRIVER)
|
||||
tft_Write_32D(color); tft_Write_32D(color);
|
||||
tft_Write_32D(color); tft_Write_32D(color);
|
||||
#else
|
||||
tft_Write_16(color); tft_Write_16(color); tft_Write_16(color); tft_Write_16(color);
|
||||
tft_Write_16(color); tft_Write_16(color); tft_Write_16(color); tft_Write_16(color);
|
||||
#endif
|
||||
len-=8;
|
||||
}
|
||||
|
||||
while (len--) {tft_Write_16(color);}
|
||||
}
|
||||
|
||||
|
||||
@@ -392,26 +414,23 @@ void TFT_eSPI::pushBlock(uint16_t color, uint32_t len)
|
||||
void TFT_eSPI::pushPixels(const void* data_in, uint32_t len)
|
||||
{
|
||||
uint16_t *data = (uint16_t*)data_in;
|
||||
|
||||
if(_swapBytes) {
|
||||
uint16_t col[BUF_SIZE]; // Buffer for swapped bytes
|
||||
while ( len>=BUF_SIZE ) {
|
||||
for (uint32_t i = 0; i < BUF_SIZE; i++) { col[i] = (*data>>8) | (*data<<8); data++; }
|
||||
HAL_SPI_Transmit(&spiHal, (uint8_t*)col, BUF_SIZE<<1, HAL_MAX_DELAY);
|
||||
len -= BUF_SIZE;
|
||||
while ( len-- ) {
|
||||
TX_FIFO = (uint8_t)(*data>>8);
|
||||
TX_FIFO = (uint8_t)(*data<<8);
|
||||
data++;
|
||||
}
|
||||
for (uint32_t i = 0; i < len; i++) { col[i] = (*data>>8) | (*data<<8); data++; }
|
||||
HAL_SPI_Transmit(&spiHal, (uint8_t*)col, len<<1, HAL_MAX_DELAY);
|
||||
}
|
||||
else {
|
||||
// HAL byte count for transmit is only 16 bits maximum so to avoid this constraint
|
||||
// transfers of small blocks are performed until HAL capacity is reached.
|
||||
while(len>0x7FFF) { // Transfer 16 bit pixels in blocks if len*2 over 65534 bytes
|
||||
HAL_SPI_Transmit(&spiHal, (uint8_t*)data, 0x800<<1, HAL_MAX_DELAY);
|
||||
len -= 0x800; data+= 0x800; // Arbitrarily use 2KByte blocks
|
||||
while ( len-- ) {
|
||||
// Split out the colours
|
||||
TX_FIFO = (uint8_t)(*data);
|
||||
TX_FIFO = (uint8_t)(*data>>8);
|
||||
data++;
|
||||
}
|
||||
// Send remaining pixels (max 65534 bytes)
|
||||
HAL_SPI_Transmit(&spiHal, (uint8_t*)data, len<<1, HAL_MAX_DELAY);
|
||||
}
|
||||
SPI_BUSY_CHECK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -527,7 +546,7 @@ void TFT_eSPI::pushImageDMA(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t
|
||||
// small transfers are performed using a blocking call until DMA capacity is reached.
|
||||
// User sketch can prevent blocking by managing pixel count and splitting into blocks
|
||||
// of 32767 pixels maximum. (equivalent to an area of ~320 x 100 pixels)
|
||||
while(len>0x7FFF) { // Transfer 16 bit pixels in blocks if len*2 over 65534 bytes
|
||||
while(len>0x7FFF) { // Transfer 16-bit pixels in blocks if len*2 over 65534 bytes
|
||||
HAL_SPI_Transmit(&spiHal, (uint8_t*)buffer, 0x800<<1, HAL_MAX_DELAY);
|
||||
len -= 0x800; buffer+= 0x800; // Arbitrarily send 1K pixel blocks (2Kbytes)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user