TFT_eSPI touch demo compile error

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


Any help appreciated.

User_Setup.h (15.7 KB)

Why do users choose to ignore the advice about posting code ?

The easier you make it to read and copy your code the more likely it is that you will get help

Please follow the advice given in the link below when posting code , use code tags and post the code here

Actually, the boy has done well !!

He has posted a link to the display.
And has attached his User_Setup.h

Solution:

  1. Select the Setup16_ILI9488_Parallel.h from the example User_Setups.

  2. Do not define TOUCH_CS. This is for displays with a XPT2046 Touch controller chip.

  3. Run all of Bodmer's example sketches.

  4. Report back with any problems. Quote example by name. Setup by name.

  5. 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.

David.

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.

Silly questions:

  1. did the screen come in an antistatic bag ?
  2. did the bag have a printed label ?
  3. was the screen glass cracked or broken ?

David.

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.

I'm now quite confused about its touch ability. It is sold as a touchscreen but does not have convenient X+/X- pins, see attached photo or another example from eBay which has the same pinout 3.5" inch TFT LCD Touch Screen Display Board 480x320 For Arduino UNO R3 Mega2560 | eBay (there's a photo showing the pin side of the board.)

If as David has said "XM, XP, YM, YP pins are shared with the TFT controller" how am I to know which they are shared with? The Adafruit page GitHub - s60sc/Adafruit_TouchScreen: Arduino library for 4-wire resistive touchscreens seems to offering a way to wire and drive this, I'll try it but am cautious about damaging something.

I found some more information over at Parallel TFT 3.5" Touch Screen on ESP32 that really leads to more questions.

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

David.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.