ESPHome 2025.6.0
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
mpr121_binary_sensor.cpp
Go to the documentation of this file.
2
3namespace esphome {
4namespace mpr121 {
5
7 uint8_t touch_threshold = this->touch_threshold_.value_or(this->parent_->get_touch_threshold());
8 this->parent_->write_byte(MPR121_TOUCHTH_0 + 2 * this->channel_, touch_threshold);
9
10 uint8_t release_threshold = this->release_threshold_.value_or(this->parent_->get_release_threshold());
11 this->parent_->write_byte(MPR121_RELEASETH_0 + 2 * this->channel_, release_threshold);
12}
13
14void MPR121BinarySensor::process(uint16_t data) {
15 bool new_state = data & (1 << this->channel_);
16 this->publish_state(new_state);
17}
18
19} // namespace mpr121
20} // namespace esphome
void publish_state(bool state)
Publish a new state to the front-end.
value_type value_or(U const &v) const
Definition optional.h:93
@ MPR121_RELEASETH_0
Definition mpr121.h:32
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7