|
| ~SRGXVPort () |
| Class destructor.
|
bool | begin (uint16_t initCntnt) |
| Begins the virtual port, setting the initial state of the VPort pins.
|
int | digitalRead (const uint8_t &srPin) |
| Returns the state of the requested pin of the virtual port (SRGXVPort).
|
uint8_t | digitalReadSr (const uint8_t &srPin) |
| Reads the state of a specific pin in the virtual port.
|
void | digitalWrite (const uint8_t &srPin, const uint8_t &value) |
| Set a specific pin to either HIGH (0x01) or LOW (0x00).
|
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).
|
bool | flipBit (const uint8_t &srPin) |
| Toggles the state of a specific pin in the virtual port.
|
ShiftRegGPIOXpander * | getSRGXPtr () |
| Returns a pointer to the ShiftRegGPIOXpander object that provides the resources for the virtual port.
|
uint8_t * | getStampMask () |
| Returns a pointer to the mask built to stamp the virtual port over the Main Buffer of the ShiftRegGPIOXpander object.
|
uint16_t | getVPortMaxVal () |
| Returns the maximum value that can be set in the virtual port.
|
uint16_t | readPort () |
| Reads the state of the virtual port as an unsigned integer value.
|
bool | resetBit (const uint8_t &srPin) |
| Sets the state of a pin to LOW (0x00/Reset) in the virtual port.
|
bool | setBit (const uint8_t &srPin) |
| Sets the state of a pin to HIGH (0x01/Set) in the virtual port.
|
bool | writePort (uint16_t newPortVal) |
| Sets the state of the pins composing the SRGXVPort in the Main Buffer (i.e. the GPIOXpander pins) according to the provided value.
|
Public Member Functions inherited from ShiftRegGPIOXpander |
| ShiftRegGPIOXpander () |
| Class default constructor.
|
| ShiftRegGPIOXpander (uint8_t ds, uint8_t sh_cp, uint8_t st_cp, uint8_t srQty=1) |
| Class constructor.
|
| ~ShiftRegGPIOXpander () |
| Class destructor.
|
bool | begin (uint8_t *initCntnt=nullptr) |
| GPIOXpander object setup and activation.
|
bool | copyMainToAux (const bool &overWriteIfExists=true) |
| Copies the Buffer content to the Auxiliary Buffer.
|
SRGXVPort | createSRGXVPort (const uint8_t &strtPin, const uint8_t &pinsQty) |
| Instantiate a SRGXVPort object.
|
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.
|
int | digitalRead (const uint8_t &srPin) |
| Returns the state of the requested pin of the ShiftRegGPIOXpander.
|
uint8_t | digitalReadSr (const uint8_t &srPin) |
| Returns the state of the requested pin.
|
bool | digitalToggleSr (const uint8_t &srPin) |
| Toggles the state of a specific pin.
|
bool | digitalToggleSrAll () |
| Toggles the state of all the pins.
|
bool | digitalToggleSrMask (uint8_t *toggleMask) |
| Toggles the state of the pins in the Main Buffer according to the provided mask.
|
bool | digitalToggleSrToAux (const uint8_t &srPin) |
| Toggles the state of a specific pin in the Auxiliary Buffer.
|
void | digitalWrite (const uint8_t &srPin, const uint8_t &value) |
| Set a specific pin to either HIGH (0x01) or LOW (0x00).
|
bool | digitalWriteSr (const uint8_t &srPin, const uint8_t &value) |
| Set a specific pin to either HIGH (0x01) or LOW (0x00).
|
bool | digitalWriteSrAllReset () |
| Sets all the pins to LOW (0x00/Reset).
|
bool | digitalWriteSrAllSet () |
| Sets all the pins to HIGH (0x01).
|
bool | digitalWriteSrMaskReset (uint8_t *resetMask) |
| Modifies the Main buffer contents by resetting simultaneously certain pins.
|
bool | digitalWriteSrMaskSet (uint8_t *setMask) |
| Modifies the Main buffer contents by setting simultaneously certain pins.
|
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.
|
bool | discardAux () |
| Deletes the Auxiliary Buffer.
|
void | end () |
| Method provided for ending any relevant activation procedures made by the begin(uint8_t*) method.
|
bool | flipBit (const uint8_t &srPin) |
| Toggles the state of a specific pin in the Main Buffer.
|
uint8_t * | getMainBuffPtr () |
| Retrieves the pointer to the Main Buffer.
|
uint8_t | getMaxSRGXPin () |
| Return the greatest valid pin number.
|
uint8_t | getSrQty () |
| Return the quantity of shift registers composing the GPIOXtender object.
|
bool | isValid (SRGXVPort &VPort) |
| Checks if the provided SRGXVPort object is valid.
|
bool | moveAuxToMain () |
| Moves the data in the Auxiliary to the Main.
|
bool | resetBit (const uint8_t &srPin) |
| Sets a specific pin to LOW (0x00/Reset) in the Main Buffer.
|
bool | setBit (const uint8_t &srPin) |
| Sets a specific pin to HIGH (0x01/Set) in the Main Buffer.
|
bool | stampMaskOverMain (uint8_t *maskPtr, uint8_t *valsPtr) |
| Sets the value of several pins, scattered or contiguous, in the Main Buffer, according to the provided mask and values.
|
bool | stampOverMain (uint8_t *newCntntPtr) |
| Sets all of the output pins of the shift register to new provided values at once.
|
bool | stampSgmntOverMain (uint8_t *newSgmntPtr, const uint8_t &strtPin, const uint8_t &pinsQty) |
| Sets the value of a number of consecutive pins (the segment) in the Main Buffer.
|
A class that models Virtual Ports from the resources provided by a ShiftRegGPIOXpander object.
The Virtual Ports are sets of pins that can be used as a group, and are defined by the user. The pins are a contiguous subset of the pins available in the ShiftRegGPIOXpander object. The Virtual Ports main advantage is to provide a means to focus on a group of pins that are somehow associated: are meant to manage the communications with a specific device or group of devices, manage different related signals, etc.
The class objects provide the means to translate the pin numbers from the Virtual Port to the real pins in the ShiftRegGPIOXpander object.
A simple example use case is a crossroads traffic light controller, four different traffic lights, one for each direction, totalling 12 pins, might be solved by using a ShiftRegGPIOXpander object with 2 shift registers. Using the ShiftRegGPIOXpander object directly would require the user to remember that the first pin of the first traffic light is pin 0, the second traffic light starts at pin 3, and so on. Using a SRGXVPort object for each traffic light would allow the user to create a virtual port for each traffic light. Pin 0 of each virtual port would be the red light, pin 1 would be the yellow light, and pin 2 would be the green light. The user would then be able to use the virtual port objects to manipulate the traffic lights without having to convert each light to the real pin numbers in the ShiftRegGPIOXpander object, and make the addition of new traffic lights easier, as the managing methods would be the same for each virtual port.
- Note
- The SRGXVPort class has set a maximum of 16 pins that can be used in each virtual port. The number of pins assigned will be checked against the maximum number of pins available in the ShiftRegGPIOXpander object.
-
The open possibility of creating virtual ports that overlap pins in the ShiftRegGPIOXpander object is not considered a problem, even if one virtual port includes all the pins of another virtual port. Take as an example the case of the x86 Intel processors, where the 64-bits registers are a superset of the 32-bits registers, the 32-bits registers are a superset of the 16-bits registers and the 16-bits are superset of 8-bits registers, with the possibility of managing the 64 bits at once or subsets by using the corresponding designations provided. The user can manage the virtual ports as they see fit, but the library will not provide any mechanism to prevent overlapping virtual ports.
- Warning
- The SRGXVPort class uses the buffer memory provided by the ShiftRegGPIOXpander object to handle the pins state. The user might decide to use the SRGXVPort objects to manipulate the pins state, or use the ShiftRegGPIOXpander object directly. The classes are designed to allow the user to use both methods, but the user must be aware that the state of a pin might be modified by the shiftRegGPIOXpander object directly, and by any and all the SRGXPVPort objects that same pin is part of.