divabanana
Member
I have a 2.4" ILI9341 screen with an XPT2046 touch controller.
This is the screen: http://www.aliexpress.com/item/240x...2278769615.html?spm=2114.13010608.0.78.HIIx8v
The screen is wired up to a Teensy 3.2 exactly as per the table at https://www.pjrc.com/store/display_ili9341_touch.html and I am running Teensyduino 1.29-beta2
The screen runs graphics fine - the graphicstest and DemoSauce examples work perfectly.
However, I cannot for the life of me get the touch to work at all.
Running the standard ILI9341Test sketch from the XPT2046_Touchscreen folder, all I get is the following output
Running the TouchTest sketch from the XPT2046_Touchscreen folder I get
I have tried 3 different screens with the same result and I have tried on a couple of different breadboards again with the same result.
Does anybody have any ideas as to what I am doing wrong?!
The ILI9341Test sketch code is
The TouchTest sketch code is
This is the screen: http://www.aliexpress.com/item/240x...2278769615.html?spm=2114.13010608.0.78.HIIx8v
The screen is wired up to a Teensy 3.2 exactly as per the table at https://www.pjrc.com/store/display_ili9341_touch.html and I am running Teensyduino 1.29-beta2
The screen runs graphics fine - the graphicstest and DemoSauce examples work perfectly.
However, I cannot for the life of me get the touch to work at all.
Running the standard ILI9341Test sketch from the XPT2046_Touchscreen folder, all I get is the following output
Code:
...
, x = 0, y = 0
, x = 0, y = 0
, x = 0, y = 0
, x = 0, y = 0
...
Running the TouchTest sketch from the XPT2046_Touchscreen folder I get
Code:
...
Pressure = 4095, x = 0, y = 0
Pressure = 4095, x = 0, y = 0
Pressure = 4095, x = 0, y = 0
Pressure = 4095, x = 0, y = 0
...
I have tried 3 different screens with the same result and I have tried on a couple of different breadboards again with the same result.
Does anybody have any ideas as to what I am doing wrong?!
The ILI9341Test sketch code is
Code:
#include <ILI9341_t3.h>
#include <font_Arial.h> // from ILI9341_t3
#include <XPT2046_Touchscreen.h>
#include <SPI.h>
#define CS_PIN 8
#define TFT_DC 9
#define TFT_CS 10
// MOSI=11, MISO=12, SCK=13
XPT2046_Touchscreen ts(CS_PIN);
#define TIRQ_PIN 2
//XPT2046_Touchscreen ts(CS_PIN); // Param 2 - NULL - No interrupts
//XPT2046_Touchscreen ts(CS_PIN, 255); // Param 2 - 255 - No interrupts
//XPT2046_Touchscreen ts(CS_PIN, TIRQ_PIN); // Param 2 - Touch IRQ Pin - interrupt enabled polling
ILI9341_t3 tft = ILI9341_t3(TFT_CS, TFT_DC);
void setup() {
Serial.begin(38400);
tft.begin();
tft.setRotation(1);
tft.fillScreen(ILI9341_BLACK);
ts.begin();
while (!Serial && (millis() <= 1000));
}
boolean wastouched = true;
void loop() {
boolean istouched = ts.touched();
if (istouched) {
TS_Point p = ts.getPoint();
if (!wastouched) {
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_YELLOW);
tft.setFont(Arial_60);
tft.setCursor(60, 80);
tft.print("Touch");
}
tft.fillRect(100, 150, 140, 60, ILI9341_BLACK);
tft.setTextColor(ILI9341_GREEN);
tft.setFont(Arial_24);
tft.setCursor(100, 150);
tft.print("X = ");
tft.print(p.x);
tft.setCursor(100, 180);
tft.print("Y = ");
tft.print(p.y);
Serial.print(", x = ");
Serial.print(p.x);
Serial.print(", y = ");
Serial.println(p.y);
} else {
if (wastouched) {
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_RED);
tft.setFont(Arial_48);
tft.setCursor(120, 50);
tft.print("No");
tft.setCursor(80, 120);
tft.print("Touch");
}
Serial.println("no touch");
}
wastouched = istouched;
delay(100);
}
The TouchTest sketch code is
Code:
#include <XPT2046_Touchscreen.h>
#include <SPI.h>
#define CS_PIN 8
// MOSI=11, MISO=12, SCK=13
//XPT2046_Touchscreen ts(CS_PIN);
#define TIRQ_PIN 2
//XPT2046_Touchscreen ts(CS_PIN); // Param 2 - NULL - No interrupts
//XPT2046_Touchscreen ts(CS_PIN, 255); // Param 2 - 255 - No interrupts
XPT2046_Touchscreen ts(CS_PIN, TIRQ_PIN); // Param 2 - Touch IRQ Pin - interrupt enabled polling
void setup() {
Serial.begin(38400);
ts.begin();
while (!Serial && (millis() <= 1000));
}
void loopB() {
TS_Point p = ts.getPoint();
Serial.print("Pressure = ");
Serial.print(p.z);
if (ts.touched()) {
Serial.print(", x = ");
Serial.print(p.x);
Serial.print(", y = ");
Serial.print(p.y);
}
Serial.println();
// delay(100);
delay(30);
}
void loop() {
if (ts.touched()) {
TS_Point p = ts.getPoint();
Serial.print("Pressure = ");
Serial.print(p.z);
Serial.print(", x = ");
Serial.print(p.x);
Serial.print(", y = ");
Serial.print(p.y);
delay(30);
Serial.println();
}
}