27 this->
mark_failed(LOG_STR(
"Failed to read status register"));
30 if ((
status & 0x0F) == ST7123_STATUS_INIT) {
31 ESP_LOGD(TAG,
"Controller still initializing");
40 ESP_LOGD(TAG,
"Status is %X",
status);
44 data <= ST7123_MAX_TOUCHES) {
57 this->
mark_failed(LOG_STR(
"Failed to read calibration"));
64 Touchscreen::update();
70 uint8_t data[(ST7123_REG_TOUCH_DATA - ST7123_REG_ADV_TOUCH_INFO) + ST7123_MAX_TOUCHES * ST7123_TOUCH_STRIDE];
71 const size_t len = (ST7123_REG_TOUCH_DATA - ST7123_REG_ADV_TOUCH_INFO) + this->
max_touches_ * ST7123_TOUCH_STRIDE;
77 const uint8_t *points = data + (ST7123_REG_TOUCH_DATA - ST7123_REG_ADV_TOUCH_INFO);
79 const uint8_t *p = points + i * ST7123_TOUCH_STRIDE;
80 if ((p[0] & ST7123_TOUCH_VALID) == 0)
84 uint8_t intensity = p[5];
85 ESP_LOGV(TAG,
"Touch %u: x=%u, y=%u, intensity=%u", i,
x,
y, intensity);
92 "ST7123 Touchscreen:\n"
94 " X Raw Min: %d, X Raw Max: %d\n"
95 " 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.
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
void update_touches() override
InternalGPIOPin * interrupt_pin_
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.
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, "st7123.touchscreen")
constexpr uint16_t encode_uint16(uint8_t msb, uint8_t lsb)
Encode a 16-bit value given the most and least significant byte.
uint32_t IRAM_ATTR HOT millis()
ESPHOME_ALWAYS_INLINE void pulse_reset(GPIOPin *pin, ResetPulse pulse)
Set up an active-low reset pin and drive it through pulse.