7static constexpr uint16_t REG_TOUCH_NUM = 0x1001;
8static constexpr uint16_t REG_POINT1 = 0x1002;
9static constexpr uint8_t MAX_TOUCHES = 5;
10static constexpr uint8_t POINT_SIZE = 7;
13 ESP_LOGCONFIG(TAG,
"Setting up icnt86 Touchscreen...");
38 uint8_t buf[MAX_TOUCHES * POINT_SIZE] = {0};
39 uint8_t mask[1] = {0x00};
44 ESP_LOGW(TAG,
"Failed to read touch count");
47 uint8_t touch_count = buf[0];
49 if (touch_count == 0x00 || touch_count > MAX_TOUCHES) {
56 ESP_LOGW(TAG,
"Failed to read touch points");
60 ESP_LOGV(TAG,
"Touch count: %d", touch_count);
63 for (uint8_t i = 0; i < touch_count; i++) {
64 uint16_t
x = ((uint16_t) buf[2 + 7 * i] << 8) + buf[1 + 7 * i];
65 uint16_t
y = ((uint16_t) buf[4 + 7 * i] << 8) + buf[3 + 7 * i];
78 ESP_LOGCONFIG(TAG,
"icnt86 Touchscreen:");
void status_set_warning()
void status_clear_warning()
virtual void digital_write(bool value)=0
int get_native_width()
Get the native (original) width of the display in pixels.
int get_native_height()
Get the native (original) height of the display in pixels.
ErrorCode write_register16(uint16_t a_register, const uint8_t *data, size_t len) const
write an array of bytes to a specific register in the I²C device
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
InternalGPIOPin * interrupt_pin_
void update_touches() override
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.
display::Display * display_
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.
ESPHOME_LOG_TAG(TAG, "icnt86")
void HOT delay(uint32_t ms)