ESPHome 2025.9.0-dev
Loading...
Searching...
No Matches
chsc6x_touchscreen.cpp
Go to the documentation of this file.
2
3namespace esphome {
4namespace chsc6x {
5
7 if (this->interrupt_pin_ != nullptr) {
8 this->interrupt_pin_->setup();
10 }
11 if (this->x_raw_max_ == this->x_raw_min_) {
12 this->x_raw_max_ = this->display_->get_native_width();
13 }
14 if (this->y_raw_max_ == this->y_raw_min_) {
15 this->y_raw_max_ = this->display_->get_native_height();
16 }
17}
18
20 uint8_t data[CHSC6X_REG_STATUS_LEN];
21 if (!this->read_bytes(CHSC6X_REG_STATUS, data, sizeof(data))) {
22 return;
23 }
24
25 uint8_t num_of_touches = data[CHSC6X_REG_STATUS_TOUCH];
26
27 if (num_of_touches == 1) {
28 uint16_t x = data[CHSC6X_REG_STATUS_X_COR];
29 uint16_t y = data[CHSC6X_REG_STATUS_Y_COR];
30 this->add_raw_touch_position_(0, x, y);
31 }
32}
33
35 ESP_LOGCONFIG(TAG, "CHSC6X Touchscreen:");
36 LOG_I2C_DEVICE(this);
37 LOG_PIN(" Interrupt Pin: ", this->interrupt_pin_);
38 ESP_LOGCONFIG(TAG,
39 " Touch timeout: %d\n"
40 " x_raw_max_: %d\n"
41 " y_raw_max_: %d",
42 this->touch_timeout_, this->x_raw_max_, this->y_raw_max_);
43}
44
45} // namespace chsc6x
46} // namespace esphome
virtual void setup()=0
int get_native_width()
Get the native (original) width of the display in pixels.
Definition display.h:221
int get_native_height()
Get the native (original) height of the display in pixels.
Definition display.h:223
bool read_bytes(uint8_t a_register, uint8_t *data, uint8_t len)
Compat APIs All methods below have been added for compatibility reasons.
Definition i2c.h:216
void attach_interrupt_(InternalGPIOPin *irq_pin, esphome::gpio::InterruptType type)
Call this function to send touch points to the on_touch listener and the binary_sensors.
void add_raw_touch_position_(uint8_t id, int16_t x_raw, int16_t y_raw, int16_t z_raw=0)
@ INTERRUPT_FALLING_EDGE
Definition gpio.h:42
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
uint16_t x
Definition tt21100.cpp:5
uint16_t y
Definition tt21100.cpp:6