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!
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:");
}
}