8static const char *
const TAG =
"st7123.touchscreen";
31 this->
mark_failed(LOG_STR(
"Failed to read status register"));
34 if ((
status & 0x0F) == ST7123_STATUS_INIT) {
35 ESP_LOGD(TAG,
"Controller still initializing");
44 ESP_LOGD(TAG,
"Status is %X",
status);
48 data <= ST7123_MAX_TOUCHES) {
61 this->
mark_failed(LOG_STR(
"Failed to read calibration"));
68 Touchscreen::update();
74 uint8_t data[(ST7123_REG_TOUCH_DATA - ST7123_REG_ADV_TOUCH_INFO) + ST7123_MAX_TOUCHES * ST7123_TOUCH_STRIDE];
75 const size_t len = (ST7123_REG_TOUCH_DATA - ST7123_REG_ADV_TOUCH_INFO) + this->
max_touches_ * ST7123_TOUCH_STRIDE;
83 const uint8_t *points = data + (ST7123_REG_TOUCH_DATA - ST7123_REG_ADV_TOUCH_INFO);
85 const uint8_t *p = points + i * ST7123_TOUCH_STRIDE;
86 if ((p[0] & ST7123_TOUCH_VALID) == 0)
90 uint8_t intensity = p[5];
91 ESP_LOGV(TAG,
"Touch %u: x=%u, y=%u, intensity=%u", i,
x,
y, intensity);
98 "ST7123 Touchscreen:\n"
100 " X Raw Min: %d, X Raw Max: %d\n"
101 " Y Raw Min: %d, Y Raw Max: %d",
103 LOG_I2C_DEVICE(
this);
void mark_failed()
Mark this component as failed.
void status_set_warning()
void status_clear_warning()
virtual void digital_write(bool value)=0
ErrorCode read_register16(uint16_t a_register, uint8_t *data, size_t len)
reads an array of bytes from a specific register in the I²C device
void dump_config() override
void update_touches() override
InternalGPIOPin * interrupt_pin_
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)
@ ERROR_OK
No error found during execution of method.
constexpr uint16_t encode_uint16(uint8_t msb, uint8_t lsb)
Encode a 16-bit value given the most and least significant byte.
void HOT delay(uint32_t ms)
uint32_t IRAM_ATTR HOT millis()