TouchScreen conflict with TFT ILI93141

McTime

Member
Hi, I'm trying to use the resisitive touch of the Adafruit ILI9341 Display. My project is on a good way so I got Audio and display working nicely. Now I wanted to add some touch functionality.
However, as soon as the TouchScreen.getPoint() function is called, the display goes blank! Yes, just white and nothing else.
See my test code below. If I comment the line "p = ts.getPoint();" the display shows correct behavior.

Any idea what happens here?
Thanks!

Code:
#include "ILI9341_t3.h"
#define TFT_CS 10
#define TFT_DC 9

ILI9341_t3 tft = ILI9341_t3 (TFT_CS, TFT_DC);

// touch controller
#include "TouchScreen.h"
#define YP A10  // must be an analog pin, use "An" notation!
#define XM A12  // must be an analog pin, use "An" notation!
#define YM 30   // can be a digital pin
#define XP 28   // can be a digital pin
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 400);
TSPoint p; 

void setup() {
  tft.begin();
  tft.setRotation(3);
  tft.fillScreen(ILI9341_GREEN);
  Serial.println("Ready");
  screen();
}

void screen() {
  tft.drawRect(0, 8, tft.width(), 167, ILI9341_WHITE);
  tft.setCursor(2, 10);
  tft.setTextColor(ILI9341_YELLOW); 
  tft.setTextSize(1);
}
void loop() {
  delay(120);
  
  p = ts.getPoint();
  if (p.z > ts.pressureThreshhold*2) {
     Serial.print("X = "); Serial.print(p.x); 
     Serial.print("\tY = "); Serial.print(p.y); 
     Serial.print("\tPressure = "); Serial.println(p.z);
     tft.fillRect(2, 10, 50, 10, ILI9341_BLUE); 
     tft.setCursor(2, 10);
     tft.print("Btn:"); // tft.print("p.x");  tft.print("p.y");  
  }
  else {
     tft.setCursor(2, 10);
     tft.print("Waiting:");
  }
}
 
Is the touch screen resistive or capacitive touch? Capacitive is an i2c device according to the link. Oher notes there ...

Do any of the driver examples work properly?

If Touch is SPI see this and verify both halves of the display & Touch are tri-stated: pjrc.com/better-spi-bus-design-in-3-steps/
> not all are and that would require adding that or using a second SPI bus.
 
It looks like it should work. As mentioned, it is the resistive display, which matches the code, including the library.

Looks like all of the pins used are not the SPI pins, so again it should work.
I assume display is like: https://www.adafruit.com/product/1770

Are you using the version of TouchScreen library that ships with Teensyduino or a different version?
You can tell by what libraries it says it used at the end of a build.

Might help to see a picture of the wiring. For example, the pins you are using are on the bottom of the T4, so I would double check there
are no shorts from those pins to the test pads that are near them on the bottom.

If I get a chance, I will see if I can find the one I purchased back in 2014... But will probably try with T4.1 as simpler to get to those pins
 
Quick update: I hooked up T4.1 as I mentioned to display using your pin numbers.

And it appears to work fine.

So I would double check you wiring.

Also sometimes in past had issues with loose wires, when you press on screen it wiggles wire, like gnd or and breaks connection.
 
Also sometimes in past had issues with loose wires, when you press on screen it wiggles wire, like gnd or and breaks connection.

Thanks for trying out, KurtE.

I rewired just the board to the display and removed anything else. It seemed to work, but after about 10 touches I again get a blank display.

So I checked the display and it appears the display is not mounted correctly on the breakout board, instead it stands off about 1mm on the side of the flex cables. That seemed to cause the connection to the breakoutboard to come loose. I reseated the flex cable to its connector and now no blank display anymore!


Does anybody has experience with a better quality display with the same interfacing than this made by Adafruit? Thanks!
 
Does anybody has experience with a better quality display with the same interfacing than this made by Adafruit? Thanks!

I previously used a closely related <Adafruit resistive touchscreen display> in several of my projects, usually with good success. However, I have now switched to exclusively using the <PJRC Color 320x240 TFT Touchscreen> in my projects where a 3.2" TFT is needed. I am extremely pleased with both the performance & the ease of incorporating this particular touchscreen into my projects. The built-in XPT2046 touch controller is very easy to work with, & the Teensy ILI9341_t3n display library includes some really nice features, particularly framebuffer support. I highly recommend that you take a look at using this PJRC Color 320x240 TFT Touchscreen in place of the Adafruit breakout that is currently giving you some trouble. There may be some minor differences in using the Adafruit library vs. the Teensy library, but any effort to make the changeover will be well worth the future ease of use & long-term reliability.

Mark J Culross
KD5RXT
 
Back
Top