ESPHome  2023.8.3
touchscreen.cpp
Go to the documentation of this file.
1 #include "touchscreen.h"
2 
3 #include "esphome/core/log.h"
4 
5 namespace esphome {
6 namespace touchscreen {
7 
8 static const char *const TAG = "touchscreen";
9 
11  this->display_ = display;
12  this->display_width_ = display->get_width();
13  this->display_height_ = display->get_height();
14  this->rotation_ = static_cast<TouchRotation>(display->get_rotation());
15 
16  if (this->rotation_ == ROTATE_90_DEGREES || this->rotation_ == ROTATE_270_DEGREES) {
18  }
19 }
20 
22  ESP_LOGV(TAG, "Touch (x=%d, y=%d)", tp.x, tp.y);
23  this->touch_trigger_.trigger(tp);
24  for (auto *listener : this->touch_listeners_)
25  listener->touch(tp);
26 }
27 
28 } // namespace touchscreen
29 } // namespace esphome
DisplayRotation get_rotation() const
Definition: display.h:429
Trigger< TouchPoint > touch_trigger_
Definition: touchscreen.h:49
virtual int get_width()=0
Get the width of the image in pixels with rotation applied.
void send_touch_(TouchPoint tp)
Call this function to send touch points to the on_touch listener and the binary_sensors.
Definition: touchscreen.cpp:21
std::vector< TouchListener * > touch_listeners_
Definition: touchscreen.h:50
void swap(optional< T > &x, optional< T > &y)
Definition: optional.h:210
void set_display(display::Display *display)
Definition: touchscreen.cpp:10
virtual int get_height()=0
Get the height of the image in pixels with rotation applied.