Support for SSD1963 and ST7706 SPI read

The SSD1963 support has been tested with a 480x800 pixel display from Buy Display.
Support for reading an ST7796 SPI display has been added.
pushToSprite added to keywords list.
This commit is contained in:
Bodmer committed 2020-10-02 01:07:15 +01:00
1 parent 0c49b71dd4
commit 49cef1f35d
15 files changed
+458 -94

No files matched your search

+6 -2
View File
@@ -457,7 +457,11 @@ void TFT_eSPI::pushBlock(uint16_t color, uint32_t len){
if ( (color >> 8) == (color & 0x00FF) )
{ if (!len) return;
tft_Write_16(color);
#if defined (SSD1963_DRIVER)
while (--len) {WR_L; WR_H; WR_L; WR_H; WR_L; WR_H;}
#else
while (--len) {WR_L; WR_H; WR_L; WR_H;}
#endif
}
else while (len--) {tft_Write_16(color);}
}
@@ -649,8 +653,8 @@ extern "C" void dc_callback();
void IRAM_ATTR dc_callback(spi_transaction_t *spi_tx)
{
if ((bool)spi_tx->user) DC_D;
else DC_C;
if ((bool)spi_tx->user) {DC_D;}
else {DC_C;}
}
/***************************************************************************************
+36 -18
View File
@@ -84,24 +84,42 @@ void TFT_eSPI::end_SDA_Read(void)
** Description: Write a block of pixels of the same colour
***************************************************************************************/
void TFT_eSPI::pushBlock(uint16_t color, uint32_t len){
// Loop unrolling improves speed dramtically graphics test 0.634s => 0.374s
while (len>31) {
// 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);
len-=32;
}
while (len>7) {
tft_Write_32D(color); tft_Write_32D(color);
tft_Write_32D(color); tft_Write_32D(color);
len-=8;
}
// Loop unrolling improves speed dramtically 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);}
}
+124 -2
View File
@@ -411,6 +411,31 @@
GPIOB->BSRR = D3_BSR_MASK(C) | D4_BSR_MASK(C) | D5_BSR_MASK(C) | D6_BSR_MASK(C); \
WR_STB // Need to slow down strobe
#if defined (SSD1963_DRIVER)
// Write 18 bit color to TFT (untested)
#define tft_Write_16(C) uint8_t r = (((C) & 0xF800)>> 8); uint8_t g = (((C) & 0x07E0)>> 3); uint8_t b = (((C) & 0x001F)<< 3); \
GPIOA->BSRR = D0_BSR_MASK(r) | D2_BSR_MASK(r) | D7_BSR_MASK(r); \
WR_L; \
GPIOC->BSRR = D1_BSR_MASK(r); \
GPIOB->BSRR = D3_BSR_MASK(r) | D4_BSR_MASK(r) | D5_BSR_MASK(r) | D6_BSR_MASK(r); \
WR_STB; \
GPIOA->BSRR = D0_BSR_MASK(g) | D2_BSR_MASK(g) | D7_BSR_MASK(g); \
WR_L; \
GPIOC->BSRR = D1_BSR_MASK(g); \
GPIOB->BSRR = D3_BSR_MASK(g) | D4_BSR_MASK(g) | D5_BSR_MASK(g) | D6_BSR_MASK(g); \
WR_STB; \
GPIOA->BSRR = D0_BSR_MASK(b) | D2_BSR_MASK(b) | D7_BSR_MASK(b); \
WR_L; \
GPIOC->BSRR = D1_BSR_MASK(b); \
GPIOB->BSRR = D3_BSR_MASK(b) | D4_BSR_MASK(b) | D5_BSR_MASK(b) | D6_BSR_MASK(b); \
WR_STB // Need to slow down strobe
// 18 bit color write with swapped bytes
#define tft_Write_16S(C) uint16_t Cswap = ((C) >>8 | (C) << 8); tft_Write_16(Cswap)
#else
// Write 16 bits to TFT
#define tft_Write_16(C) GPIOA->BSRR = D8_BSR_MASK(C) | D10_BSR_MASK(C) | D15_BSR_MASK(C); \
WR_L; \
@@ -434,6 +459,7 @@
GPIOC->BSRR = D9_BSR_MASK(C); \
GPIOB->BSRR = D11_BSR_MASK(C) | D12_BSR_MASK(C) | D13_BSR_MASK(C) | D14_BSR_MASK(C); \
WR_STB
#endif
#define tft_Write_32(C) tft_Write_16((uint16_t)((C)>>16)); tft_Write_16((uint16_t)(C))
@@ -527,6 +553,31 @@
GPIOE->BSRR = D3_BSR_MASK(C) | D5_BSR_MASK(C) | D6_BSR_MASK(C); \
WR_STB
#if defined (SSD1963_DRIVER)
// Write 18 bit color to TFT (untested)
#define tft_Write_16(C) uint8_t r = (((C) & 0xF800)>> 8); uint8_t g = (((C) & 0x07E0)>> 3); uint8_t b = (((C) & 0x001F)<< 3); \
GPIOF->BSRR = D0_BSR_MASK(r) | D2_BSR_MASK(r) | D4_BSR_MASK(r) | D7_BSR_MASK(r); \
WR_L; \
GPIOD->BSRR = D1_BSR_MASK(r); \
GPIOE->BSRR = D3_BSR_MASK(r) | D5_BSR_MASK(r) | D6_BSR_MASK(r); \
WR_STB; \
GPIOF->BSRR = D0_BSR_MASK(g) | D2_BSR_MASK(g) | D4_BSR_MASK(g) | D7_BSR_MASK(g); \
WR_L; \
GPIOD->BSRR = D1_BSR_MASK(g); \
GPIOE->BSRR = D3_BSR_MASK(g) | D5_BSR_MASK(g) | D6_BSR_MASK(g); \
WR_STB; \
GPIOF->BSRR = D0_BSR_MASK(b) | D2_BSR_MASK(b) | D4_BSR_MASK(b) | D7_BSR_MASK(b); \
WR_L; \
GPIOD->BSRR = D1_BSR_MASK(b); \
GPIOE->BSRR = D3_BSR_MASK(b) | D5_BSR_MASK(b) | D6_BSR_MASK(b); \
WR_STB // Need to slow down strobe
// 18 bit color write with swapped bytes
#define tft_Write_16S(C) uint16_t Cswap = ((C) >>8 | (C) << 8); tft_Write_16(Cswap)
#else
// Write 16 bits to TFT
#define tft_Write_16(C) GPIOF->BSRR = D8_BSR_MASK(C) | D10_BSR_MASK(C) | D12_BSR_MASK(C) | D15_BSR_MASK(C); \
WR_L; \
@@ -551,6 +602,8 @@
GPIOE->BSRR = D11_BSR_MASK(C) | D13_BSR_MASK(C) | D14_BSR_MASK(C); \
WR_STB
#endif
#define tft_Write_32(C) tft_Write_16((uint16_t)((C)>>16)); tft_Write_16((uint16_t)(C))
#define tft_Write_32C(C,D) tft_Write_16((uint16_t)(C)); tft_Write_16((uint16_t)(D))
@@ -672,7 +725,20 @@
// Write 8 bits to TFT
#define tft_Write_8(C) GPIOA->BSRR = (0x00FF0000 | (uint8_t)(C)); WR_L; WR_STB
#if defined (SSD1963_DRIVER)
// Write 18 bit color to TFT (untested)
#define tft_Write_16(C) uint8_t r = (((C) & 0xF800)>> 8); uint8_t g = (((C) & 0x07E0)>> 3); uint8_t b = (((C) & 0x001F)<< 3); \
GPIOA->BSRR = (0x00FF0000 | (uint8_t)(r)); WR_L; WR_STB; \
GPIOA->BSRR = (0x00FF0000 | (uint8_t)(g)); WR_L; WR_STB; \
GPIOA->BSRR = (0x00FF0000 | (uint8_t)(b)); WR_L; WR_STB
// 18 bit color write with swapped bytes
#define tft_Write_16S(C) uint16_t Cswap = ((C) >>8 | (C) << 8); tft_Write_16(Cswap)
#else
// Write 16 bits to TFT
#define tft_Write_16(C) GPIOA->BSRR = (0x00FF0000 | (uint8_t)(C>>8)); WR_L; WR_STB; \
GPIOA->BSRR = (0x00FF0000 | (uint8_t)(C>>0)); WR_L; WR_STB
@@ -680,6 +746,7 @@
// 16 bit write with swapped bytes
#define tft_Write_16S(C) GPIOA->BSRR = (0x00FF0000 | (uint8_t)(C>>0)); WR_L; WR_STB; \
GPIOA->BSRR = (0x00FF0000 | (uint8_t)(C>>8)); WR_L; WR_STB
#endif
#define tft_Write_32(C) tft_Write_16((uint16_t)((C)>>16)); tft_Write_16((uint16_t)(C))
@@ -701,7 +768,20 @@
// Write 8 bits to TFT
#define tft_Write_8(C) GPIOB->BSRR = (0x00FF0000 | (uint8_t)(C)); WR_L; WR_STB
#if defined (SSD1963_DRIVER)
// Write 18 bit color to TFT (untested)
#define tft_Write_16(C) uint8_t r = (((C) & 0xF800)>> 8); uint8_t g = (((C) & 0x07E0)>> 3); uint8_t b = (((C) & 0x001F)<< 3); \
GPIOB->BSRR = (0x00FF0000 | (uint8_t)(r)); WR_L; WR_STB; \
GPIOB->BSRR = (0x00FF0000 | (uint8_t)(g)); WR_L; WR_STB; \
GPIOB->BSRR = (0x00FF0000 | (uint8_t)(b)); WR_L; WR_STB
// 18 bit color write with swapped bytes
#define tft_Write_16S(C) uint16_t Cswap = ((C) >>8 | (C) << 8); tft_Write_16(Cswap)
#else
// Write 16 bits to TFT
#define tft_Write_16(C) GPIOB->BSRR = (0x00FF0000 | (uint8_t)(C>>8)); WR_L; WR_STB; \
GPIOB->BSRR = (0x00FF0000 | (uint8_t)(C>>0)); WR_L; WR_STB
@@ -709,6 +789,7 @@
// 16 bit write with swapped bytes
#define tft_Write_16S(C) GPIOB->BSRR = (0x00FF0000 | (uint8_t)(C>>0)); WR_L; WR_STB; \
GPIOB->BSRR = (0x00FF0000 | (uint8_t)(C>>8)); WR_L; WR_STB
#endif
#define tft_Write_32(C) tft_Write_16((uint16_t)((C)>>16)); tft_Write_16((uint16_t)(C))
@@ -801,6 +882,46 @@
D7_PIN_PORT->BSRR = D7_BSR_MASK(C); \
WR_STB
#if defined (SSD1963_DRIVER)
// Write 18 bit color to TFT (untested)
#define tft_Write_16(C) uint8_t r = (((C) & 0xF800)>> 8); uint8_t g = (((C) & 0x07E0)>> 3); uint8_t b = (((C) & 0x001F)<< 3); \
D0_PIN_PORT->BSRR = D8_BSR_MASK(r); \
D1_PIN_PORT->BSRR = D9_BSR_MASK(r); \
D2_PIN_PORT->BSRR = D10_BSR_MASK(r); \
D3_PIN_PORT->BSRR = D11_BSR_MASK(r); \
WR_L; \
D4_PIN_PORT->BSRR = D12_BSR_MASK(r); \
D5_PIN_PORT->BSRR = D13_BSR_MASK(r); \
D6_PIN_PORT->BSRR = D14_BSR_MASK(r); \
D7_PIN_PORT->BSRR = D15_BSR_MASK(r); \
WR_STB;\
D0_PIN_PORT->BSRR = D8_BSR_MASK(g); \
D1_PIN_PORT->BSRR = D9_BSR_MASK(g); \
D2_PIN_PORT->BSRR = D10_BSR_MASK(g); \
D3_PIN_PORT->BSRR = D11_BSR_MASK(g); \
WR_L; \
D4_PIN_PORT->BSRR = D12_BSR_MASK(g); \
D5_PIN_PORT->BSRR = D13_BSR_MASK(g); \
D6_PIN_PORT->BSRR = D14_BSR_MASK(g); \
D7_PIN_PORT->BSRR = D15_BSR_MASK(g); \
WR_STB;\
D0_PIN_PORT->BSRR = D0_BSR_MASK(b); \
D1_PIN_PORT->BSRR = D1_BSR_MASK(b); \
D2_PIN_PORT->BSRR = D2_BSR_MASK(b); \
D3_PIN_PORT->BSRR = D3_BSR_MASK(b); \
WR_L; \
D4_PIN_PORT->BSRR = D4_BSR_MASK(b); \
D5_PIN_PORT->BSRR = D5_BSR_MASK(b); \
D6_PIN_PORT->BSRR = D6_BSR_MASK(b); \
D7_PIN_PORT->BSRR = D7_BSR_MASK(b); \
WR_STB
// 18 bit color write with swapped bytes
#define tft_Write_16S(C) uint16_t Cswap = ((C) >>8 | (C) << 8); tft_Write_16(Cswap)
#else
// Write 16 bits to TFT
#define tft_Write_16(C) D0_PIN_PORT->BSRR = D8_BSR_MASK(C); \
D1_PIN_PORT->BSRR = D9_BSR_MASK(C); \
@@ -844,6 +965,7 @@
D6_PIN_PORT->BSRR = D14_BSR_MASK(C); \
D7_PIN_PORT->BSRR = D15_BSR_MASK(C); \
WR_STB
#endif
#define tft_Write_32(C) tft_Write_16((uint16_t)((C)>>16)); tft_Write_16((uint16_t)(C))