ESPHome  2022.6.3
touchscreen_binary_sensor.cpp
Go to the documentation of this file.
2 
3 namespace esphome {
4 namespace touchscreen {
5 
7  bool touched = (tp.x >= this->x_min_ && tp.x <= this->x_max_ && tp.y >= this->y_min_ && tp.y <= this->y_max_);
8 
9  if (this->page_ != nullptr) {
10  touched &= this->page_ == this->parent_->get_display()->get_active_page();
11  }
12 
13  if (touched) {
14  this->publish_state(true);
15  } else {
16  release();
17  }
18 }
19 
21 
22 } // namespace touchscreen
23 } // namespace esphome
void publish_state(bool state)
Publish a new state to the front-end.
Definition: a4988.cpp:4