1
0
mirror of https://github.com/esphome/esphome.git synced 2025-04-13 14:20:29 +01:00

[touchscreen] Axis swap bugfix (#8376)

This commit is contained in:
Clyde Stubbs 2025-03-10 14:04:34 +11:00 committed by GitHub
parent 10cea51739
commit 75d1eeeffe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -74,6 +74,9 @@ void Touchscreen::loop() {
void Touchscreen::add_raw_touch_position_(uint8_t id, int16_t x_raw, int16_t y_raw, int16_t z_raw) { void Touchscreen::add_raw_touch_position_(uint8_t id, int16_t x_raw, int16_t y_raw, int16_t z_raw) {
TouchPoint tp; TouchPoint tp;
uint16_t x, y; uint16_t x, y;
if (this->swap_x_y_) {
std::swap(x_raw, y_raw);
}
if (this->touches_.count(id) == 0) { if (this->touches_.count(id) == 0) {
tp.state = STATE_PRESSED; tp.state = STATE_PRESSED;
tp.id = id; tp.id = id;
@ -90,10 +93,6 @@ void Touchscreen::add_raw_touch_position_(uint8_t id, int16_t x_raw, int16_t y_r
x = this->normalize_(x_raw, this->x_raw_min_, this->x_raw_max_, this->invert_x_); x = this->normalize_(x_raw, this->x_raw_min_, this->x_raw_max_, this->invert_x_);
y = this->normalize_(y_raw, this->y_raw_min_, this->y_raw_max_, this->invert_y_); y = this->normalize_(y_raw, this->y_raw_min_, this->y_raw_max_, this->invert_y_);
if (this->swap_x_y_) {
std::swap(x, y);
}
tp.x = (uint16_t) ((int) x * this->display_width_ / 0x1000); tp.x = (uint16_t) ((int) x * this->display_width_ / 0x1000);
tp.y = (uint16_t) ((int) y * this->display_height_ / 0x1000); tp.y = (uint16_t) ((int) y * this->display_height_ / 0x1000);
} else { } else {