ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
xpt2046.h
Go to the documentation of this file.
1#pragma once
2
8#include "esphome/core/log.h"
9
10namespace esphome::xpt2046 {
11
12using namespace touchscreen;
13
15 public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW,
16 spi::CLOCK_PHASE_LEADING, spi::DATA_RATE_2MHZ> {
17 public:
19 void set_threshold(int16_t threshold) { this->threshold_ = threshold; }
21 void set_irq_pin(InternalGPIOPin *pin) { this->irq_pin_ = pin; }
22
23 void setup() override;
24 void dump_config() override;
25 // float get_setup_priority() const override;
26
27 protected:
28 static int16_t best_two_avg(int16_t value1, int16_t value2, int16_t value3);
29
30 int16_t read_adc_(uint8_t ctrl);
31
32 void update_touches() override;
33
34 int16_t threshold_;
35
37};
38
39} // namespace esphome::xpt2046
The SPIDevice is what components using the SPI will create.
Definition spi.h:429
void set_irq_pin(InternalGPIOPin *pin)
Set the pin used to detect the touch.
Definition xpt2046.h:21
int16_t read_adc_(uint8_t ctrl)
Definition xpt2046.cpp:98
static int16_t best_two_avg(int16_t value1, int16_t value2, int16_t value3)
Definition xpt2046.cpp:79
void set_threshold(int16_t threshold)
Set the threshold for the touch detection.
Definition xpt2046.h:19