13 esph_log_e(TAG,
"Failed to read chip id");
26 esph_log_e(TAG,
"Unknown chip ID 0x%02X", this->
chip_id_);
36 esph_log_config(TAG,
"CST816 Touchscreen setup complete");
44 listener->update_button(state);
48 esph_log_config(TAG,
"Setting up CST816 Touchscreen...");
64 if (!this->
read_bytes(REG_STATUS, data,
sizeof data)) {
68 uint8_t num_of_touches = data[REG_TOUCH_NUM] & 3;
69 if (num_of_touches == 0) {
74 uint16_t
x =
encode_uint16(data[REG_XPOS_HIGH] & 0xF, data[REG_XPOS_LOW]);
75 uint16_t
y =
encode_uint16(data[REG_YPOS_HIGH] & 0xF, data[REG_YPOS_LOW]);
76 esph_log_v(TAG,
"Read touch %d/%d", x, y);
85 ESP_LOGCONFIG(TAG,
"CST816 Touchscreen:");
100 case CST816D_CHIP_ID:
106 case CST816T_CHIP_ID:
113 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 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.
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)