From d02fe55c461f4759f35aabfada214857fe4e42a7 Mon Sep 17 00:00:00 2001 From: Bodmer Date: Thu, 2 Jan 2020 11:53:50 +0000 Subject: [PATCH] Fix #503 The s60sc Adafruit_Touch library fork for the ESP32 parallel mode uses the TFT_WR pin as an analogue input to read the screen resistance. The TFT_eSPI library kept TFT_CS low permanently for performance reasons, but when used with the touch library a low analogue value on the TFT_WR pin will write spurious data to the display. This change toggle TFT_CS so it is only low during TFT parallel bus writes. The performance reduction is small. --- TFT_eSPI.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/TFT_eSPI.h b/TFT_eSPI.h index e6f85e9..84a8d1f 100644 --- a/TFT_eSPI.h +++ b/TFT_eSPI.h @@ -190,8 +190,16 @@ #define CS_H digitalWrite(TFT_CS, HIGH) #elif defined (ESP32) #if defined (ESP32_PARALLEL) - #define CS_L // The TFT CS is set permanently low during init() - #define CS_H + #if TFT_CS >= 32 + #define CS_L GPIO.out1_w1tc.val = (1 << (TFT_CS - 32)) + #define CS_H GPIO.out1_w1ts.val = (1 << (TFT_CS - 32)) + #elif TFT_CS >= 0 + #define CS_L GPIO.out_w1tc = (1 << TFT_CS) + #define CS_H GPIO.out_w1ts = (1 << TFT_CS) + #else + #define CS_L + #define CS_H + #endif #else #if TFT_CS >= 32 #ifdef RPI_ILI9486_DRIVER // RPi display needs a slower CS change