7 esph_log_config(TAG,
"Setting up CST226 Touchscreen...");
19 if (!this->
read_bytes(CST226_REG_STATUS, data,
sizeof data)) {
25 if (data[6] != 0xAB || data[0] == 0xAB || data[5] == 0x80) {
29 uint8_t num_of_touches = data[5] & 0x7F;
30 if (num_of_touches == 0 || num_of_touches > 5) {
36 for (uint8_t i = 0; i != num_of_touches; i++) {
37 uint8_t
id = data[index] >> 4;
38 int16_t
x = (data[index + 1] << 4) | ((data[index + 3] >> 4) & 0x0F);
39 int16_t
y = (data[index + 2] << 4) | (data[index + 3] & 0x0F);
40 int16_t z = data[index + 4];
42 esph_log_v(TAG,
"Read touch %d: %d/%d",
id, x, y);
57 esph_log_e(TAG,
"Write byte to 0xD1 failed");
62 if (this->
read16_(0xD204, buffer, 4)) {
63 uint16_t chip_id = buffer[2] + (buffer[3] << 8);
64 uint16_t project_id = buffer[0] + (buffer[1] << 8);
65 esph_log_config(TAG,
"Chip ID %X, project ID %x", chip_id, project_id);
68 if (this->
read16_(0xD1F8, buffer, 4)) {
69 this->
x_raw_max_ = buffer[0] + (buffer[1] << 8);
70 this->
y_raw_max_ = buffer[2] + (buffer[3] << 8);
77 esph_log_config(TAG,
"CST226 Touchscreen setup complete");
81 ESP_LOGCONFIG(TAG,
"CST226 Touchscreen:");
virtual void digital_write(bool value)=0
void status_set_warning(const char *message="unspecified")
bool read16_(uint16_t addr, uint8_t *data, size_t len)
void update_touches() override
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.
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.
No error found during execution of method.
void status_clear_warning()
ErrorCode write_register16(uint16_t a_register, const uint8_t *data, size_t len, bool stop=true)
write an array of bytes to a specific register in the I²C device
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)
void dump_config() override
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
void IRAM_ATTR HOT delay(uint32_t ms)