9static const char *
const TAG =
"ax15231.touchscreen";
11constexpr static const uint8_t AXS_READ_TOUCHPAD[11] = {0xb5, 0xab, 0xa5, 0x5a, 0x0, 0x0, 0x0, 0x8};
13#define ERROR_CHECK(err) \
14 if ((err) != i2c::ERROR_OK) { \
15 this->status_set_warning("Failed to communicate"); \
20 ESP_LOGCONFIG(TAG,
"Setting up AXS15231 Touchscreen...");
39 ESP_LOGCONFIG(TAG,
"AXS15231 Touchscreen setup complete");
46 err = this->
write(AXS_READ_TOUCHPAD,
sizeof(AXS_READ_TOUCHPAD),
false);
48 err = this->
read(data,
sizeof(data));
51 if (data[0] != 0 || data[1] == 0)
59 ESP_LOGCONFIG(TAG,
"AXS15231 Touchscreen:");
63 ESP_LOGCONFIG(TAG,
" Width: %d", this->
x_raw_max_);
64 ESP_LOGCONFIG(TAG,
" Height: %d", this->
y_raw_max_);
void status_clear_warning()
virtual void pin_mode(gpio::Flags flags)=0
virtual void digital_write(bool value)=0
void update_touches() override
InternalGPIOPin * interrupt_pin_
void dump_config() override
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 write(const uint8_t *data, size_t len, bool stop=true)
writes an array of bytes to a device using an I2CBus
ErrorCode read(uint8_t *data, size_t len)
reads an array of bytes from the device using an I2CBus
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.
display::Display * display_
void add_raw_touch_position_(uint8_t id, int16_t x_raw, int16_t y_raw, int16_t z_raw=0)
ErrorCode
Error codes returned by I2CBus and I2CDevice methods.
Providing packet encoding functions for exchanging data with a remote host.
constexpr uint16_t encode_uint16(uint8_t msb, uint8_t lsb)
Encode a 16-bit value given the most and least significant byte.
void IRAM_ATTR HOT delay(uint32_t ms)