Add ESP32 VSPI or HSPI port option + others

If the VSPI port is in use and pins are not accessible (e.g. TTGO
T-Beam)
then add or uncomment the following line in the setup header file:
//#define USE_HSPI_PORT

Minor performance tweaks for ESP32 to minimise the occurence of the slow
transaction overhead.

setAddrWindow now takes xstart, ystart, width and height as inputs

Multi-sample raw touch x and y for noisy displays

Example update for setAddrWindow change compatibility
This commit is contained in:
Bodmer committed 2019-01-22 18:41:31 +00:00
1 parent 0fdd25186a
commit 054a824eb8
16 files changed
+355 -242

No files matched your search

+4 -1
View File
@@ -441,6 +441,8 @@ void TFT_eSPI::drawGlyph(uint16_t code)
int16_t cy = cursor_y + gFont.maxAscent - gdY[gNum];
int16_t cx = cursor_x + gdX[gNum];
startWrite(); // Avoid slow ESP32 transaction overhead for every pixel
for (int y = 0; y < gHeight[gNum]; y++)
{
fontFile.read(pbuffer, gWidth[gNum]); //<//
@@ -480,7 +482,8 @@ void TFT_eSPI::drawGlyph(uint16_t code)
drawRect(cursor_x, cursor_y + gFont.maxAscent - gFont.ascent, gFont.spaceWidth, gFont.ascent, fg);
cursor_x += gFont.spaceWidth + 1;
}
endWrite();
}
/***************************************************************************************
+15 -9
View File
@@ -301,7 +301,8 @@ bool TFT_eSprite::pushRotated(int16_t angle, int32_t transp)
if (max_x > _tft->width()) max_x = _tft->width();
if (max_y > _tft->height()) max_y = _tft->height();
_tft->startWrite();
_tft->startWrite(); // ESP32: avoid transaction overhead for every tft pixel
// Scan destination bounding box and fetch transformed pixels from source Sprite
for (int32_t x = min_x; x <= max_x; x++) {
int32_t xt = x - _tft->_xpivot;
@@ -325,7 +326,8 @@ bool TFT_eSprite::pushRotated(int16_t angle, int32_t transp)
else if (column_drawn) y = max_y; // Skip remaining column pixels
}
}
_tft->endWrite();
_tft->endWrite(); // ESP32: end transaction
return true;
}
@@ -465,7 +467,6 @@ void TFT_eSprite::pushSprite(int32_t x, int32_t y)
if (_bpp == 16) _tft->pushImage(x, y, _iwidth, _iheight, _img );
else _tft->pushImage(x, y, _dwidth, _dheight, _img8, (bool)(_bpp == 8));
}
@@ -562,7 +563,7 @@ void TFT_eSprite::pushImage(int32_t x, int32_t y, uint32_t w, uint32_t h, uint1
if (xs + w >= _iwidth) ws = _iwidth - xs;
if (ys + h >= _iheight) hs = _iheight - ys;
if (_bpp == 16)
if (_bpp == 16) // Plot a 16 bpp image into a 16 bpp Sprite
{
for (uint32_t yp = yo; yp < yo + hs; yp++)
{
@@ -577,7 +578,7 @@ void TFT_eSprite::pushImage(int32_t x, int32_t y, uint32_t w, uint32_t h, uint1
ys++;
}
}
else if (_bpp == 8)
else if (_bpp == 8) // Plot a 16 bpp image into a 8 bpp Sprite
{
for (uint32_t yp = yo; yp < yo + hs; yp++)
{
@@ -613,7 +614,7 @@ void TFT_eSprite::pushImage(int32_t x, int32_t y, uint32_t w, uint32_t h, uint1
x = y;
y = _dheight - tx - 1;
}
// Plot a 1bpp image into a 1bpp Sprite
uint8_t* pdata = (uint8_t* ) data;
uint32_t ww = (w+7) & 0xFFF8;
for (int32_t yp = 0; yp<h; yp++)
@@ -636,6 +637,10 @@ void TFT_eSprite::pushImage(int32_t x, int32_t y, uint32_t w, uint32_t h, uint1
*************************************************************************************x*/
void TFT_eSprite::pushImage(int32_t x, int32_t y, uint32_t w, uint32_t h, const uint16_t *data)
{
#ifdef ESP32
pushImage(x, y, w, h, (uint16_t*) data);
#else
// Partitioned memory FLASH processor
if ((x >= _iwidth) || (y >= _iheight) || (w == 0) || (h == 0) || !_created) return;
if ((x + (int32_t)w < 0) || (y + (int32_t)h < 0)) return;
@@ -654,7 +659,7 @@ void TFT_eSprite::pushImage(int32_t x, int32_t y, uint32_t w, uint32_t h, const
if (xs + w >= _iwidth) ws = _iwidth - xs;
if (ys + h >= _iheight) hs = _iheight - ys;
if (_bpp == 16)
if (_bpp == 16) // Plot a 16 bpp image into a 16 bpp Sprite
{
for (uint32_t yp = yo; yp < yo + hs; yp++)
{
@@ -670,7 +675,7 @@ void TFT_eSprite::pushImage(int32_t x, int32_t y, uint32_t w, uint32_t h, const
}
}
else if (_bpp == 8)
else if (_bpp == 8) // Plot a 16 bpp image into a 8 bpp Sprite
{
for (uint32_t yp = yo; yp < yo + hs; yp++)
{
@@ -706,7 +711,7 @@ void TFT_eSprite::pushImage(int32_t x, int32_t y, uint32_t w, uint32_t h, const
x = y;
y = _dheight - tx - 1;
}
// Plot a 1bpp image into a 1bpp Sprite
const uint8_t* pdata = (const uint8_t* ) data;
uint32_t ww = (w+7) & 0xFFF8;
for (int32_t yp = 0; yp<h; yp++)
@@ -721,6 +726,7 @@ void TFT_eSprite::pushImage(int32_t x, int32_t y, uint32_t w, uint32_t h, const
}
}
}
#endif // if ESP32 else ESP8266 check
}
+24 -10
View File
@@ -22,18 +22,32 @@ uint8_t TFT_eSPI::getTouchRaw(uint16_t *x, uint16_t *y){
T_CS_L;
// Start YP sample request for x position
SPI.transfer(0xd0); // Start new YP conversion
tmp = SPI.transfer(0); // Read first 8 bits
// Start YP sample request for x position, read 4 times and keep last sample
spi.transfer(0xd0); // Start new YP conversion
spi.transfer(0); // Read first 8 bits
spi.transfer(0xd0); // Read last 8 bits and start new YP conversion
spi.transfer(0); // Read first 8 bits
spi.transfer(0xd0); // Read last 8 bits and start new YP conversion
spi.transfer(0); // Read first 8 bits
spi.transfer(0xd0); // Read last 8 bits and start new YP conversion
tmp = spi.transfer(0); // Read first 8 bits
tmp = tmp <<5;
tmp |= 0x1f & (SPI.transfer(0x90)>>3); // Read last 8 bits and start new XP conversion
tmp |= 0x1f & (spi.transfer(0x90)>>3); // Read last 8 bits and start new XP conversion
*x = tmp;
// Start XP sample request for y position
tmp = SPI.transfer(0); // Read first 8 bits
// Start XP sample request for y position, read 4 times and keep last sample
spi.transfer(0); // Read first 8 bits
spi.transfer(0x90); // Read last 8 bits and start new XP conversion
spi.transfer(0); // Read first 8 bits
spi.transfer(0x90); // Read last 8 bits and start new XP conversion
spi.transfer(0); // Read first 8 bits
spi.transfer(0x90); // Read last 8 bits and start new XP conversion
tmp = spi.transfer(0); // Read first 8 bits
tmp = tmp <<5;
tmp |= 0x1f & (SPI.transfer(0)>>3); // Read last 8 bits
tmp |= 0x1f & (spi.transfer(0)>>3); // Read last 8 bits
*y = tmp;
@@ -57,9 +71,9 @@ uint16_t TFT_eSPI::getTouchRawZ(void){
// Calculate Z
int16_t tz = 0xFFF;
SPI.transfer(0xb0); // Start new Z1 conversion
tz += SPI.transfer16(0xc0) >> 3; // Read Z1 and start Z2 conversion
tz -= SPI.transfer16(0x00) >> 3; // Read Z2
spi.transfer(0xb0); // Start new Z1 conversion
tz += spi.transfer16(0xc0) >> 3; // Read Z1 and start Z2 conversion
tz -= spi.transfer16(0x00) >> 3; // Read Z2
T_CS_H;