mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00:00 
			
		
		
		
	[touchscreen] Axis swap bugfix (#8376)
This commit is contained in:
		| @@ -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) { | ||||
|   TouchPoint tp; | ||||
|   uint16_t x, y; | ||||
|   if (this->swap_x_y_) { | ||||
|     std::swap(x_raw, y_raw); | ||||
|   } | ||||
|   if (this->touches_.count(id) == 0) { | ||||
|     tp.state = STATE_PRESSED; | ||||
|     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_); | ||||
|     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.y = (uint16_t) ((int) y * this->display_height_ / 0x1000); | ||||
|   } else { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user