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
2019-01-22 18:41:31 +00:00
parent 0fdd25186a
commit 054a824eb8
16 changed files with 355 additions and 242 deletions
+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;