ESPHome 2025.5.0
|
A class to cache the read state of a GPIO expander. More...
#include <cached_gpio.h>
Public Member Functions | |
bool | digital_read (T pin) |
void | digital_write (T pin, bool value) |
Protected Member Functions | |
virtual bool | digital_read_hw (T pin)=0 |
Call component low level function to read GPIO state from device. | |
virtual bool | digital_read_cache (T pin)=0 |
Call component read function from internal cache. | |
virtual void | digital_write_hw (T pin, bool value)=0 |
Call component low level function to write GPIO state to device. | |
void | reset_pin_cache_ () |
Invalidate cache. This function should be called in component loop(). | |
Protected Attributes | |
const uint8_t | cache_byte_size_ = N / (sizeof(T) * BITS_PER_BYTE) |
std::array< bool, N/(sizeof(T) *BITS_PER_BYTE)> | read_cache_invalidated_ {} |
Static Protected Attributes | |
static const uint8_t | BITS_PER_BYTE = 8 |
A class to cache the read state of a GPIO expander.
This class caches reads between GPIO Pins which are on the same bank. This means that for reading whole Port (ex. 8 pins) component needs only one I2C/SPI read per main loop call. It assumes, that one bit in byte identifies one GPIO pin Template parameters: T - Type which represents internal register. Could be uint8_t or uint16_t. Adjust to match size of your internal GPIO bank register. N - Number of pins
Definition at line 18 of file cached_gpio.h.
|
inline |
Definition at line 20 of file cached_gpio.h.
|
protectedpure virtual |
Call component read function from internal cache.
Implemented in esphome::tca9555::TCA9555Component.
|
protectedpure virtual |
Call component low level function to read GPIO state from device.
Implemented in esphome::tca9555::TCA9555Component.
|
inline |
Definition at line 30 of file cached_gpio.h.
|
protectedpure virtual |
Call component low level function to write GPIO state to device.
Implemented in esphome::tca9555::TCA9555Component.
|
inlineprotected |
Invalidate cache. This function should be called in component loop().
Definition at line 42 of file cached_gpio.h.
|
staticprotected |
Definition at line 48 of file cached_gpio.h.
|
protected |
Definition at line 39 of file cached_gpio.h.
|
protected |
Definition at line 49 of file cached_gpio.h.