ShiftRegGPIOXpander Library for ESP32 (Arduino) v1.1.0
A library that provides an easy mechanism to add GPIO digital output pins by using Shift Registers
Loading...
Searching...
No Matches
ShiftRegGPIOXpander.h
Go to the documentation of this file.
1
34#ifndef _ShiftRegGPIOXpander_ESP32_H_
35#define _ShiftRegGPIOXpander_ESP32_H_
36
37#include <Arduino.h>
38#include <stdint.h>
39
48private:
49 uint8_t _ds{};
50 uint8_t _sh_cp{};
51 uint8_t _st_cp{};
52 uint8_t _srQty{};
53
54 uint8_t* _srArryBuffPtr{};
55 uint8_t* _auxArryBuffPtr{nullptr};
56 uint8_t _maxSrPin{0};
57
58 bool _sendSnglSRCntnt(uint8_t data); // Sends the content of a single byte to a Shift Register filling it's internal buffer, but it does not latch it (it does not set the output pins of the shfit register to the buffered value). The latching must be done by the calling party.
59public:
81 ShiftRegGPIOXpander(uint8_t ds, uint8_t sh_cp, uint8_t st_cp, uint8_t srQty = 1, uint8_t* initCntnt = nullptr);
102 bool copyMainToAux(bool overWriteIfExists = true);
108 void discardAux();
122 uint8_t digitalReadSr(const uint8_t &srPin);
129 void digitalWriteSr(const uint8_t srPin, const uint8_t value);
151 void digitalWriteSrMaskReset(uint8_t* newResetMask);
165 void digitalWriteSrMaskSet(uint8_t* newSetMask);
176 void digitalWriteSrToAux(const uint8_t srPin, const uint8_t value);
184 uint8_t* getMainBuffPtr();
192 uint8_t getMaxPin();
200 uint8_t getSrQty();
213 bool moveAuxToMain(bool flushASAP = true);
228 bool stampOverMain(uint8_t* newCntntPtr);
242 bool sendAllSRCntnt();
243};
244
245#endif //ShiftRegGPIOXpander_ESP32_H_
A class that models a GPIO outputs pins extender through the use of 8-bits serial in paralell out (SI...
Definition ShiftRegGPIOXpander.h:47
bool stampOverMain(uint8_t *newCntntPtr)
Sets all of the output pins of the shift register to new provided values at once.
Definition ShiftRegGPIOXpander.cpp:278
uint8_t getSrQty()
Return the quantity of shift registers composing the GPIOXtender object.
Definition ShiftRegGPIOXpander.cpp:220
void digitalWriteSrMaskReset(uint8_t *newResetMask)
Modifies the Main buffer contents by resetting simultaneously certain pins.
Definition ShiftRegGPIOXpander.cpp:153
bool moveAuxToMain(bool flushASAP=true)
Moves the data in the Auxiliary to the Main.
Definition ShiftRegGPIOXpander.cpp:225
uint8_t getMaxPin()
Return the greatest valid pin number.
Definition ShiftRegGPIOXpander.cpp:215
ShiftRegGPIOXpander()
Class default constructor.
Definition ShiftRegGPIOXpander.cpp:35
void digitalWriteSrAllSet()
Sets all the pins to HIGH (0x01).
Definition ShiftRegGPIOXpander.cpp:140
~ShiftRegGPIOXpander()
Class destructor.
Definition ShiftRegGPIOXpander.cpp:64
void digitalWriteSrToAux(const uint8_t srPin, const uint8_t value)
Set a specific pin to either HIGH (0x01) or LOW (0x00) in the Auxiliary Buffer.
Definition ShiftRegGPIOXpander.cpp:179
uint8_t * getMainBuffPtr()
Retrieves the pointer to the Main Buffer.
Definition ShiftRegGPIOXpander.cpp:210
void digitalWriteSrAllReset()
Sets all the pins to LOW (0x00).
Definition ShiftRegGPIOXpander.cpp:127
void digitalWriteSrMaskSet(uint8_t *newSetMask)
Modifies the Main buffer contents by setting simultaneously certain pins.
Definition ShiftRegGPIOXpander.cpp:166
void digitalWriteSr(const uint8_t srPin, const uint8_t value)
Set a specific pin to either HIGH (0x01) or LOW (0x00).
Definition ShiftRegGPIOXpander.cpp:109
void discardAux()
Deletes the Auxiliary Buffer.
Definition ShiftRegGPIOXpander.cpp:197
bool sendAllSRCntnt()
Flushes the contents of the Buffer to the GPIO Extender.
Definition ShiftRegGPIOXpander.cpp:241
bool copyMainToAux(bool overWriteIfExists=true)
Copies the Buffer content to the Auxiliary Buffer
Definition ShiftRegGPIOXpander.cpp:75
uint8_t digitalReadSr(const uint8_t &srPin)
Returns the state of the requested pin.
Definition ShiftRegGPIOXpander.cpp:92