PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

61 行
1.3KB

  1. // Touch screen library with X Y and Z (pressure) readings as well
  2. // as oversampling to avoid 'bouncing'
  3. // (c) ladyada / adafruit
  4. // Code under MIT License
  5. #ifndef _ADAFRUIT_TOUCHSCREEN_H_
  6. #define _ADAFRUIT_TOUCHSCREEN_H_
  7. #include <stdint.h>
  8. #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega32U4__) || defined(TEENSYDUINO) || defined(__AVR_ATmega2560__)
  9. #if defined(__IMXRT1052__) || defined(__IMXRT1062__)
  10. typedef volatile uint32_t RwReg;
  11. #else
  12. typedef volatile uint8_t RwReg;
  13. #endif
  14. #endif
  15. #if defined(ARDUINO_STM32_FEATHER)
  16. typedef volatile uint32 RwReg;
  17. #endif
  18. #if defined(ARDUINO_FEATHER52) || defined(ESP32)
  19. typedef volatile uint32_t RwReg;
  20. #endif
  21. #if defined (__AVR__) || defined(TEENSYDUINO) || defined(ARDUINO_ARCH_SAMD)
  22. #define USE_FAST_PINIO
  23. #endif
  24. class TSPoint {
  25. public:
  26. TSPoint(void);
  27. TSPoint(int16_t x, int16_t y, int16_t z);
  28. bool operator==(TSPoint);
  29. bool operator!=(TSPoint);
  30. int16_t x, y, z;
  31. };
  32. class TouchScreen {
  33. public:
  34. TouchScreen(uint8_t xp, uint8_t yp, uint8_t xm, uint8_t ym, uint16_t rx);
  35. bool isTouching(void);
  36. uint16_t pressure(void);
  37. int readTouchY();
  38. int readTouchX();
  39. TSPoint getPoint();
  40. int16_t pressureThreshhold;
  41. private:
  42. uint8_t _yp, _ym, _xm, _xp;
  43. uint16_t _rxplate;
  44. volatile RwReg *xp_port, *yp_port, *xm_port, *ym_port;
  45. RwReg xp_pin, xm_pin, yp_pin, ym_pin;
  46. };
  47. #endif