SX1509 minimum loop period (fixes esphome/issues#4325) (#4613)

* Minimum loop period (fixes esphome/issues#4325)

* clang-tidy suggestions

* More clang-tidy suggestions
This commit is contained in:
tracestep
2023-03-26 18:59:57 -03:00
committed by GitHub
parent 29e7d00894
commit 806e43c34c
2 changed files with 6 additions and 0 deletions
+3
View File
@@ -42,6 +42,9 @@ void SX1509Component::dump_config() {
void SX1509Component::loop() {
if (this->has_keypad_) {
if (millis() - this->last_loop_timestamp_ < min_loop_period_)
return;
this->last_loop_timestamp_ = millis();
uint16_t key_data = this->read_key_data();
for (auto *binary_sensor : this->keypad_binary_sensors_)
binary_sensor->process(key_data);