An implementation of the GpioExpanderAdapter For Adafruit's PCF8574 library.
Details: https://learn.adafruit.com/adafruit-pcf8574
#include <AdafruitPCF8574ExpanderAdapter.h>
◆ AdafruitPCF8574ExpanderAdapter() [1/2]
| AdafruitPCF8574ExpanderAdapter::AdafruitPCF8574ExpanderAdapter |
( |
| ) |
|
|
inline |
Construct a AdafruitPCF8574ExpanderAdapter. An Adafruit_PCF8574 instance will be created for you.
This will create and Adafruit_PCF8574 on the stack - creating one on the heap causes a crash as the Adafruit lib tries to delete an object that doesn't yet exist for ESP32 in the begin().
◆ AdafruitPCF8574ExpanderAdapter() [2/2]
| AdafruitPCF8574ExpanderAdapter::AdafruitPCF8574ExpanderAdapter |
( |
Adafruit_PCF8574 & |
_pcf | ) |
|
|
inline |
◆ attachPin()
| void AdafruitPCF8574ExpanderAdapter::attachPin |
( |
byte |
pin, |
|
|
int |
mode = INPUT_PULLUP |
|
) |
| |
|
inlineoverridevirtual |
Attach a pin and set its pin mode.
- Parameters
-
| pin | The pin number on the expander |
| mode | Default INPUT_PULLUP |
Implements GpioExpanderAdapter.
◆ begin() [1/2]
| void AdafruitPCF8574ExpanderAdapter::begin |
( |
void |
| ) |
|
|
inlineoverridevirtual |
The default begin for a GPIOExpanderAdapter will use the default I2C address for the PCF8574.
Implements GpioExpanderAdapter.
◆ begin() [2/2]
| bool AdafruitPCF8574ExpanderAdapter::begin |
( |
uint8_t |
i2c_addr, |
|
|
TwoWire * |
wire = &Wire |
|
) |
| |
|
inline |
Use this method instead of the default begin() to specify a different I2C addreess and optional Wire.
- Parameters
-
| i2c_addr | The I2C address to use for the PCF8574 |
| wire | Optional |
- Returns
- true
-
false
◆ canWrite()
| bool AdafruitPCF8574ExpanderAdapter::canWrite |
( |
| ) |
|
|
inline |
The PCF8574 can write a pins state.
- Returns
- true
◆ read()
| bool AdafruitPCF8574ExpanderAdapter::read |
( |
byte |
pin | ) |
|
|
inlineoverridevirtual |
Returns the state of a pin on the expander.
- Parameters
-
| pin | The pin number on the expander board |
- Returns
- true/HIGH
-
false/LOW
Implements GpioExpanderAdapter.
◆ update()
| void AdafruitPCF8574ExpanderAdapter::update |
( |
| ) |
|
|
inlineoverridevirtual |
Update the state of all input pins (called from loop() before updating EventButtons)
Implements GpioExpanderAdapter.
◆ updateAndRead()
| bool AdafruitPCF8574ExpanderAdapter::updateAndRead |
( |
byte |
pin | ) |
|
|
inline |
Update the expander over I2C and return a pin state. Not recommended, use a single uptate() and then multiple pin read()s in loop().
- Parameters
-
| pin | The pin number on the expander board |
- Returns
- true/HIGH
-
false/LOW
◆ write()
| void AdafruitPCF8574ExpanderAdapter::write |
( |
byte |
pin, |
|
|
bool |
state |
|
) |
| |
|
inline |
Write bool state to a pin.
Sets the pin state directlu over I2C
- Parameters
-
| pin | The pin number on the expander |
| state | true/false or HIGH/LOW |
The documentation for this class was generated from the following file: