ESPHome  2024.10.2
mpr121_binary_sensor.cpp
Go to the documentation of this file.
1 #include "mpr121_binary_sensor.h"
2 
3 namespace esphome {
4 namespace 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 
14 void 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 process(uint16_t data) override
void publish_state(bool state)
Publish a new state to the front-end.
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
value_type value_or(U const &v) const
Definition: optional.h:93