1#ifndef AdafruitPCF8575ExpanderAdapter_h
2#define AdafruitPCF8575ExpanderAdapter_h
4#include <Adafruit_PCF8575.h>
6#include "GpioExpanderAdapter/GpioExpanderAdapter.h"
7#include "PinAdapter/PinAdapter.h"
40 delayMicroseconds(400);
41 pinStates = pcf.digitalReadWord();
52 bool begin(uint8_t i2c_addr, TwoWire *wire = &Wire) {
53 bool ret = pcf.begin(i2c_addr, wire);
54 delayMicroseconds(400);
55 pinStates = pcf.digitalReadWord();
65 pinStates = pcf.digitalReadWord();
74 void attachPin(
byte pin,
int mode = INPUT_PULLUP)
override {
75 pcf.pinMode(pin, mode);
86 bool read(
byte pin)
override {
87 return bitRead(pinStates, pin);
98 return pcf.digitalRead(pin);
110 pcf.digitalWrite(pin, state);
124 Adafruit_PCF8575 pcf;
125 uint16_t pinStates = 0;
An implementation of the GpioExpanderAdapter For Adafruit's PCF8575 library.
Definition: AdafruitPCF8575ExpanderAdapter.h:15
AdafruitPCF8575ExpanderAdapter()
Construct a AdafruitPCF8575ExpanderAdapter. An Adafruit_PCF8575 instance will be created for you.
Definition: AdafruitPCF8575ExpanderAdapter.h:23
bool read(byte pin) override
Returns the state of a pin on the expander.
Definition: AdafruitPCF8575ExpanderAdapter.h:86
bool updateAndRead(byte pin)
Update the expander over I2C and return a pin state. Not recommended, use a single uptate() and then ...
Definition: AdafruitPCF8575ExpanderAdapter.h:97
bool begin(uint8_t i2c_addr, TwoWire *wire=&Wire)
Use this method instead of the default begin() to specify a different I2C addreess.
Definition: AdafruitPCF8575ExpanderAdapter.h:52
void write(byte pin, bool state)
Write bool state to a pin.
Definition: AdafruitPCF8575ExpanderAdapter.h:109
void update() override
Update the state of all input pins (called from loop() before updating EventButtons)
Definition: AdafruitPCF8575ExpanderAdapter.h:64
void attachPin(byte pin, int mode=INPUT_PULLUP) override
Attach a pin and set its pin mode.
Definition: AdafruitPCF8575ExpanderAdapter.h:74
void begin() override
The default begin for a GPIOExpanderAdapter will use the default I2C address for the PCF8575.
Definition: AdafruitPCF8575ExpanderAdapter.h:38
bool canWrite()
The PCF8575 can write a pins state.
Definition: AdafruitPCF8575ExpanderAdapter.h:118
AdafruitPCF8575ExpanderAdapter(Adafruit_PCF8575 &_pcf)
Construct a AdafruitPCF8575ExpanderAdapter with an already created Adafruit_PCF8575 instance.
Definition: AdafruitPCF8575ExpanderAdapter.h:30
The base class/interface specification for GPIO expanders.
Definition: GpioExpanderAdapter.h:10