No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 
 

38 líneas
2.0 KiB

  1. // Coded by Bodmer 10/2/18, see license in root directory.
  2. // This is part of the TFT_eSPI class and is associated with the Touch Screen handlers
  3. public:
  4. // Get raw x,y ADC values from touch controller
  5. uint8_t getTouchRaw(uint16_t *x, uint16_t *y);
  6. // Get raw z (i.e. pressure) ADC value from touch controller
  7. uint16_t getTouchRawZ(void);
  8. // Convert raw x,y values to calibrated and correctly rotated screen coordinates
  9. void convertRawXY(uint16_t *x, uint16_t *y);
  10. // Get the screen touch coordinates, returns true if screen has been touched
  11. // if the touch cordinates are off screen then x and y are not updated
  12. uint8_t getTouch(uint16_t *x, uint16_t *y, uint16_t threshold = 600);
  13. // Run screen calibration and test, report calibration values to the serial port
  14. void calibrateTouch(uint16_t *data, uint32_t color_fg, uint32_t color_bg, uint8_t size);
  15. // Set the screen calibration values
  16. void setTouch(uint16_t *data);
  17. private:
  18. // Legacy support only - deprecated TODO: delete
  19. void spi_begin_touch();
  20. void spi_end_touch();
  21. // Handlers for the touch controller bus settings
  22. inline void begin_touch_read_write() __attribute__((always_inline));
  23. inline void end_touch_read_write() __attribute__((always_inline));
  24. // Private function to validate a touch, allow settle time and reduce spurious coordinates
  25. uint8_t validTouch(uint16_t *x, uint16_t *y, uint16_t threshold = 600);
  26. // Initialise with example calibration values so processor does not crash if setTouch() not called in setup()
  27. uint16_t touchCalibration_x0 = 300, touchCalibration_x1 = 3600, touchCalibration_y0 = 300, touchCalibration_y1 = 3600;
  28. uint8_t touchCalibration_rotate = 1, touchCalibration_invert_x = 2, touchCalibration_invert_y = 0;
  29. uint32_t _pressTime; // Press and hold time-out
  30. uint16_t _pressX, _pressY; // For future use (last sampled calibrated coordinates)