From 32f05f50f5cd2ec5d1485ac7b81bd65fc6d611b4 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 9 Apr 2026 17:01:51 -1000 Subject: [PATCH] [sx1509] Extract clear_interrupt_ inline helper --- esphome/components/sx1509/sx1509.cpp | 3 +-- esphome/components/sx1509/sx1509.h | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/esphome/components/sx1509/sx1509.cpp b/esphome/components/sx1509/sx1509.cpp index bf07f006d0..935e8dd006 100644 --- a/esphome/components/sx1509/sx1509.cpp +++ b/esphome/components/sx1509/sx1509.cpp @@ -59,8 +59,7 @@ void SX1509Component::loop() { this->interrupt_pending_ = false; // Clear interrupt source before resetting cache to avoid losing // pin changes that occur between cache reset and interrupt clear - uint16_t interrupt_source = 0; - this->read_byte_16(REG_INTERRUPT_SOURCE_B, &interrupt_source); + this->clear_interrupt_(); this->reset_pin_cache_(); if (!this->has_keypad_) { this->disable_loop(); diff --git a/esphome/components/sx1509/sx1509.h b/esphome/components/sx1509/sx1509.h index 4a398e820e..0d8679f581 100644 --- a/esphome/components/sx1509/sx1509.h +++ b/esphome/components/sx1509/sx1509.h @@ -94,6 +94,10 @@ class SX1509Component : public Component, const uint32_t min_loop_period_ = 15; // ms void enable_pin_interrupt_(uint8_t pin); + void clear_interrupt_() { + uint16_t interrupt_source = 0; + this->read_byte_16(REG_INTERRUPT_SOURCE_B, &interrupt_source); + } void setup_keypad_(); void set_debounce_config_(uint8_t config_value); void set_debounce_time_(uint8_t time);