ESPHome  2024.5.0
touchscreen_binary_sensor.cpp
Go to the documentation of this file.
2 
3 namespace esphome {
4 namespace touchscreen {
5 
7  this->parent_->register_listener(this);
8  this->publish_initial_state(false);
9 }
10 
12  bool touched = (tp.x >= this->x_min_ && tp.x <= this->x_max_ && tp.y >= this->y_min_ && tp.y <= this->y_max_);
13 
14  if (this->page_ != nullptr) {
15  touched &= this->page_ == this->parent_->get_display()->get_active_page();
16  }
17  if (touched) {
18  this->publish_state(true);
19  } else {
20  this->release();
21  }
22 }
23 
25 
26 } // namespace touchscreen
27 } // namespace esphome
void publish_initial_state(bool state)
Publish the initial state, this will not make the callback manager send callbacks and is meant only f...
void publish_state(bool state)
Publish a new state to the front-end.
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7