PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TouchTest.ino 780B

3 years ago
123456789101112131415161718192021222324252627282930313233
  1. #include <XPT2046_Touchscreen.h>
  2. #include <SPI.h>
  3. #define CS_PIN 8
  4. // MOSI=11, MISO=12, SCK=13
  5. //XPT2046_Touchscreen ts(CS_PIN);
  6. #define TIRQ_PIN 2
  7. //XPT2046_Touchscreen ts(CS_PIN); // Param 2 - NULL - No interrupts
  8. //XPT2046_Touchscreen ts(CS_PIN, 255); // Param 2 - 255 - No interrupts
  9. XPT2046_Touchscreen ts(CS_PIN, TIRQ_PIN); // Param 2 - Touch IRQ Pin - interrupt enabled polling
  10. void setup() {
  11. Serial.begin(38400);
  12. ts.begin();
  13. ts.setRotation(1);
  14. while (!Serial && (millis() <= 1000));
  15. }
  16. void loop() {
  17. if (ts.touched()) {
  18. TS_Point p = ts.getPoint();
  19. Serial.print("Pressure = ");
  20. Serial.print(p.z);
  21. Serial.print(", x = ");
  22. Serial.print(p.x);
  23. Serial.print(", y = ");
  24. Serial.print(p.y);
  25. delay(30);
  26. Serial.println();
  27. }
  28. }