1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-27 13:13:50 +00:00

[mpr121] cleaner setup (#11013)

This commit is contained in:
mrtoy-me
2025-10-04 22:54:31 +10:00
committed by GitHub
parent 2eea674c04
commit 874db20b7d
2 changed files with 2 additions and 5 deletions

View File

@@ -11,6 +11,7 @@ namespace mpr121 {
static const char *const TAG = "mpr121";
void MPR121Component::setup() {
this->disable_loop();
// soft reset device
this->write_byte(MPR121_SOFTRESET, 0x63);
this->set_timeout(100, [this]() {
@@ -51,7 +52,7 @@ void MPR121Component::setup() {
this->write_byte(MPR121_ECR, 0x80 | (this->max_touch_channel_ + 1));
this->flush_gpio_();
this->setup_complete_ = true;
this->enable_loop();
});
}
@@ -80,9 +81,6 @@ void MPR121Component::dump_config() {
}
}
void MPR121Component::loop() {
if (!this->setup_complete_)
return;
uint16_t val = 0;
this->read_byte_16(MPR121_TOUCHSTATUS_L, &val);