3#ifndef RobTillaartPCF8575ExpanderAdapter_h
4#define RobTillaartPCF8575ExpanderAdapter_h
8#include "GpioExpanderAdapter/GpioExpanderAdapter.h"
9#include "PinAdapter/PinAdapter.h"
38 : pcf(deviceAddress, wire)
56 delayMicroseconds(400);
57 pinStates = pcf.read16();
65 pinStates = pcf.read16();
74 void attachPin(
byte pin,
int mode = INPUT_PULLUP)
override {
85 bool read(
byte pin)
override {
86 return bitRead(pinStates, pin);
122 uint16_t pinStates = 0;
The base class/interface specification for GPIO expanders.
Definition: GpioExpanderAdapter.h:10
An implementation of the GpioExpanderAdapter RobTillaart's PCF8575 library.
Definition: RobTillaartPCF8575ExpanderAdapter.h:19
bool read(byte pin) override
Returns the state of a pin on the expander.
Definition: RobTillaartPCF8575ExpanderAdapter.h:85
bool updateAndRead(byte pin)
Update the expander over I2C and return a pin state. Not recommended, use a single uptate() and then ...
Definition: RobTillaartPCF8575ExpanderAdapter.h:97
void attachPin(byte pin, int mode=INPUT_PULLUP) override
Attach a pin and set its pin mode.
Definition: RobTillaartPCF8575ExpanderAdapter.h:74
void update() override
Update the state of all input pins (called from loop() before updating EventButtons)
Definition: RobTillaartPCF8575ExpanderAdapter.h:64
void begin() override
The default begin for a GPIOExpanderAdapter.
Definition: RobTillaartPCF8575ExpanderAdapter.h:54
bool canWrite()
The MCP23017 can write a pins state.
Definition: RobTillaartPCF8575ExpanderAdapter.h:115
RobTillaartPCF8575ExpanderAdapter(const uint8_t deviceAddress, TwoWire *wire=&Wire)
Construct a RobTillaartPCF8575ExpanderAdapter using a specified I2C address and otional Wire.
Definition: RobTillaartPCF8575ExpanderAdapter.h:37
RobTillaartPCF8575ExpanderAdapter()
Construct a RobTillaartPCF8575ExpanderAdapter using the default I2C address.
Definition: RobTillaartPCF8575ExpanderAdapter.h:27
RobTillaartPCF8575ExpanderAdapter(PCF8575 &_pcf)
Construct a RobTillaartPCF8575ExpanderAdapter using an already created PCF8575 instance.
Definition: RobTillaartPCF8575ExpanderAdapter.h:46
void write(byte pin, bool state)
Write bool state to a pin.
Definition: RobTillaartPCF8575ExpanderAdapter.h:107