37 ESP_LOGCONFIG(TAG,
"CST816 Touchscreen setup complete");
45 listener->update_button(state);
49 ESP_LOGCONFIG(TAG,
"Setting up CST816 Touchscreen...");
65 if (!this->
read_bytes(REG_STATUS, data,
sizeof data)) {
69 uint8_t num_of_touches = data[REG_TOUCH_NUM] & 3;
70 if (num_of_touches == 0) {
75 uint16_t
x =
encode_uint16(data[REG_XPOS_HIGH] & 0xF, data[REG_XPOS_LOW]);
76 uint16_t
y =
encode_uint16(data[REG_YPOS_HIGH] & 0xF, data[REG_YPOS_LOW]);
77 ESP_LOGV(TAG,
"Read touch %d/%d", x, y);
86 ESP_LOGCONFIG(TAG,
"CST816 Touchscreen:");
101 case CST816D_CHIP_ID:
107 case CST816T_CHIP_ID:
114 ESP_LOGCONFIG(TAG,
" Chip type: %s", name);
virtual void digital_write(bool value)=0
bool read_byte(uint8_t a_register, uint8_t *data, bool stop=true)
void status_set_warning(const char *message="unspecified")
int get_native_height()
Get the native (original) height of the display in pixels.
void set_timeout(const std::string &name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a unique name.
bool read_bytes(uint8_t a_register, uint8_t *data, uint8_t len)
Compat APIs All methods below have been added for compatibility reasons.
void dump_config() override
InternalGPIOPin * interrupt_pin_
int get_native_width()
Get the native (original) width of the display in pixels.
void status_set_error(const char *message="unspecified")
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.
std::string str_sprintf(const char *fmt,...)
constexpr uint16_t encode_uint16(uint8_t msb, uint8_t lsb)
Encode a 16-bit value given the most and least significant byte.
void update_touches() override
display::Display * display_
bool write_byte(uint8_t a_register, uint8_t data, bool stop=true)
virtual void mark_failed()
Mark this component as failed.
void add_raw_touch_position_(uint8_t id, int16_t x_raw, int16_t y_raw, int16_t z_raw=0)
Implementation of SPI Controller mode.
std::vector< CST816ButtonListener * > button_listeners_
void IRAM_ATTR HOT delay(uint32_t ms)
void update_button_state_(bool state)