13 void process(
int x,
int y,
bool touched);
19 void set_area(int16_t x_min, int16_t x_max, int16_t y_min, int16_t y_max) {
26 void touch(int16_t x, int16_t y);
30 int16_t x_min_, x_max_,
y_min_, y_max_;
35 public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW,
36 spi::CLOCK_PHASE_LEADING, spi::DATA_RATE_2MHZ> {
44 void set_calibration(int16_t x_min, int16_t x_max, int16_t y_min, int16_t y_max);
59 void setup()
override;
60 void dump_config()
override;
61 float get_setup_priority()
const override;
78 void update()
override;
98 int16_t x_raw{0}, y_raw{0}, z_raw{0};
102 static int16_t best_two_avg(int16_t x, int16_t y, int16_t z);
103 static int16_t normalize(int16_t
val, int16_t min_val, int16_t max_val);
105 int16_t read_adc_(uint8_t ctrl);
114 uint32_t last_pos_ms_{0};
117 bool last_irq_{
true};
120 std::vector<XPT2046Button *> buttons_{};
void set_dimensions(int16_t x, int16_t y)
Set the logical touch screen dimensions.
void set_swap_x_y(bool val)
If true the x and y axes will be swapped.
This class simplifies creating components that periodically check a state.
void set_threshold(int16_t threshold)
Set the threshold for the touch detection.
void set_irq_pin(GPIOPin *pin)
Set the pin used to detect the touch.
void register_button(XPT2046Button *button)
Register a virtual button to the component.
XPT2046OnStateTrigger * get_on_state_trigger() const
Get an access to the on_state automation trigger.
void process(int x, int y, bool touched)
Base class for all binary_sensor-type classes.
void set_report_interval(uint32_t interval)
Set the interval to report the touch point perodically.