pca9554 cache reads (#5137)

This commit is contained in:
Steve Rodgers
2023-08-11 17:50:33 -07:00
committed by GitHub
parent 5cb21324a1
commit 1269bf9791
2 changed files with 29 additions and 2 deletions
+6
View File
@@ -13,6 +13,8 @@ class PCA9554Component : public Component, public i2c::I2CDevice {
/// Check i2c availability and setup masks
void setup() override;
/// Poll for input changes periodically
void loop() override;
/// Helper function to read the value of a pin.
bool digital_read(uint8_t pin);
/// Helper function to write the value of a pin.
@@ -22,6 +24,8 @@ class PCA9554Component : public Component, public i2c::I2CDevice {
float get_setup_priority() const override;
float get_loop_priority() const override;
void dump_config() override;
protected:
@@ -35,6 +39,8 @@ class PCA9554Component : public Component, public i2c::I2CDevice {
uint8_t output_mask_{0x00};
/// The state of the actual input pin states - 1 means HIGH, 0 means LOW
uint8_t input_mask_{0x00};
/// Flags to check if read previously during this loop
uint8_t was_previously_read_ = {0x00};
/// Storage for last I2C error seen
esphome::i2c::ErrorCode last_error_;
};