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
GpioExpanderAdapter Class Referenceabstract

Description

The base class/interface specification for GPIO expanders.

#include <GpioExpanderAdapter.h>

Inheritance diagram for GpioExpanderAdapter:
Inheritance graph
[legend]

Public Member Functions

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...
 

Member Function Documentation

◆ attachPin()

virtual void GpioExpanderAdapter::attachPin ( byte  pin,
int  mode = INPUT_PULLUP 
)
pure virtual

Use it to configure individual pin mode, if expander allows it. Not all of them do.

Implemented in AdafruitMCP23017ExpanderAdapter, AdafruitPCF8574ExpanderAdapter, AdafruitPCF8575ExpanderAdapter, HC165ExpanderAdapter, and RobTillaartPCF8575ExpanderAdapter.

◆ begin()

virtual void GpioExpanderAdapter::begin ( )
pure virtual

◆ canWrite()

bool GpioExpanderAdapter::canWrite ( )
inline

Returns true if the concrete GpioExpanderAdapter has implemented the write() method.

Returns
true The impemented GpioExpanderAdapter can write to pins.
false The default, ie unimplemented

◆ read()

virtual bool GpioExpanderAdapter::read ( byte  pin)
pure virtual

Returns the state of a pin on the expander.

Returns
true aka HIGH
false aka LOW

Implemented in AdafruitMCP23017ExpanderAdapter, AdafruitPCF8574ExpanderAdapter, AdafruitPCF8575ExpanderAdapter, HC165ExpanderAdapter, and RobTillaartPCF8575ExpanderAdapter.

◆ update()

virtual void GpioExpanderAdapter::update ( )
pure virtual

Read the state of all pins on the expander.

Expander pins generally cannot be read like regular GPIO pins, they have to be 'scanned' for their current state before reading individual pins.

Implemented in AdafruitMCP23017ExpanderAdapter, AdafruitPCF8574ExpanderAdapter, AdafruitPCF8575ExpanderAdapter, HC165ExpanderAdapter, and RobTillaartPCF8575ExpanderAdapter.

◆ write()

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

Optionally implemented by concrete GpioExpanderAdapters if they support writing to pins.

Not used by InputEvents but provided so 'app' code can write to the GPIO expander.

Parameters
pinThe pin number on the expander
stateHIGH or LOW (true/false)

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