ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
touchscreen_binary_sensor.h
Go to the documentation of this file.
1#pragma once
2
8
9#include <vector>
10
11namespace esphome::touchscreen {
12
14 public Component,
15 public TouchListener,
16 public Parented<Touchscreen> {
17 public:
18 void setup() override;
19
21 void set_area(int16_t x_min, int16_t x_max, int16_t y_min, int16_t y_max) {
22 this->x_min_ = x_min;
23 this->x_max_ = x_max;
24 this->y_min_ = y_min;
25 this->y_max_ = y_max;
26 }
27 void set_use_raw(bool use_raw) { this->use_raw_ = use_raw; }
28 int16_t get_x_min() { return this->x_min_; }
29 int16_t get_x_max() { return this->x_max_; }
30 int16_t get_y_min() { return this->y_min_; }
31 int16_t get_y_max() { return this->y_max_; }
32 int16_t get_width() { return this->x_max_ - this->x_min_; }
33 int16_t get_height() { return this->y_max_ - this->y_min_; }
34
35 void add_page(display::DisplayPage *page) { this->pages_.push_back(page); }
36
37 void touch(TouchPoint tp) override;
38 void release() override;
39
40 protected:
41 int16_t x_min_{}, x_max_{}, y_min_{}, y_max_{};
42 bool use_raw_{};
43 std::vector<display::DisplayPage *> pages_{};
44};
45
46} // namespace esphome::touchscreen
Helper class to easily give an object a parent of type T.
Definition helpers.h:1861
Base class for all binary_sensor-type classes.
void set_area(int16_t x_min, int16_t x_max, int16_t y_min, int16_t y_max)
Set the touch screen area where the button will detect the touch.