ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
cached_gpio_component.h
Go to the documentation of this file.
1#pragma once
2
5#include "esphome/core/hal.h"
6
8
12 public:
14 float get_setup_priority() const override { return setup_priority::IO; }
15
16 protected:
25 if (this->interrupt_pin_ == nullptr)
26 this->enable_loop();
27 }
28
30};
31
33template<typename T, uint16_t N>
35 public:
36 void loop() override {
37 this->reset_pin_cache_();
38 if (this->interrupt_pin_ != nullptr)
40 }
41
42 protected:
45 if (this->attach_interrupt_pin_())
46 this->set_invalidate_on_read_(false);
47 }
48};
49
50} // namespace esphome::gpio_expander
void enable_loop()
Enable this component's loop.
Definition component.h:248
Base for expanders that cache reads per loop. With an interrupt pin the cache stays valid until INT f...
A class to cache the read state of a GPIO expander.
Definition cached_gpio.h:29
void reset_pin_cache_()
Invalidate cache. This function should be called in component loop().
Definition cached_gpio.h:78
void set_invalidate_on_read_(bool invalidate)
Control whether digital_read() invalidates the pin's cache entry after reading.
Definition cached_gpio.h:83
Component side of a cached GPIO expander with an optional active-low INT line.
bool attach_interrupt_pin_()
Attach the falling-edge ISR when there is an interrupt pin, then disable the loop until an input need...
void disable_loop_when_released_()
The loop runs again after the INT line falls; stop it once the line is released (HIGH).
void enable_polling_loop_()
Call from pin_mode() for an input pin: without an interrupt pin the loop polls instead.
constexpr float IO
For components that represent GPIO pins like PCF8573.
Definition component.h:41