Add support for ST7735 128x128 display

May not cater for 128x128 ST7735 displays with different RGB and offset
configurations.
This commit is contained in:
Bodmer committed 2017-04-16 16:13:12 +01:00
1 parent a71a98a59c
commit c2dcf25cc1
8 files changed
+50 -31

No files matched your search

+8 -23
View File
@@ -151,12 +151,12 @@ void TFT_eSPI::begin(void)
void TFT_eSPI::init(void)
{
#ifdef TFT_CS
csport = portOutputRegister(digitalPinToPort(TFT_CS));
//csport = portOutputRegister(digitalPinToPort(TFT_CS));
cspinmask = (uint32_t) digitalPinToBitMask(TFT_CS);
#endif
#ifdef TFT_DC
dcport = portOutputRegister(digitalPinToPort(TFT_DC));
//dcport = portOutputRegister(digitalPinToPort(TFT_DC));
dcpinmask = (uint32_t) digitalPinToBitMask(TFT_DC);
#endif
@@ -1476,7 +1476,7 @@ inline void TFT_eSPI::setAddrWindow(int32_t xs, int32_t ys, int32_t xe, int32_t
addr_col = 0xFFFF;
addr_row = 0xFFFF;
#if defined (ST7735_DRIVER) && (defined (ST7735_GREENTAB) || defined (ST7735_GREENTAB2) || defined (ST7735_GREENTAB3))
#ifdef CGRAM_OFFSET
xs+=colstart;
xe+=colstart;
ys+=rowstart;
@@ -1504,21 +1504,6 @@ inline void TFT_eSPI::setAddrWindow(int32_t xs, int32_t ys, int32_t xe, int32_t
SPI1CMD |= SPIBUSY;
while(SPI1CMD & SPIBUSY) {}
// This proves we can only change the byte level bit SPI register read-out order, not the actual byte order
// So we can't use this method to avoid coordinate byte order swapping!
//uint32_t x = (xs << 16) | xe;
// Swap bits in 32 bit word end for end
//x = (((x & 0xAAAAAAAA) >> 1) | ((x & 0x55555555) << 1));
//x = (((x & 0xCCCCCCCC) >> 2) | ((x & 0x33333333) << 2));
//x = (((x & 0xF0F0F0F0) >> 4) | ((x & 0x0F0F0F0F) << 4));
//x = (((x & 0xFF00FF00) >> 8) | ((x & 0x00FF00FF) << 8));
//x = (x >> 16) | (x << 16);
//SPI1W0 = x;
//SPI1C |= (SPICWBO | SPICRBO); // LSB first
//SPI1CMD |= SPIBUSY;
//while(SPI1CMD & SPIBUSY) {}
//SPI1C &= ~(SPICWBO | SPICRBO); // MSB first = default
// Row addr set
DC_C;
@@ -1690,7 +1675,7 @@ inline void TFT_eSPI::setAddrWindow(int32_t x0, int32_t y0, int32_t x1, int32_t
addr_col = 0xFFFF;
addr_row = 0xFFFF;
#if defined (ST7735_DRIVER) && (defined (ST7735_GREENTAB) || defined (ST7735_GREENTAB2) || defined (ST7735_GREENTAB3))
#ifdef CGRAM_OFFSET
x0+=colstart;
x1+=colstart;
y0+=rowstart;
@@ -1746,7 +1731,7 @@ void TFT_eSPI::readAddrWindow(int32_t xs, int32_t ys, int32_t xe, int32_t ye)
addr_col = 0xFFFF;
addr_row = 0xFFFF;
#if defined (ST7735_DRIVER) && (defined (ST7735_GREENTAB) || defined (ST7735_GREENTAB2) || defined (ST7735_GREENTAB3))
#ifdef CGRAM_OFFSET
xs+=colstart;
xe+=colstart;
ys+=rowstart;
@@ -1812,7 +1797,7 @@ void TFT_eSPI::readAddrWindow(int32_t x0, int32_t y0, int32_t x1, int32_t y1)
addr_col = 0xFFFF;
addr_row = 0xFFFF;
#if defined (ST7735_DRIVER) && (defined (ST7735_GREENTAB) || defined (ST7735_GREENTAB2) || defined (ST7735_GREENTAB3))
#ifdef CGRAM_OFFSET
x0+=colstart;
x1+=colstart;
y0+=rowstart;
@@ -1861,7 +1846,7 @@ void TFT_eSPI::drawPixel(uint32_t x, uint32_t y, uint32_t color)
// Faster range checking, possible because x and y are unsigned
if ((x >= _width) || (y >= _height)) return;
#if defined (ST7735_DRIVER) && (defined (ST7735_GREENTAB) || defined (ST7735_GREENTAB2) || defined (ST7735_GREENTAB3))
#ifdef CGRAM_OFFSET
x+=colstart;
y+=rowstart;
#endif
@@ -2043,7 +2028,7 @@ void TFT_eSPI::drawPixel(uint32_t x, uint32_t y, uint32_t color)
if ((x >= _width) || (y >= _height)) return;
spi_begin();
#if defined (ST7735_DRIVER) && (defined (ST7735_GREENTAB) || defined (ST7735_GREENTAB2) || defined (ST7735_GREENTAB3))
#ifdef CGRAM_OFFSET
x+=colstart;
y+=rowstart;
#endif