#include <ILI9341_t3.h>
#include <font_Arial.h> // from ILI9341_t3
#include <XPT2046_Touchscreen.h>
#include <SPI.h>
#define CS_PIN 26
#define TFT_DC 20
#define TFT_CS 21
// MOSI=11, MISO=12, SCK=13
//XPT2046_Touchscreen ts(8);
#define TIRQ_PIN 8
//XPT2046_Touchscreen ts(CS_PIN); // Param 2 - NULL - No interrupts
XPT2046_Touchscreen ts(8 ); // 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,255,28,27,39);
void setup() {
Serial.begin(38400);
tft.begin();
tft.setRotation(1);
tft.fillScreen(ILI9341_BLACK);
ts.begin();
ts.setRotation(1);
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);
}
...
#define CS_TS 8
#define TIRQ_PIN 2
XPT2046_Touchscreen ts(CS_TS, TIRQ_PIN); // Param 2 - Touch IRQ Pin - interrupt enabled polling
...
#define
void setup() {
Serial.begin(38400);
pinMode(CS_TS, OUTPUT); // initialize it as output
digitalWrite(CS_TS, HIGH); // make sure TS is not selected before tft begin...
tft.begin();
tft.setRotation(1);
tft.fillScreen(ILI9341_BLACK);
ts.begin();
ts.setRotation(1);
while (!Serial && (millis() <= 1000));
}
Indeed I had the original sketch working with default SPI pins and without the audio-board. I havent seen#29 mentioned as Touch_CS, ill see if pin 8 stays high when i start the sketch
As stated in #111 it was working a fewdays ago when I started to mount this TFT. I first tried to get the TFT and XPT on a breadboard working before adding it to my project. As it worked I added it to my project, then had trouble reading the XPT and I still do. For the moment this is not limiting me very much so I am moving on with my projectHave you ever seen that touch work with the XPT2046 library? That board is not the same format as the PJRC with linear pins on one end. Can you breadboard it to another Teensy?
.
#define PIN 8
void setup() {
pinMode(PIN, OUTPUT);
}
void loop() {
digitalWrite(PIN, !digitalRead(PIN));
delay(500);
}
int current_pin = 13;
int next_pin_number = 0;
void setup() {
// Blink any pin. Note: I put pin 13 as input to see if we can
// jumper to it to see if we can find the pin...
while (!Serial && millis() < 5000);
Serial.begin(115200);
delay (250);
Serial.println("Find Pin by blinking");
Serial.println("Enter pin number to blink");
pinMode(13, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if (Serial.available()) {
int ch;
while ((ch = Serial.read()) != -1) {
if ((ch >='0') && (ch <= '9')) {
next_pin_number = next_pin_number * 10 + (ch-'0');
} else {
if (next_pin_number != 0) {
digitalWrite(current_pin, LOW); // turn the previous pin to low...
current_pin = next_pin_number;
pinMode(current_pin, OUTPUT);
if (current_pin != 13)
pinMode(13, INPUT);
digitalWrite(current_pin, HIGH);
next_pin_number = 0; // setup to enter next pin
Serial.printf("Now Blinking pin %d\n\r", current_pin);
}
}
}
} else {
digitalWrite(current_pin, !digitalRead(current_pin));
delay(250);
}
}