42#ifndef _SHIFTREGGPIOXPANDER_ESP32_H_
43#define _SHIFTREGGPIOXPANDER_ESP32_H_
73 bool _copyMainToAux(
const bool &overWriteIfExists =
true);
89 bool _moveAuxToMain();
101 bool _sendAllSRCntnt();
111 bool _sendSnglSRCntnt(
const uint8_t &data);
114 SemaphoreHandle_t _SRGXAuxBffrMtx;
115 SemaphoreHandle_t _SRGXMnBffrMtx;
117 uint8_t* _mainBuffrArryPtr{};
118 uint8_t* _auxBuffrArryPtr{
nullptr};
119 uint8_t _maxSRGXPin{};
163 bool begin(uint8_t* initCntnt =
nullptr);
208 bool digitalReadSgmntSr(
const uint8_t &strtPin,
const uint8_t &pinsQty, uint16_t &bffrSgmnt);
392 bool flipBit(
const uint8_t &srPin);
453 bool resetBit(
const uint8_t &srPin);
463 bool setBit(
const uint8_t &srPin);
508 bool stampSgmntOverMain(uint8_t* newSgmntPtr,
const uint8_t &strtPin,
const uint8_t &pinsQty);
536 friend class ShiftRegGPIOXpander;
540 const static uint8_t _maxPortPinsQty{16};
543 ShiftRegGPIOXpander* _SRGXPtr{
nullptr};
547 uint8_t* _srgxStampMskPtr{
nullptr};
548 uint16_t _vportBuffer{0};
552 uint16_t _vportMaxVal{0};
554 bool _buildSRGXVPortMsk(uint8_t* &maskPtr);
557 SemaphoreHandle_t _SRGXVPortMskMtx;
574 SRGXVPort(ShiftRegGPIOXpander* SRGXPtr, uint8_t strtPin, uint8_t pinsQty);
586 bool begin(uint16_t initCntnt);
616 bool flipBit(
const uint8_t &srPin);
654 bool resetBit(
const uint8_t &srPin);
662 bool setBit(
const uint8_t &srPin);
A class that models Virtual Ports from the resources provided by a ShiftRegGPIOXpander object.
Definition ShiftRegGPIOXpander_ESP32.h:530
uint8_t digitalReadSr(const uint8_t &srPin)
Reads the state of a specific pin in the virtual port.
Definition ShiftRegGPIOXpander_ESP32.cpp:708
bool writePort(uint16_t newPortVal)
Sets the state of the pins in the Main Buffer (i.e. the GPIOXpander pins) according to the provided v...
Definition ShiftRegGPIOXpander_ESP32.cpp:791
uint16_t getVPortMaxVal()
Returns the maximum value that can be set in the virtual port.
Definition ShiftRegGPIOXpander_ESP32.cpp:752
bool begin(uint16_t initCntnt)
Begins the virtual port, setting the initial state of the VPort pins.
Definition ShiftRegGPIOXpander_ESP32.cpp:664
uint8_t * getStampMask()
Returns a pointer to the mask built to stamp the virtual port over the Main Buffer of the ShiftRegGPI...
Definition ShiftRegGPIOXpander_ESP32.cpp:747
bool flipBit(const uint8_t &srPin)
Toggles the state of a specific pin in the virtual port.
Definition ShiftRegGPIOXpander_ESP32.cpp:731
bool resetBit(const uint8_t &srPin)
Sets the state of a pin to LOW (0x00/Reset) in the virtual port.
Definition ShiftRegGPIOXpander_ESP32.cpp:767
uint16_t readPort()
Reads the state of the virtual port as an integer value.
Definition ShiftRegGPIOXpander_ESP32.cpp:757
bool digitalWriteSr(const uint8_t &srPin, const uint8_t &value)
Sets the state of a specific pin in the virtual port, either HIGH (0x01/Set) or LOW (0x00/Reset).
Definition ShiftRegGPIOXpander_ESP32.cpp:720
SRGXVPort()
Default constructor.
Definition ShiftRegGPIOXpander_ESP32.cpp:639
bool setBit(const uint8_t &srPin)
Sets the state of a pin to HIGH (0x01/Set) in the virtual port.
Definition ShiftRegGPIOXpander_ESP32.cpp:779
~SRGXVPort()
Class destructor.
Definition ShiftRegGPIOXpander_ESP32.cpp:656
ShiftRegGPIOXpander * getSRGXPtr()
Returns a pointer to the ShiftRegGPIOXpander object that provides the resources for the virtual port.
Definition ShiftRegGPIOXpander_ESP32.cpp:742
bool begin(uint8_t *initCntnt=nullptr)
GPIOXpander object setup and activation.
Definition ShiftRegGPIOXpander_ESP32.cpp:67
bool stampOverMain(uint8_t *newCntntPtr)
Sets all of the output pins of the shift register to new provided values at once.
Definition ShiftRegGPIOXpander_ESP32.cpp:587
bool digitalWriteSrMaskSet(uint8_t *setMask)
Modifies the Main buffer contents by setting simultaneously certain pins.
Definition ShiftRegGPIOXpander_ESP32.cpp:352
bool isValid(SRGXVPort &VPort)
Checks if the provided SRGXVPort object is valid.
Definition ShiftRegGPIOXpander_ESP32.cpp:457
bool resetBit(const uint8_t &srPin)
Sets a specific pin to LOW (0x00/Reset) in the Main Buffer.
Definition ShiftRegGPIOXpander_ESP32.cpp:493
bool digitalReadSgmntSr(const uint8_t &strtPin, const uint8_t &pinsQty, uint16_t &bffrSgmnt)
Returns a 16-bits value containing a zero-based segment of the Main Buffer.
Definition ShiftRegGPIOXpander_ESP32.cpp:138
uint8_t getSrQty()
Return the quantity of shift registers composing the GPIOXtender object.
Definition ShiftRegGPIOXpander_ESP32.cpp:452
bool 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_ESP32.cpp:380
bool digitalToggleSr(const uint8_t &srPin)
Toggles the state of a specific pin.
Definition ShiftRegGPIOXpander_ESP32.cpp:179
uint8_t getMaxSRGXPin()
Return the greatest valid pin number.
Definition ShiftRegGPIOXpander_ESP32.cpp:447
bool setBit(const uint8_t &srPin)
Sets a specific pin to HIGH (0x01/Set) in the Main Buffer.
Definition ShiftRegGPIOXpander_ESP32.cpp:541
bool copyMainToAux(const bool &overWriteIfExists=true)
Copies the Buffer content to the Auxiliary Buffer.
Definition ShiftRegGPIOXpander_ESP32.cpp:112
bool moveAuxToMain()
Moves the data in the Auxiliary to the Main.
Definition ShiftRegGPIOXpander_ESP32.cpp:477
ShiftRegGPIOXpander()
Class default constructor.
Definition ShiftRegGPIOXpander_ESP32.cpp:45
bool digitalWriteSr(const uint8_t &srPin, const uint8_t &value)
Set a specific pin to either HIGH (0x01) or LOW (0x00).
Definition ShiftRegGPIOXpander_ESP32.cpp:265
~ShiftRegGPIOXpander()
Class destructor.
Definition ShiftRegGPIOXpander_ESP32.cpp:55
bool stampSgmntOverMain(uint8_t *newSgmntPtr, const uint8_t &strtPin, const uint8_t &pinsQty)
Sets the value of a set of consecutive pins (the segment) in the Main Buffer.
Definition ShiftRegGPIOXpander_ESP32.cpp:614
bool digitalWriteSrAllSet()
Sets all the pins to HIGH (0x01).
Definition ShiftRegGPIOXpander_ESP32.cpp:306
uint8_t * getMainBuffPtr()
Retrieves the pointer to the Main Buffer.
Definition ShiftRegGPIOXpander_ESP32.cpp:442
bool stampMaskOverMain(uint8_t *maskPtr, uint8_t *valsPtr)
Sets the value of several scattered (or not) pins in the Main Buffer, according to the provided mask ...
Definition ShiftRegGPIOXpander_ESP32.cpp:552
bool digitalToggleSrMask(uint8_t *toggleMask)
Toggles the state of the pins in the Main Buffer according to the provided mask.
Definition ShiftRegGPIOXpander_ESP32.cpp:218
bool digitalToggleSrAll()
Toggles the state of all the pins.
Definition ShiftRegGPIOXpander_ESP32.cpp:199
bool flipBit(const uint8_t &srPin)
Toggles the state of a specific pin in the Main Buffer.
Definition ShiftRegGPIOXpander_ESP32.cpp:431
bool digitalWriteSrAllReset()
Sets all the pins to LOW (0x00/Reset).
Definition ShiftRegGPIOXpander_ESP32.cpp:288
bool digitalToggleSrToAux(const uint8_t &srPin)
Toggles the state of a specific pin in the Auxiliary Buffer.
Definition ShiftRegGPIOXpander_ESP32.cpp:246
SRGXVPort createSRGXVPort(const uint8_t &strtPin, const uint8_t &pinsQty)
Instantiate a SRGXVPort object.
Definition ShiftRegGPIOXpander_ESP32.cpp:131
uint8_t digitalReadSr(const uint8_t &srPin)
Returns the state of the requested pin.
Definition ShiftRegGPIOXpander_ESP32.cpp:161
void end()
Method provided for ending any relevant activation procedures made by the begin(uint8_t*) method.
Definition ShiftRegGPIOXpander_ESP32.cpp:426
bool discardAux()
Deletes the Auxiliary Buffer.
Definition ShiftRegGPIOXpander_ESP32.cpp:411
bool digitalWriteSrMaskReset(uint8_t *resetMask)
Modifies the Main buffer contents by resetting simultaneously certain pins.
Definition ShiftRegGPIOXpander_ESP32.cpp:324