Are you using the the touchtest.ino sketch that is a example sketch in the teensy xpt2046 library?
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();
ts.setRotation(1);
while (!Serial && (millis() <= 1000));
}
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();
}
}
Tailor the pins to what you want. Looks like you are using PlatformIO so not sure about using that, I am using the Arduino IDE with Arduino 1.8.13 and Teensyduino 1.54-beta5. When I compile the example I get:
Code:
Opening Teensy Loader...
Sketch uses 40824 bytes (0%) of program storage space. Maximum is 8126464 bytes.
Global variables use 49844 bytes (9%) of dynamic memory, leaving 474444 bytes for local variables. Maximum is 524288 bytes.
EDIT are you added the touchscreen include to your sketch?
Code:
#include <XPT2046_Touchscreen.h>
#include <SPI.h>