From fe51ee6257d1a8343f2bdc3a6135d459808874ee Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Mon, 14 Apr 2025 08:41:11 +1000 Subject: [PATCH] [axs15231] Don't overwrite manual dimensions (#8553) --- .../axs15231/touchscreen/axs15231_touchscreen.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/esphome/components/axs15231/touchscreen/axs15231_touchscreen.cpp b/esphome/components/axs15231/touchscreen/axs15231_touchscreen.cpp index 54b39a6bb9..c7646bcf2f 100644 --- a/esphome/components/axs15231/touchscreen/axs15231_touchscreen.cpp +++ b/esphome/components/axs15231/touchscreen/axs15231_touchscreen.cpp @@ -30,8 +30,12 @@ void AXS15231Touchscreen::setup() { this->interrupt_pin_->setup(); this->attach_interrupt_(this->interrupt_pin_, gpio::INTERRUPT_FALLING_EDGE); } - this->x_raw_max_ = this->display_->get_native_width(); - this->y_raw_max_ = this->display_->get_native_height(); + if (this->x_raw_max_ == 0) { + this->x_raw_max_ = this->display_->get_native_width(); + } + if (this->y_raw_max_ == 0) { + this->y_raw_max_ = this->display_->get_native_height(); + } ESP_LOGCONFIG(TAG, "AXS15231 Touchscreen setup complete"); } @@ -44,7 +48,7 @@ void AXS15231Touchscreen::update_touches() { err = this->read(data, sizeof(data)); ERROR_CHECK(err); this->status_clear_warning(); - if (data[0] != 0) // no touches + if (data[0] != 0 || data[1] == 0) // no touches return; uint16_t x = encode_uint16(data[2] & 0xF, data[3]); uint16_t y = encode_uint16(data[4] & 0xF, data[5]);