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
HC165ExpanderAdapter Class Reference

Description

An implementation of the GpioExpanderAdapter using 74HC165 shift register(s)

Datasheet: https://www.ti.com/lit/ds/symlink/sn74hc165.pdf

Supports up to 4 cascaded 74HC165 shift registers, returning 32 pin states (read only)

pin 0 is pin H (pin 7 is pin A) on the first 74HC165, pin 8 is a pin H on the second 74HC165, etc

#include <HC165ExpanderAdapter.h>

Inheritance diagram for HC165ExpanderAdapter:
Inheritance graph
[legend]

Public Member Functions

 HC165ExpanderAdapter (byte dataPin, byte clockPin, byte shldPin, byte cascadeLength=cascadeDefaultLength)
 Construct a new HC165ExpanderAdapter. More...
 
void begin () override
 Initialize the pin expander. More...
 
void update () override
 Read the state of pins on the 74HC165 cascade. More...
 
bool read (byte pin) override
 Returns the state of a pin on the expander. More...
 
void attachPin (byte pin, int mode=INPUT_PULLUP) override
 pinMode not supported by 74HC165 so do nothing 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

◆ HC165ExpanderAdapter()

HC165ExpanderAdapter::HC165ExpanderAdapter ( byte  dataPin,
byte  clockPin,
byte  shldPin,
byte  cascadeLength = cascadeDefaultLength 
)
inline

Construct a new HC165ExpanderAdapter.

Parameters
dataPinSerial data
clockPinUsed to shift to next bit
shldPinShift/Load input
cascadeLengthThe number of 74HC165s chained together (1-4, default is 1)

Member Function Documentation

◆ attachPin()

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

pinMode not supported by 74HC165 so do nothing

Parameters
pin
mode

Implements GpioExpanderAdapter.

◆ begin()

void HC165ExpanderAdapter::begin ( )
inlineoverridevirtual

Initialize the pin expander.

Implements GpioExpanderAdapter.

◆ read()

bool HC165ExpanderAdapter::read ( byte  pin)
inlineoverridevirtual

Returns the state of a pin on the expander.

Returns
true/HIGH
false/LOW

Implements GpioExpanderAdapter.

◆ update()

void HC165ExpanderAdapter::update ( )
inlineoverridevirtual

Read the state of pins on the 74HC165 cascade.

Implements GpioExpanderAdapter.


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