mirror of
https://github.com/esphome/esphome.git
synced 2026-07-10 17:05:36 +00:00
Fix pin_interrupt_mode overriding auto-enabled CHANGE interrupt
MCP23XXXGPIOPin::setup() calls pin_interrupt_mode(pin, NO_INTERRUPT) after pin_mode() already auto-enabled CHANGE, undoing the auto-enable. Skip the explicit pin_interrupt_mode call when interrupt_pin is configured and the user didn't override the default.
This commit is contained in:
@@ -7,7 +7,12 @@ namespace mcp23xxx_base {
|
||||
|
||||
template<uint8_t N> void MCP23XXXGPIOPin<N>::setup() {
|
||||
this->pin_mode(flags_);
|
||||
this->parent_->pin_interrupt_mode(this->pin_, this->interrupt_mode_);
|
||||
// When interrupt_pin is configured, pin_mode() already auto-enables CHANGE
|
||||
// interrupt for input pins, so skip the explicit call if the user didn't
|
||||
// override the default (NO_INTERRUPT)
|
||||
if (this->interrupt_mode_ != MCP23XXX_NO_INTERRUPT || this->parent_->get_interrupt_pin() == nullptr) {
|
||||
this->parent_->pin_interrupt_mode(this->pin_, this->interrupt_mode_);
|
||||
}
|
||||
}
|
||||
template<uint8_t N> void MCP23XXXGPIOPin<N>::pin_mode(gpio::Flags flags) { this->parent_->pin_mode(this->pin_, flags); }
|
||||
template<uint8_t N> bool MCP23XXXGPIOPin<N>::digital_read() {
|
||||
|
||||
@@ -16,6 +16,7 @@ template<uint8_t N> class MCP23XXXBase : public Component, public gpio_expander:
|
||||
|
||||
void set_open_drain_ints(const bool value) { this->open_drain_ints_ = value; }
|
||||
void set_interrupt_pin(InternalGPIOPin *pin) { this->interrupt_pin_ = pin; }
|
||||
InternalGPIOPin *get_interrupt_pin() const { return this->interrupt_pin_; }
|
||||
float get_setup_priority() const override { return setup_priority::IO; }
|
||||
|
||||
void loop() override {
|
||||
|
||||
Reference in New Issue
Block a user