6static constexpr uint32_t REREAD_TIMEOUT_ID = 1;
7static constexpr uint32_t REREAD_DELAY_MS = 20;
25 uint16_t x_max, y_max;
26 if (this->
read_words_(cstxxx::REG_RESOLUTION, x_max, y_max)) {
34 LOG_STR(
"Failed to read chip ID")))
36 if (this->
chip_id_ != CST9220_CHIP_ID && this->
chip_id_ != CST9217_CHIP_ID) {
37 ESP_LOGE(TAG,
"Unknown chip ID: 0x%04X", this->
chip_id_);
54 uint8_t data[CST9220_DATA_LENGTH];
66 if (data[cstxxx::SYNC_IDX] != cstxxx::SYNC_BYTE) {
73 uint8_t num_touches = data[cstxxx::FINGER_COUNT_IDX] & 0x7F;
74 if (num_touches > CST9220_MAX_TOUCHES)
75 num_touches = CST9220_MAX_TOUCHES;
77 for (uint8_t i = 0; i < num_touches; i++) {
79 if (touch.event != TOUCH_EVENT_DOWN)
81 ESP_LOGV(TAG,
"Read touch %d: %d/%d", touch.id, touch.x, touch.y);
88 "CST9220 Touchscreen:\n"
90 " Project ID: 0x%04X\n"
91 " X Raw Min: %d, X Raw Max: %d\n"
92 " Y Raw Min: %d, Y Raw Max: %d",
void mark_failed()
Mark this component as failed.
bool status_comm_result(bool ok)
Clears the warning when ok, else sets it with message (default "Communication failed"); returns ok.
bool ESPHOME_ALWAYS_INLINE setup_check(bool ok)
Marks the component failed with message (default "Communication failed") unless ok; returns ok.
void set_timeout(const char *name, uint32_t timeout, SchedulerCallback &&f)
Set a timeout function with a const char* name.
void update_touches() override
void dump_config() override
bool ESPHOME_ALWAYS_INLINE read_words_(uint16_t reg, uint16_t &low, uint16_t &high)
Reads two little-endian words starting at reg.
bool check_firmware_()
Checks the firmware check code, marking the component failed if it is unreadable or wrong.
bool enter_command_mode_()
Enters command mode, marking the component failed if the write fails.
void setup_interrupt_pin_(gpio::InterruptType type)
Sets up the interrupt pin, if configured, to fire on type.
InternalGPIOPin * interrupt_pin_
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 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
std::map< uint8_t, TouchPoint > touches_
display::Display * display_
TouchscreenInterrupt store_
void add_raw_touch_position_(uint8_t id, int16_t x_raw, int16_t y_raw, int16_t z_raw=0)
TouchRecord decode_touch(const uint8_t *report, uint8_t index)
Decodes record index of a touch report.
@ ERROR_OK
No error found during execution of method.
void HOT delay(uint32_t ms)
ESPHOME_ALWAYS_INLINE void pulse_reset(GPIOPin *pin, ResetPulse pulse)
Set up an active-low reset pin and drive it through pulse.