InputEvents v1.5.2
An easy to use but comprehensive Event Library for Buttons, Encoders, Encoder Buttons, Analog Inputs, Joysticks and Switches.
Public Member Functions | List of all members
RobTillaartPCF8575ExpanderAdapter Class Reference

Description

An implementation of the GpioExpanderAdapter RobTillaart's PCF8575 library.

Note: You may need to call Wire.begin() in your sketch (if not already called) as the underlying library does not do so.

Repository: https://github.com/RobTillaart/PCF8575

#include <RobTillaartPCF8575ExpanderAdapter.h>

Inheritance diagram for RobTillaartPCF8575ExpanderAdapter:
Inheritance graph
[legend]

Public Member Functions

 RobTillaartPCF8575ExpanderAdapter ()
 Construct a RobTillaartPCF8575ExpanderAdapter using the default I2C address.
 
 RobTillaartPCF8575ExpanderAdapter (const uint8_t deviceAddress, TwoWire *wire=&Wire)
 Construct a RobTillaartPCF8575ExpanderAdapter using a specified I2C address and otional Wire. More...
 
 RobTillaartPCF8575ExpanderAdapter (PCF8575 &_pcf)
 Construct a RobTillaartPCF8575ExpanderAdapter using an already created PCF8575 instance. More...
 
void begin () override
 The default begin for a GPIOExpanderAdapter. More...
 
void update () override
 Update the state of all input pins (called from loop() before updating EventButtons) More...
 
void attachPin (byte pin, int mode=INPUT_PULLUP) override
 Attach a pin and set its pin mode. More...
 
bool read (byte pin) override
 Returns the state of a pin on the expander. More...
 
bool updateAndRead (byte pin)
 Update the expander over I2C and return a pin state. Not recommended, use a single uptate() and then multiple pin read()s in loop(). More...
 
void write (byte pin, bool state)
 Write bool state to a pin. More...
 
bool canWrite ()
 The MCP23017 can write a pins state. More...
 
- Public Member Functions inherited from GpioExpanderAdapter
virtual void begin ()=0
 Initialize the expander. (Idempotent) More...
 
virtual void update ()=0
 Read the state of all pins on the expander. More...
 
virtual bool read (byte pin)=0
 Returns the state of a pin on the expander. More...
 
virtual void attachPin (byte pin, int mode=INPUT_PULLUP)=0
 Use it to configure individual pin mode, if expander allows it. Not all of them do. More...
 
void write (byte pin, bool state)
 Optionally implemented by concrete GpioExpanderAdapters if they support writing to pins. More...
 
bool canWrite ()
 Returns true if the concrete GpioExpanderAdapter has implemented the write() method. More...
 

Constructor & Destructor Documentation

◆ RobTillaartPCF8575ExpanderAdapter() [1/2]

RobTillaartPCF8575ExpanderAdapter::RobTillaartPCF8575ExpanderAdapter ( const uint8_t  deviceAddress,
TwoWire *  wire = &Wire 
)
inline

Construct a RobTillaartPCF8575ExpanderAdapter using a specified I2C address and otional Wire.

Parameters
deviceAddress
wire

◆ RobTillaartPCF8575ExpanderAdapter() [2/2]

RobTillaartPCF8575ExpanderAdapter::RobTillaartPCF8575ExpanderAdapter ( PCF8575 &  _pcf)
inline

Construct a RobTillaartPCF8575ExpanderAdapter using an already created PCF8575 instance.

Parameters
_pcf

Member Function Documentation

◆ attachPin()

void RobTillaartPCF8575ExpanderAdapter::attachPin ( byte  pin,
int  mode = INPUT_PULLUP 
)
inlineoverridevirtual

Attach a pin and set its pin mode.

Parameters
pinThe pin number on the expander
modeDefault INPUT_PULLUP

Implements GpioExpanderAdapter.

◆ begin()

void RobTillaartPCF8575ExpanderAdapter::begin ( )
inlineoverridevirtual

The default begin for a GPIOExpanderAdapter.

Implements GpioExpanderAdapter.

◆ canWrite()

bool RobTillaartPCF8575ExpanderAdapter::canWrite ( )
inline

The MCP23017 can write a pins state.

Returns
true

◆ read()

bool RobTillaartPCF8575ExpanderAdapter::read ( byte  pin)
inlineoverridevirtual

Returns the state of a pin on the expander.

Parameters
pinThe pin number on the expander
Returns
true/HIGH
false/LOW

Implements GpioExpanderAdapter.

◆ update()

void RobTillaartPCF8575ExpanderAdapter::update ( )
inlineoverridevirtual

Update the state of all input pins (called from loop() before updating EventButtons)

Implements GpioExpanderAdapter.

◆ updateAndRead()

bool RobTillaartPCF8575ExpanderAdapter::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
pinThe pin number on the expander board
Returns
true/HIGH
false/LOW

◆ write()

void RobTillaartPCF8575ExpanderAdapter::write ( byte  pin,
bool  state 
)
inline

Write bool state to a pin.

Parameters
pinThe pin number on the expander
statetrue/false or HIGH/LOW

The documentation for this class was generated from the following file: