PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

TouchTestIRQ.ino 967B

il y a 3 ans
12345678910111213141516171819202122232425262728293031323334353637
  1. #include <XPT2046_Touchscreen.h>
  2. #include <SPI.h>
  3. #define CS_PIN 8
  4. // MOSI=11, MISO=12, SCK=13
  5. // The TIRQ interrupt signal must be used for this example.
  6. #define TIRQ_PIN 2
  7. XPT2046_Touchscreen ts(CS_PIN, TIRQ_PIN); // Param 2 - Touch IRQ Pin - interrupt enabled polling
  8. void setup() {
  9. Serial.begin(38400);
  10. ts.begin();
  11. ts.setRotation(1);
  12. while (!Serial && (millis() <= 1000));
  13. }
  14. void loop() {
  15. // tirqTouched() is much faster than touched(). For projects where other SPI chips
  16. // or other time sensitive tasks are added to loop(), using tirqTouched() can greatly
  17. // reduce the delay added to loop() when the screen has not been touched.
  18. if (ts.tirqTouched()) {
  19. if (ts.touched()) {
  20. TS_Point p = ts.getPoint();
  21. Serial.print("Pressure = ");
  22. Serial.print(p.z);
  23. Serial.print(", x = ");
  24. Serial.print(p.x);
  25. Serial.print(", y = ");
  26. Serial.print(p.y);
  27. delay(30);
  28. Serial.println();
  29. }
  30. }
  31. }