mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-06-01 10:38:27 +02:00
display: split DisplayBuffer and Display (#5001)
This commit is contained in:
@@ -7,6 +7,17 @@ namespace touchscreen {
|
||||
|
||||
static const char *const TAG = "touchscreen";
|
||||
|
||||
void Touchscreen::set_display(display::Display *display) {
|
||||
this->display_ = display;
|
||||
this->display_width_ = display->get_width();
|
||||
this->display_height_ = display->get_height();
|
||||
this->rotation_ = static_cast<TouchRotation>(display->get_rotation());
|
||||
|
||||
if (this->rotation_ == ROTATE_90_DEGREES || this->rotation_ == ROTATE_270_DEGREES) {
|
||||
std::swap(this->display_width_, this->display_height_);
|
||||
}
|
||||
}
|
||||
|
||||
void Touchscreen::send_touch_(TouchPoint tp) {
|
||||
ESP_LOGV(TAG, "Touch (x=%d, y=%d)", tp.x, tp.y);
|
||||
this->touch_trigger_.trigger(tp);
|
||||
|
||||
@@ -31,13 +31,8 @@ enum TouchRotation {
|
||||
|
||||
class Touchscreen {
|
||||
public:
|
||||
void set_display(display::DisplayBuffer *display) {
|
||||
this->display_ = display;
|
||||
this->display_width_ = display->get_width_internal();
|
||||
this->display_height_ = display->get_height_internal();
|
||||
this->rotation_ = static_cast<TouchRotation>(display->get_rotation());
|
||||
}
|
||||
display::DisplayBuffer *get_display() const { return this->display_; }
|
||||
void set_display(display::Display *display);
|
||||
display::Display *get_display() const { return this->display_; }
|
||||
|
||||
Trigger<TouchPoint> *get_touch_trigger() { return &this->touch_trigger_; }
|
||||
|
||||
@@ -49,7 +44,7 @@ class Touchscreen {
|
||||
|
||||
uint16_t display_width_;
|
||||
uint16_t display_height_;
|
||||
display::DisplayBuffer *display_;
|
||||
display::Display *display_;
|
||||
TouchRotation rotation_;
|
||||
Trigger<TouchPoint> touch_trigger_;
|
||||
std::vector<TouchListener *> touch_listeners_;
|
||||
|
||||
Reference in New Issue
Block a user