Raise to version 2.0.0
The library has been cleaned up as it has got a bit untidy due to the large number of small incremental changes. 4bit Sprite examples renaed to be consistent with others. alphaBlend example moved to generic folder (alphaBlend fn was moved to TFT_eSPI class). Added sections + explanatory comments to functions prototypes. Temporary comments added for potential gotchas for noobs when using DMA. spi_begin/end functions renamed to reflect functionality. Old fns retained for backwards compatibility with user setup.h files.
This commit is contained in:
1 parent
b954372859
commit
0e0fd75277
29 files changed
+1267
-797
No files matched your search
@@ -12,8 +12,8 @@
|
||||
#include "soc/spi_reg.h"
|
||||
|
||||
// Processor specific code used by SPI bus transaction startWrite and endWrite functions
|
||||
#define SET_SPI_WRITE_MODE // Not used
|
||||
#define SET_SPI_READ_MODE // Not used
|
||||
#define SET_BUS_WRITE_MODE // Not used
|
||||
#define SET_BUS_READ_MODE // Not used
|
||||
|
||||
// Code to check if DMA is busy, used by SPI bus transaction transaction and endWrite functions
|
||||
#define DMA_BUSY_CHECK // DMA not implemented for this processor (yet)
|
||||
@@ -30,15 +30,7 @@
|
||||
#define SPI_PORT VSPI
|
||||
#endif
|
||||
|
||||
// If it is a 16bit serial display we must transfer 16 bits every time
|
||||
// Set commands bits to 16 or 8
|
||||
#ifdef RPI_ILI9486_DRIVER
|
||||
#ifndef RPI_DRIVER
|
||||
#define RPI_DRIVER
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef RPI_DRIVER
|
||||
#ifdef RPI_DISPLAY_TYPE
|
||||
#define CMD_BITS (16-1)
|
||||
#else
|
||||
#define CMD_BITS (8-1)
|
||||
@@ -73,7 +65,7 @@
|
||||
#define DC_D GPIO.out_w1ts = (1 << TFT_DC)
|
||||
#else
|
||||
#if TFT_DC >= 32
|
||||
#ifdef RPI_DRIVER // RPi displays need a slower DC change
|
||||
#ifdef RPI_DISPLAY_TYPE // RPi displays need a slower DC change
|
||||
#define DC_C GPIO.out1_w1ts.val = (1 << (TFT_DC - 32)); \
|
||||
GPIO.out1_w1tc.val = (1 << (TFT_DC - 32))
|
||||
#define DC_D GPIO.out1_w1tc.val = (1 << (TFT_DC - 32)); \
|
||||
@@ -83,12 +75,12 @@
|
||||
#define DC_D GPIO.out1_w1ts.val = (1 << (TFT_DC - 32))//;GPIO.out1_w1ts.val = (1 << (TFT_DC - 32))
|
||||
#endif
|
||||
#elif TFT_DC >= 0
|
||||
#ifdef RPI_ILI9486_DRIVER // RPi ILI9486 display needs a slower DC change
|
||||
#ifdef RPI_DISPLAY_TYPE // RPi ILI9486 display needs a slower DC change
|
||||
#define DC_C GPIO.out_w1tc = (1 << TFT_DC); \
|
||||
GPIO.out_w1tc = (1 << TFT_DC)
|
||||
#define DC_D GPIO.out_w1tc = (1 << TFT_DC); \
|
||||
GPIO.out_w1ts = (1 << TFT_DC)
|
||||
#elif defined (RPI_DRIVER) // Other RPi displays need a slower C->D change
|
||||
#elif defined (RPI_DISPLAY_TYPE) // Other RPi displays need a slower C->D change
|
||||
#define DC_C GPIO.out_w1tc = (1 << TFT_DC)
|
||||
#define DC_D GPIO.out_w1tc = (1 << TFT_DC); \
|
||||
GPIO.out_w1ts = (1 << TFT_DC)
|
||||
@@ -123,7 +115,7 @@
|
||||
#endif
|
||||
#else
|
||||
#if TFT_CS >= 32
|
||||
#ifdef RPI_ILI9486_DRIVER // RPi ILI9486 display needs a slower CS change
|
||||
#ifdef RPI_DISPLAY_TYPE // RPi ILI9486 display needs a slower CS change
|
||||
#define CS_L GPIO.out1_w1ts.val = (1 << (TFT_CS - 32)); \
|
||||
GPIO.out1_w1tc.val = (1 << (TFT_CS - 32))
|
||||
#define CS_H GPIO.out1_w1tc.val = (1 << (TFT_CS - 32)); \
|
||||
@@ -133,7 +125,7 @@
|
||||
#define CS_H GPIO.out1_w1ts.val = (1 << (TFT_CS - 32))//;GPIO.out1_w1ts.val = (1 << (TFT_CS - 32))
|
||||
#endif
|
||||
#elif TFT_CS >= 0
|
||||
#ifdef RPI_ILI9486_DRIVER // RPi ILI9486 display needs a slower CS change
|
||||
#ifdef RPI_DISPLAY_TYPE // RPi ILI9486 display needs a slower CS change
|
||||
#define CS_L GPIO.out_w1ts = (1 << TFT_CS); GPIO.out_w1tc = (1 << TFT_CS)
|
||||
#define CS_H GPIO.out_w1tc = (1 << TFT_CS); GPIO.out_w1ts = (1 << TFT_CS)
|
||||
#else
|
||||
@@ -277,7 +269,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Macros to write commands/pixel colour data to an Raspberry Pi TFT
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
#elif defined (RPI_DRIVER)
|
||||
#elif defined (RPI_DISPLAY_TYPE)
|
||||
|
||||
// ESP32 low level SPI writes for 8, 16 and 32 bit values
|
||||
// to avoid the function call overhead
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
// None
|
||||
|
||||
// Processor specific code used by SPI bus transaction startWrite and endWrite functions
|
||||
#define SET_SPI_WRITE_MODE SPI1U=SPI1U_WRITE
|
||||
#define SET_SPI_READ_MODE SPI1U=SPI1U_READ
|
||||
#define SET_BUS_WRITE_MODE SPI1U=SPI1U_WRITE
|
||||
#define SET_BUS_READ_MODE SPI1U=SPI1U_READ
|
||||
|
||||
// Code to check if DMA is busy, used by SPI bus transaction transaction and endWrite functions
|
||||
#define DMA_BUSY_CHECK // DMA not available, leave blank
|
||||
@@ -43,14 +43,6 @@
|
||||
#undef TFT_PARALLEL_8_BIT
|
||||
#endif
|
||||
|
||||
// If it is a 16bit serial display we must transfer 16 bits every time
|
||||
// Set commands bits to 16 or 8
|
||||
#ifdef RPI_ILI9486_DRIVER
|
||||
#ifndef RPI_DRIVER
|
||||
#define RPI_DRIVER
|
||||
#endif
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Define the DC (TFT Data/Command or Register Select (RS))pin drive code
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -151,7 +143,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Macros to write commands/pixel colour data to an Raspberry Pi TFT
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
#elif defined (RPI_DRIVER)
|
||||
#elif defined (RPI_DISPLAY_TYPE)
|
||||
// Command is 16 bits
|
||||
#define CMD_BITS 16
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
// None
|
||||
|
||||
// Processor specific code used by SPI bus transaction startWrite and endWrite functions
|
||||
#define SET_SPI_WRITE_MODE // Not used
|
||||
#define SET_SPI_READ_MODE // Not used
|
||||
#define SET_BUS_WRITE_MODE // Not used
|
||||
#define SET_BUS_READ_MODE // Not used
|
||||
|
||||
// Code to check if DMA is busy, used by SPI bus transaction startWrite and endWrite functions
|
||||
#define DMA_BUSY_CHECK // Not used so leave blank
|
||||
@@ -111,7 +111,7 @@
|
||||
// Macros to write commands/pixel colour data to other displays
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
#else
|
||||
#if defined (RPI_ILI9486_DRIVER) // RPi TFT always needs 16 bit transfers
|
||||
#if defined (RPI_DISPLAY_TYPE) // RPi TFT type always needs 16 bit transfers
|
||||
#define tft_Write_8(C) spi.transfer(0); spi.transfer(C)
|
||||
#else
|
||||
#ifdef __AVR__ // AVR processors do not have 16 bit transfer
|
||||
@@ -123,7 +123,7 @@
|
||||
#define tft_Write_16(C) spi.transfer16(C)
|
||||
#define tft_Write_16S(C) spi.transfer16(((C)>>8) | ((C)<<8))
|
||||
#endif // AVR
|
||||
#endif // RPI_ILI9486_DRIVER
|
||||
#endif // RPI_DISPLAY_TYPE
|
||||
|
||||
#define tft_Write_32(C) \
|
||||
tft_Write_16((uint16_t) ((C)>>16)); \
|
||||
|
||||
@@ -353,7 +353,7 @@ void TFT_eSPI::pushPixelsDMA(uint16_t* image, uint32_t len)
|
||||
if (len == 0) return;
|
||||
|
||||
// Wait for any current DMA transaction to end
|
||||
while (dmaHal.State == HAL_DMA_STATE_BUSY);
|
||||
while (spiHal.State == HAL_SPI_STATE_BUSY_TX); // Check if SPI Tx is busy
|
||||
|
||||
if(_swapBytes) {
|
||||
for (uint32_t i = 0; i < len; i++) (image[i] = image[i] << 8 | image[i] >> 8);
|
||||
@@ -389,8 +389,7 @@ void TFT_eSPI::pushImageDMA(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t
|
||||
|
||||
uint32_t len = dw*dh;
|
||||
|
||||
// Wait for any current DMA transaction to end
|
||||
while (dmaHal.State == HAL_DMA_STATE_BUSY);
|
||||
while (spiHal.State == HAL_SPI_STATE_BUSY_TX); // Check if SPI Tx is busy
|
||||
|
||||
// If image is clipped, copy pixels into a contiguous block
|
||||
if ( (dw != w) || (dh != h) ) {
|
||||
@@ -418,9 +417,6 @@ void TFT_eSPI::pushImageDMA(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for any current SPI transaction to end
|
||||
while (spiHal.State == HAL_SPI_STATE_BUSY_TX);
|
||||
|
||||
setWindow(x, y, x + dw - 1, y + dh - 1);
|
||||
|
||||
// DMA byte count for transmit is only 16 bits maximum, so to avoid this constraint
|
||||
@@ -446,7 +442,7 @@ void TFT_eSPI::pushImageDMA(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t
|
||||
** Description: Override the default HAL stream 3 interrupt handler
|
||||
***************************************************************************************/
|
||||
extern "C" void DMA2_Stream3_IRQHandler();
|
||||
void DMA2_Stream3_IRQHandler()
|
||||
void DMA2_Stream3_IRQHandler(void)
|
||||
{
|
||||
// Call the default end of buffer handler
|
||||
HAL_DMA_IRQHandler(&dmaHal);
|
||||
@@ -490,7 +486,7 @@ bool TFT_eSPI::initDMA(void)
|
||||
***************************************************************************************/
|
||||
extern "C" void DMA1_Channel3_IRQHandler();
|
||||
|
||||
void DMA1_Channel3_IRQHandler()
|
||||
void DMA1_Channel3_IRQHandler(void)
|
||||
{
|
||||
// Call the default end of buffer handler
|
||||
HAL_DMA_IRQHandler(&dmaHal);
|
||||
|
||||
@@ -11,9 +11,11 @@
|
||||
// Include processor specific header
|
||||
// None
|
||||
|
||||
// RPi support not tested - Fast RPi not supported
|
||||
|
||||
// Processor specific code used by SPI bus transaction startWrite and endWrite functions
|
||||
#define SET_SPI_WRITE_MODE // Not used
|
||||
#define SET_SPI_READ_MODE // Not used
|
||||
#define SET_BUS_WRITE_MODE // Not used
|
||||
#define SET_BUS_READ_MODE // Not used
|
||||
|
||||
// SUPPORT_TRANSACTIONS is mandatory for STM32
|
||||
#if !defined (SUPPORT_TRANSACTIONS)
|
||||
@@ -43,7 +45,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Write strobe timing setup
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
#if defined (ILI9341_DRIVER) // WRX twc spec is 66ns = 15.15MHz
|
||||
#if defined (ILI9341_DRIVER) || defined (ST7796_DRIVER) // WRX twc spec is 66ns = 15.15MHz
|
||||
|
||||
// Extra write pulse low time (delay for data setup)
|
||||
#if defined (STM32F2xx) || defined (STM32F4xx)
|
||||
@@ -731,7 +733,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Macros to write commands/pixel colour data to a SPI Raspberry Pi TFT
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
#elif defined (RPI_ILI9486_DRIVER)
|
||||
#elif defined (RPI_DISPLAY_TYPE)
|
||||
|
||||
#define tft_Write_8(C) \
|
||||
{ spiBuffer[0] = 0; spiBuffer[1] = C; \
|
||||
|
||||
Reference in new issue
Block a user