ShiftRegGPIOXpander Library for ESP32 (Arduino) v2.1.0
A library that provides an easy mechanism to add GPIO digital output pins by using Shift Registers
Loading...
Searching...
No Matches
SRGVXVPort Class Reference

A class that models Virtual Ports from the resources provided by a ShiftRegGPIOXpander object. More...

#include <ShiftRegGPIOXpander_ESP32.h>

Detailed Description

A class that models Virtual Ports from the resources provided by a ShiftRegGPIOXpander object.

The Virtual Ports are a set 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, as 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 of use is a crossroads traffic light controller, four different traffic lights, one for each direction, totalling 12 pins, is 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 SRGVXVPort 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 remember the real pin numbers in the ShiftRegGPIOXpander object.

Note
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, and the 32-bits registers are a superset of the 16-bits registers. The user can use the virtual ports as they see fit, but the library will not provide any mechanism to prevent overlapping virtual ports.