ESPHome  2024.3.2
Go to the documentation of this file.
1 #pragma once
4 #include "esphome/core/hal.h"
7 namespace esphome {
8 namespace pca6416a {
10 class PCA6416AComponent : public Component, public i2c::I2CDevice {
11  public:
12  PCA6416AComponent() = default;
15  void setup() override;
17  bool digital_read(uint8_t pin);
19  void digital_write(uint8_t pin, bool value);
21  void pin_mode(uint8_t pin, gpio::Flags flags);
23  float get_setup_priority() const override;
25  void dump_config() override;
27  protected:
28  bool read_register_(uint8_t reg, uint8_t *value);
29  bool write_register_(uint8_t reg, uint8_t value);
30  void update_register_(uint8_t pin, bool pin_value, uint8_t reg_addr);
33  uint8_t output_0_{0x00};
34  uint8_t output_1_{0x00};
38  bool has_pullup_{false};
39 };
42 class PCA6416AGPIOPin : public GPIOPin {
43  public:
44  void setup() override;
45  void pin_mode(gpio::Flags flags) override;
46  bool digital_read() override;
47  void digital_write(bool value) override;
48  std::string dump_summary() const override;
50  void set_parent(PCA6416AComponent *parent) { parent_ = parent; }
51  void set_pin(uint8_t pin) { pin_ = pin; }
52  void set_inverted(bool inverted) { inverted_ = inverted; }
53  void set_flags(gpio::Flags flags) { flags_ = flags; }
55  protected:
57  uint8_t pin_;
58  bool inverted_;
60 };
62 } // namespace pca6416a
63 } // namespace esphome
bool digital_read(uint8_t pin)
Helper function to read the value of a pin.
Definition: pca6416a.cpp:67
void set_flags(gpio::Flags flags)
Definition: pca6416a.h:53
void set_inverted(bool inverted)
Definition: pca6416a.h:52
bool write_register_(uint8_t reg, uint8_t value)
Definition: pca6416a.cpp:119
I2CRegister reg(uint8_t a_register)
calls the I2CRegister constructor
Definition: i2c.h:149
esphome::i2c::ErrorCode last_error_
Storage for last I2C error seen.
Definition: pca6416a.h:36
void digital_write(uint8_t pin, bool value)
Helper function to write the value of a pin.
Definition: pca6416a.cpp:75
bool has_pullup_
Only the PCAL6416A has pull-up resistors.
Definition: pca6416a.h:38
void update_register_(uint8_t pin, bool pin_value, uint8_t reg_addr)
Definition: pca6416a.cpp:135
void pin_mode(uint8_t pin, gpio::Flags flags)
Helper function to set the pin mode of a pin.
Definition: pca6416a.cpp:80
void set_parent(PCA6416AComponent *parent)
Definition: pca6416a.h:50
bool read_register_(uint8_t reg, uint8_t *value)
Definition: pca6416a.cpp:103
void setup() override
Check i2c availability and setup masks.
Definition: pca6416a.cpp:26
const uint32_t flags
Definition: stm32flash.h:85
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7
PCA6416AComponent * parent_
Definition: pca6416a.h:56
Helper class to expose a PCA6416A pin as an internal input GPIO pin.
Definition: pca6416a.h:42
Error codes returned by I2CBus and I2CDevice methods.
Definition: i2c_bus.h:11
float get_setup_priority() const override
Definition: pca6416a.cpp:161
uint8_t output_0_
The mask to write as output state - 1 means HIGH, 0 means LOW.
Definition: pca6416a.h:33
This Class provides the methods to read/write bytes from/to an i2c device.
Definition: i2c.h:133