ESPHome 2025.5.0
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 {
11namespace xpt2046 {
12
13using namespace touchscreen;
14
16 public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW,
17 spi::CLOCK_PHASE_LEADING, spi::DATA_RATE_2MHZ> {
18 public:
20 void set_threshold(int16_t threshold) { this->threshold_ = threshold; }
22 void set_irq_pin(InternalGPIOPin *pin) { this->irq_pin_ = pin; }
23
24 void setup() override;
25 void dump_config() override;
26 // float get_setup_priority() const override;
27
28 protected:
29 static int16_t best_two_avg(int16_t value1, int16_t value2, int16_t value3);
30
31 int16_t read_adc_(uint8_t ctrl);
32
33 void update_touches() override;
34
35 int16_t threshold_;
36
38};
39
40} // namespace xpt2046
41} // namespace esphome
The SPIDevice is what components using the SPI will create.
Definition spi.h:421
void set_irq_pin(InternalGPIOPin *pin)
Set the pin used to detect the touch.
Definition xpt2046.h:22
int16_t read_adc_(uint8_t ctrl)
Definition xpt2046.cpp:100
static int16_t best_two_avg(int16_t value1, int16_t value2, int16_t value3)
Definition xpt2046.cpp:81
void set_threshold(int16_t threshold)
Set the threshold for the touch detection.
Definition xpt2046.h:20
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7