I have a problem compiling the Touch_Controller_Demo.
Am using:
TFT_eSPI 2.3.70
Arduino 1.8.15
ESP32 core 1.0.6
In User_Setup.h i have uncommented #define TOUCH_CS 21
I have exactly the same Wemos Uno-shaped board that is shown on the Bodmer libraries' git page. The display is one of these https://www.ebay.com.au/itm/193738906640
Though, my issue is with compiling, not running the code.
C:\Users\emuey\OneDrive\Documents\Arduino\libraries\TFT_eSPI\Extensions/Touch.cpp: In member function 'void TFT_eSPI::begin_touch_read_write()':
C:\Users\emuey\OneDrive\Documents\Arduino\libraries\TFT_eSPI\Extensions/Touch.cpp:22:34: error: 'spi' was not declared in this scope
if (locked) {locked = false; spi.beginTransaction(SPISettings(SPI_TOUCH_FREQUENCY, MSBFIRST, SPI_MODE0));}
^
C:\Users\emuey\OneDrive\Documents\Arduino\libraries\TFT_eSPI\Extensions/Touch.cpp: In member function 'void TFT_eSPI::end_touch_read_write()':
C:\Users\emuey\OneDrive\Documents\Arduino\libraries\TFT_eSPI\Extensions/Touch.cpp:37:54: error: 'spi' was not declared in this scope
if(!inTransaction) {if (!locked) {locked = true; spi.endTransaction();}}
^
C:\Users\emuey\OneDrive\Documents\Arduino\libraries\TFT_eSPI\Extensions/Touch.cpp: In member function 'uint8_t TFT_eSPI::getTouchRaw(uint16_t*, uint16_t*)':
C:\Users\emuey\OneDrive\Documents\Arduino\libraries\TFT_eSPI\Extensions/Touch.cpp:61:3: error: 'spi' was not declared in this scope
spi.transfer(0xd0); // Start new YP conversion
^
C:\Users\emuey\OneDrive\Documents\Arduino\libraries\TFT_eSPI\Extensions/Touch.cpp: In member function 'uint16_t TFT_eSPI::getTouchRawZ()':
C:\Users\emuey\OneDrive\Documents\Arduino\libraries\TFT_eSPI\Extensions/Touch.cpp:104:3: error: 'spi' was not declared in this scope
spi.transfer(0xb0); // Start new Z1 conversion
He has posted a link to the display.
And has attached his User_Setup.h
Solution:
Select the Setup16_ILI9488_Parallel.h from the example User_Setups.
Do not define TOUCH_CS. This is for displays with a XPT2046 Touch controller chip.
Run all of Bodmer's example sketches.
Report back with any problems. Quote example by name. Setup by name.
If you have a custom Setup, attach your User_Setup file.
Incidentally, your Ebay link says ILI9488, R61581, ILI9481, HX8357D. So you might need to plug your display into a Uno and run LCD_ID_readreg.ino from MCUFRIEND_kbv library.
I don't like guesswork. If you are lucky the display came in an antistatic bag with a label that says ILI9488.
I have been trying to make posts complete and easy to read, including anything that might be relevant. If there's any specific thing that I'm doing wrong please tell me and I'll change it.
I have followed David's directions to include the different header and now get a different error
C:\Users\emuey\OneDrive\Documents\Arduino\libraries\TFT_eSPI\examples\480 x 320\Touch_Controller_Demo\Touch_Controller_Demo.ino: In function 'void setup()':
Touch_Controller_Demo:43:9: error: 'class TFT_eSPI' has no member named 'setTouch'
tft.setTouch(calibrationData);
^
Touch_Controller_Demo:46:9: error: 'class TFT_eSPI' has no member named 'calibrateTouch'
tft.calibrateTouch(calibrationData, TFT_WHITE, TFT_RED, 15);
^
C:\Users\emuey\OneDrive\Documents\Arduino\libraries\TFT_eSPI\examples\480 x 320\Touch_Controller_Demo\Touch_Controller_Demo.ino: In function 'void loop()':
Touch_Controller_Demo:63:11: error: 'class TFT_eSPI' has no member named 'getTouch'
if (tft.getTouch(&x, &y)) {
I hope this method of text quoting is OK.
The display does seem to be an ILI9488. I have successfully compiled and run all of Bodmer's examples except those requiring touch.
That is just fine. It identifies the example sketch.
The simple answer is : Bodmer supports XPT2046 Touch Controller chip.
If you want to read a bare resistive panel you need to use a library like TouchScreen.h which will have a constructor that specifies XM, XP, YM, YP pins. e.g. from Adafruit_Touchscreen.h
class TouchScreen {
public:
/**
* @brief Construct a new Touch Screen object
*
* @param xp X+ pin. Must be an analog pin
* @param yp Y+ pin. Must be an analog pin
* @param xm X- pin. Can be a digital pin
* @param ym Y- pin. Can be a digital pin
* @param rx The resistance in ohms between X+ and X- to calibrate pressure
* sensing
*/
TouchScreen(uint8_t xp, uint8_t yp, uint8_t xm, uint8_t ym, uint16_t rx);
The other thing to note is : XM, XP, YM, YP pins are shared with the TFT controller. Which means that you must restore XM, YP back to OUTPUT after any call to Touchscreen functions.
Yes, I know that a Touchscreen library could do this but most do not.
I don't have much experience with TFT_eSPI parallel screens.
To answer the questions first. The screen came in an antistatic bag with no labels, it doesn't appear to be damaged and performs all the other examples in the Bodmer library perfectly and quite quickly.
So, to get the TouchScreenDemo sketch working I would need to include, say, the Adafruit TouchScreen header?
Yes I should have looked before I leaped into this, it's become very frustrating. I truly respect people in this forum spending time to try and sort out problems like this, that degree of patience is amazing.
If you have a Uno / Mega2560 you can run the MCUFRIEND_kbv diagnostic sketches. e.g. TouchScreen_Calibr_native.ino
This will detect the Touch pins and calibrate too.
If you run TouchScreen_Calibr_native.ino on the ESP32 it can calibrate but it can't diagnose the pins.
Alternatively you use a DMM. Measure resistance between LCD_D7 and LCD_WR. And between LCD_D6 and LCD_RS. The larger resistance means YM, YP. The smaller is XP,XM