Seven Segments Displays Agnostic Library for ESP32 (Arduino) v3.3.0
A library that provides a class that models a Seven Segment Display and provides an unified API through it's members independently of the display technology.
|
Base abstract class models a generic Seven Segment display hardware. More...
#include <SevenSegDispHw.h>
Public Member Functions | |
SevenSegDispHw () | |
Default class constructor. | |
SevenSegDispHw (uint8_t *ioPins, uint8_t dspDigits=4, bool commAnode=true, uint8_t dspDigitsQtyMax=0) | |
Class constructor. | |
virtual | ~SevenSegDispHw () |
Class destructor. | |
virtual bool | begin (uint32_t updtLps=0) |
Sets up the hardware display to work, and starts the display activities. | |
virtual bool | end () |
Reverts the begin(uint32_t) actions, stopping the display activities, turning the display off and freeing the resources used by the Seven Segment display hardware object. | |
virtual uint8_t | getBrghtnssLvl () |
Returns the current display brightness level setting for the display. | |
virtual uint8_t | getBrghtnssMaxLvl () |
Returns the maximum display brightness level setting allowed for the display. | |
virtual uint8_t | getBrghtnssMinLvl () |
Returns the minimum display brightness level setting for the display. | |
bool | getCommAnode () |
Returns a value indicating if the display module component of the display hardware uses a common anode or a common cathode led wiring. | |
uint8_t * | getDspBuffPtr () |
Returns a pointer to the display buffer. | |
uint8_t | getHwDspDigitsQty () |
Returns the quantity of digits of the display module. | |
virtual bool | getIsOn () |
Returns the state of the display. | |
uint8_t * | getxcdDspBuffPtr () |
Returns a pointer to an array holding the contents for the digits/ports available from the display controller but not used for plain digits display. | |
virtual void | ntfyUpdDsply () |
Notifies the SevenSegDispHw component object of a change of content available in the display buffer, so that the object proceeds to update the display. | |
virtual bool | setBrghtnssLvl (const uint8_t &newBrghtnssLvl) |
Sets the brightness level for the display. | |
virtual bool | setDigitsOrder (uint8_t *newOrderPtr) |
Sets a mapping to relate the display buffer positions to the display port assigned to exhibit it's contents. | |
void | setDspBuffPtr (uint8_t *newDspBuffPtr) |
Sets the pointer to the Display Buffer memory area. | |
virtual void | turnOff () |
Turns the display module off. | |
virtual void | turnOn () |
Turns the display module on. | |
virtual void | turnOn (const uint8_t &newBrghtnssLvl) |
Turns the display module on set at the provided brightness level. |
Protected Attributes | |
uint8_t | _allLedsOff {} |
Value to set in the display port to set all leds off (a "space"), dependent of _commAnode. | |
uint8_t | _brghtnssLvl {0} |
Current display brightness level. | |
uint8_t | _brghtnssLvlMax {0} |
Maximum display brightness level. | |
uint8_t | _brghtnssLvlMin {0} |
Minimum display brightness level. | |
uint8_t * | _dspBlankBuffPtr {nullptr} |
Pointer to a display buffer filled with _allLedsOff ("spaces") to use as display buffer while in "Off State". | |
uint8_t * | _dspBuffPtr {nullptr} |
Pointer to the display buffer, will be provided by the SevenSegDisplays object when it's instantiated. | |
uint8_t * | _dspBuffPtrBkp {nullptr} |
Pointer to the display buffer, copy of the original _dspBuffPtr to be used as backup. | |
bool | _isOn {false} |
Current display status: On/Off. | |
uint8_t * | _xcdDspBuffPtr {nullptr} |
A pointer to a buffer the size of the exceeding digits used to control display specific amenities. | |
uint8_t | _xcdDspDigitsQty {} |
Number of unused available display ports, its the difference (_dspDigitsQtyMax - _dspDigitsQty), being the size of the array pointed by _xcdDspBuffPtr. |
Base abstract class models a generic Seven Segment display hardware.
SevenSegDispHw::SevenSegDispHw | ( | uint8_t * | ioPins, |
uint8_t | dspDigits = 4, | ||
bool | commAnode = true, | ||
uint8_t | dspDigitsQtyMax = 0 ) |
Class constructor.
ioPins | A pointer to an array holding the identifiers for the MCU GPIO pins required to send the data to be displayed to the Display controller. The correlation between the array positions and the pin function is given as in-class defined constants for each instantiable subclass. |
dspDigits | Quantity of digits/ports of the display. This value is directly related to the display module component quantity of ports and characteristics. |
commAnode | Boolean indicating if the hardware uses a display module component wired as common anode (true) or common cathode (false). |
dspDigitsQtyMax | Maximum quantity of digits/ports the display controller is able to manage. Sometimes display module components are attached to display controller component able to manage more than the display digits/ports. |
|
virtual |
Sets up the hardware display to work, and starts the display activities.
Depending on the display technology and the resources it needs to work with, this method takes care of those preparations. That means that each specific subclass of display will provide it's own version of begin() that will take care of:
updtLps | Time lapse between updating activities required, specially by dynamic subclasses. The parameter will be used according to each subclass needs, which will be described in each class begin() method. |
true | The specific configurations and startups could be successfully completed. |
Reimplemented in SevenSegDynamic, SevenSegDynDummy, SevenSegDynHC595, SevenSegHT16K33, SevenSegMax7219, SevenSegStatHC595, and SevenSegTM163X.
|
virtual |
Reverts the begin(uint32_t) actions, stopping the display activities, turning the display off and freeing the resources used by the Seven Segment display hardware object.
Reimplemented in SevenSegDynamic, SevenSegDynDummy, SevenSegDynHC595, SevenSegHT16K33, SevenSegMax7219, and SevenSegTM163X.
|
virtual |
Returns the current display brightness level setting for the display.
For displays with variable display brighness levels this method will return the current brightness level. The returned value will be in the range getBrghtnssMinLvl() <= getBrghtnssLvl() <= getBrghtnssMaxLvl(), see setBrghtnssLvl(const uint8_t &) for more details.
Reimplemented in SevenSegTM163X.
|
virtual |
Returns the maximum display brightness level setting allowed for the display.
For displays with variable display brightness levels this method will return the maximum brightness level value valid setting. See setBrghtnssLvl(const uint8_t &) for more details.
|
virtual |
Returns the minimum display brightness level setting for the display.
For displays with variable display brightness levels this method will return the minimum brightness level value setting. See setBrghtnssLvl(const uint8_t &) for more details.
bool SevenSegDispHw::getCommAnode | ( | ) |
Returns a value indicating if the display module component of the display hardware uses a common anode or a common cathode led wiring.
The SevenSegDisplays instantiated objects will compose the values corresponding to each character it displays according to the SevenSegDispHw _commAnode attribute. Each SevenSegDispHw instantiable subclass will have that constant attribute set by the subclass developer to correspond to the technical specifications of the display module component, unless the display module has the capacity to work with both technologies, in wich case the subclass constructor will include a _commAnode boolean parameter to set that attribute.
true | The display is built with a Common Anode display module component. |
false | The display is built with a Common Cathode display module component. |
uint8_t * SevenSegDispHw::getDspBuffPtr | ( | ) |
Returns a pointer to the display buffer.
The display buffer is the memory area set by the SevenSegDisplays class object instantiated to hold the data to be displayed, and so it's shared by that object and it's SevenSegDispHw subclass object component. When the SevenSegDisplays object is constructed it sets the SevenSegDispHw subclass object buffer pointer to the memory area it set for that purpose. This method retrieves that memory pointer.
uint8_t SevenSegDispHw::getHwDspDigitsQty | ( | ) |
Returns the quantity of digits of the display module.
The value returned correspond to the dspDigits parameter passed at instantiation time.
|
virtual |
Returns the state of the display.
Returns a boolean value indicating if the display is turned On or Off
true | The display is turned On |
false | The display is turned Off |
Reimplemented in SevenSegMax7219.
uint8_t * SevenSegDispHw::getxcdDspBuffPtr | ( | ) |
Returns a pointer to an array holding the contents for the digits/ports available from the display controller but not used for plain digits display.
|
virtual |
Notifies the SevenSegDispHw component object of a change of content available in the display buffer, so that the object proceeds to update the display.
While the dynamic displays must periodically refresh the data displayed, and so they get the most updated content from the display buffer without the need to receive any notification, the data displayed by the static displays internal buffer to hold the displayed data. The internal buffer contents remain constant until it's data buffer or registers are loaded with new data. This method notifies the display that the data buffer content has changed and it must load the new contents of it's internal registers or buffers to display the new information.
Reimplemented in SevenSegHT16K33, SevenSegMax7219, SevenSegStatHC595, and SevenSegTM163X.
|
virtual |
Sets the brightness level for the display.
Although dummy dynamic and dummy static displays brightness might be dimmed using PWM management, both displays require MCU intervention, added to the regular required cinematic effect generation workload, making the brightness control very expensive in resources use. For this reason the brightness control in this library will be available for the smart static displays equiped with a display controller unit specifically providing the option. Each class description and documentation will detail if the service is available or not, and in case the method is invoked in an object instantiated from a class with no brightness control capabilities, the value returned will be false, avoiding the need of a error handling mechanism.
newBrghtnssLvl | The new brightness level for the display. The value must be in the range getBrghtnssMinLvl() <= newBrghtnssLvl <= getBrghtnssMaxLvl() |
true | The parameter was in the valid range, the display will be set to the new brightness level (or keep it's brightness level if the parameter passed is equal to the current brightness level) |
Reimplemented in SevenSegHT16K33, SevenSegMax7219, and SevenSegTM163X.
|
virtual |
Sets a mapping to relate the display buffer positions to the display port assigned to exhibit it's contents.
As different Seven Segment display hardware implement different wiring schemes between the display controller component and the display module component, some implement the leftmost display port as it's lowest memory position of it's buffer, while some implement the rightmost position to it. When more than one display module components are used, it adds a new level of hardware implementation that differs from one supplier to the other. The library implements a mechanism to provide the instantiated object to relate the positions of the display ports to the display buffer positions through an array. The array has the size of the display buffer, and each array element is meant to hold the number of the corresponding port that is wired to display the data in that display buffer position The array is default defined in the constructor as (0, 1, 2,...) that is the most usual implementation found. If the order needs to be changed the setDigitsOrder() method is the way to set a new mapping.
newOrderPtr | Pointer to an uint8_t array of _dspDigits length containing the position of the port in the display module components wired to display that buffer position content. Each value will be checked against the _dspDigits value to ensure that they are all in the range acceptable, 0 <= value <= _dspDigits - 1. If one of the values is out of the valid range no change will be done. Please note that no checking will be done to ensure all of the array values are different. A repeated value will be accepted, ending in an undetermined non-critic, display behavior. |
Use example:
void SevenSegDispHw::setDspBuffPtr | ( | uint8_t * | newDspBuffPtr | ) |
Sets the pointer to the Display Buffer memory area.
When a SevenSegDisplays object is instantiated it's constructor sets a display buffer memory area to store the contents ready to be displayed. Part of the constructor execution includes passing to the SevenSegDispHw subclass component that pointer, as the underlying hardware display object will be taking the information to display from that memory buffer. The resource to set the pointer is this method.
|
virtual |
Turns the display module off.
The display module will be cleared and will keep that status until a turnOn(), or turnOn(const uint8_t &) is invoked.
Reimplemented in SevenSegDynDummy, SevenSegHT16K33, SevenSegMax7219, and SevenSegTM163X.
|
virtual |
Turns the display module on.
The display module will be turned on, making visible the contents of the display buffer. For more information see turnOff() method.
Reimplemented in SevenSegDynDummy, SevenSegHT16K33, SevenSegMax7219, and SevenSegTM163X.
|
virtual |
Turns the display module on set at the provided brightness level.
For correct execution and visual response, this method executes a setBrghtnssLvl(const uint8_t &) method followed by a turnOn() method execution.
newBrghtnssLvl | The new brightness level for the display. The value must be in the range getBrghtnssMinLvl() <= newBrghtnssLvl <= getBrghtnssMaxLvl() |
Reimplemented in SevenSegHT16K33, SevenSegMax7219, and SevenSegTM163X.