Seven Segments Displays Agnostic Library for ESP32 (Arduino) v3.1.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.

Loading...
Searching...
No Matches
SevenSegDisplays.h
Go to the documentation of this file.
1
48//FFDR For Future Development Reminder!!
49//FTPO For Testing Purposes Only code!!
50
51#ifndef _SevenSegDisplays_ESP32_H_
52#define _SevenSegDisplays_ESP32_H_
53
54#include <Arduino.h>
55#include <stdint.h>
56#include <SevenSegDispHw.h>
57
58 class SevenSegDisplays {
59 static uint8_t _displaysCount;
60 static uint16_t _dspLastSerialNum;
61 static SevenSegDisplays** _ssdInstancesLstPtr;
62
63 static TimerHandle_t _blinkTmrHndl;
64 static TimerHandle_t _waitTmrHndl;
65
66 static void tmrCbBlink(TimerHandle_t blinkTmrCbArg);
67 static void tmrCbWait(TimerHandle_t waitTmrCbArg);
68
69 static const uint32_t _minBlinkRate{100}; //unsigned long for ESP32 in Arduino enviornment
70 static const uint32_t _maxBlinkRate{2000}; //unsigned long for ESP32 in Arduino enviornment
71
72 private:
73 bool _begun{false};
74 bool _isWaiting {false};
75 uint8_t _waitChar {0xBF};
76 uint8_t _waitCount {0};
77 uint32_t _waitRate {250};
78 uint32_t _waitTimer {0};
79
80 protected:
81 bool* _blinkMaskPtr{nullptr};
82 uint8_t* _dspAuxBuffPtr{nullptr};
83 uint8_t* _dspBuffPtr{nullptr};
84 uint8_t _dspDigitsQty{};
85 SevenSegDispHw* _dspUndrlHwPtr{};
86 SevenSegDisplays* _dspInstance{nullptr};
87 uint16_t _dspSerialNbr{0};
88 int32_t _dspValMax{};
89 int32_t _dspValMin{};
90 bool _dspUndrlHwCommAnode{};
91
92 bool _isBlinking{false};
93 bool _blinkShowOn{false};
94 uint32_t _blinkTimer{0};
95 uint32_t _blinkOffRate{500};
96 uint32_t _blinkOnRate{500};
97 uint32_t _blinkRatesGCD{500}; //Holds the value for the minimum timer checking the change ON/OFF of the blinking, saving unneeded timer interruptions, and without the need of the std::gcd function
98 String _charSet{"0123456789AabCcdEeFGHhIiJLlnOoPqrStUuY-_=~* ."}; // for using indexOf() method
99 uint8_t _charLeds[45] = { //Values valid for a Common Anode display. For a Common Cathode display values must be logically bit negated
100 0xC0, // 0
101 0xF9, // 1
102 0xA4, // 2
103 0xB0, // 3
104 0x99, // 4
105 0x92, // 5
106 0x82, // 6
107 0xF8, // 7
108 0x80, // 8
109 0x90, // 9
110 0x88, // A
111 0xA0, // a
112 0x83, // b
113 0xC6, // C
114 0xA7, // c
115 0xA1, // d
116 0x86, // E
117 0x84, // e
118 0x8E, // F
119 0xC2, // G
120 0x89, // H
121 0x8B, // h
122 0xF9, // I
123 0xFB, // i
124 0xF1, // J
125 0xC7, // L
126 0xCF, // l
127 0xAB, // n
128 0xC0, // O
129 0xA3, // o
130 0x8C, // P
131 0x98, // q
132 0xAF, // r
133 0x92, // S
134 0x87, // t
135 0xC1, // U
136 0xE3, // u
137 0x91, // Y
138 0xBF, // Minus -
139 0xF7, // Underscore _
140 0xB7, // Low =
141 0xB6, //~ for Equivalent symbol
142 0x9C, // °
143 0xFF, // Space
144 0x7F //.
145 };
146
147 uint8_t _space {0xFF};
148 uint8_t _dot {0x7F};
149 String _zeroPadding{""};
150 String _spacePadding{""};
151
152 uint32_t _blinkTmrGCD(uint32_t blnkOnTm, uint32_t blnkOffTm);
153 void _ntfyToHwBuffChng();
154 void _popSsd(SevenSegDisplays** &ssdInstncObjLst, SevenSegDisplays* ssdToPop);
155 void _pushSsd(SevenSegDisplays** &ssdInstncObjLst, SevenSegDisplays* ssdToPush);
156 void _restoreDspBuff();
157 void _setAttrbts();
158 void _setDspBuffChng();
159 void _saveDspBuff();
160 void _updBlinkState();
161 void _updWaitState();
162
163 public:
169 SevenSegDisplays();
212 SevenSegDisplays(SevenSegDispHw* dspUndrlHwPtr);
216 ~SevenSegDisplays();
217
218 virtual bool begin(uint32_t updtLps = 0);
219
237 bool blink();
265 bool blink(const uint32_t &onRate, const uint32_t &offRate = 0);
280 void clear();
315 bool doubleGauge(const int &levelLeft, const int &levelRight, char labelLeft = ' ', char labelRight = ' ');
316
317 bool end();
318
352 bool gauge(const int &level, char label = ' ');
395 bool gauge(const double &level, char label = ' ');
396
397 uint8_t getCurBrghtnssLvl();
398
413 uint8_t getDigitsQty();
419 uint8_t getDspCount();
420
421 bool getDspIsDmmbl();
422
435 SevenSegDispHw* getDspUndrlHwPtr();
450 int32_t getDspValMax();
464 int32_t getDspValMin();
465
466 bool getIsOn();
467
485 uint32_t getMaxBlinkRate();
486
487 uint8_t getMaxBrghtnssLvl();
488
506 uint32_t getMinBlinkRate();
507
508 uint8_t getMinBrghtnssLvl();
509
527 uint16_t getSerialNbr();
542 bool isBlank();
556 bool isBlinking();
572 bool isWaiting();
587 bool noBlink();
602 bool noWait();
628 bool print(String text);
650 bool print(const int32_t &value, bool rgtAlgn = false, bool zeroPad = false);
676 bool print(const double &value, const unsigned int &decPlaces, bool rgtAlgn = false, bool zeroPad = false);
688 void resetBlinkMask();
712 void setBlinkMask(const bool* newBlnkMsk);
733 bool setBlinkRate(const uint32_t &newOnRate, const uint32_t &newOffRate = 0);
734
735 bool setBrghtnssLvl(const uint8_t &newBrghtnssLvl);
736
753 bool setWaitChar (const char &newChar);
771 bool setWaitRate(const uint32_t &newWaitRate);
772
773 void turnOff();
774
775 void turnOn();
776
777 void turnOn(const uint8_t &newBrghtnssLvl);
778
797 bool wait();
810 bool wait(const uint32_t &newWaitRate);
827 bool write(const uint8_t &segments, const uint8_t &port);
844 bool write(const String &character, const uint8_t &port);
845};
846
847#endif //_SevenSegDisplays_H_
SevenSegDispHw
Base abstract class models a generic Seven Segment display hardware.
Definition sevenSegDispHw.h:61
SevenSegDisplays
Default constructor.
Definition SevenSegDisplays.h:58
SevenSegDisplays::getSerialNbr
uint16_t getSerialNbr()
Returns a unique numeric identification of the object.
Definition SevenSegDisplays.cpp:395
SevenSegDisplays::getDigitsQty
uint8_t getDigitsQty()
Return the number of digits of the display hardware.
Definition SevenSegDisplays.cpp:350
SevenSegDisplays::getDspValMin
int32_t getDspValMin()
Returns a value equivalent to the smallest displayable number for the display.
Definition SevenSegDisplays.cpp:380
SevenSegDisplays::getMinBlinkRate
uint32_t getMinBlinkRate()
Returns the minimum rate the display can be configured to blink at.
Definition SevenSegDisplays.cpp:405
SevenSegDisplays::noWait
bool noWait()
Stops the Waiting mode, if it was doing so, leaving the display turned on.
Definition SevenSegDisplays.cpp:458
SevenSegDisplays::setWaitRate
bool setWaitRate(const uint32_t &newWaitRate)
Changes the timing parameter used to show the "progress ongoing bar advancement" speed.
Definition SevenSegDisplays.cpp:856
SevenSegDisplays::blink
bool blink()
Makes the display blink the contents it is showing.
Definition SevenSegDisplays.cpp:103
SevenSegDisplays::isBlinking
bool isBlinking()
Returns a boolean value indicating if the display is set to blink or not.
Definition SevenSegDisplays.cpp:423
SevenSegDisplays::clear
void clear()
Clears the display, turning off all the segments and dots.
Definition SevenSegDisplays.cpp:201
SevenSegDisplays::isWaiting
bool isWaiting()
Returns a boolean value indicating if the display is set to "waiting mode" or not.
Definition SevenSegDisplays.cpp:428
SevenSegDisplays::resetBlinkMask
void resetBlinkMask()
Resets the blinking mask.
Definition SevenSegDisplays.cpp:710
SevenSegDisplays::getDspCount
uint8_t getDspCount()
Returns the quantity of instantiated SevenSegDisplays class objects at invocation moment.
Definition SevenSegDisplays.cpp:355
SevenSegDisplays::setWaitChar
bool setWaitChar(const char &newChar)
Sets the "Waiting" character.
Definition SevenSegDisplays.cpp:838
SevenSegDisplays::isBlank
bool isBlank()
Returns a value indicating if the display is blank.
Definition SevenSegDisplays.cpp:410
SevenSegDisplays::noBlink
bool noBlink()
Stops the display blinking, if it was doing so, leaving the display turned on.
Definition SevenSegDisplays.cpp:433
SevenSegDisplays::gauge
bool gauge(const int &level, char label=' ')
Displays a basic graphical representation of the level of fulfillment or completeness of a segmented ...
Definition SevenSegDisplays.cpp:297
SevenSegDisplays::doubleGauge
bool doubleGauge(const int &levelLeft, const int &levelRight, char labelLeft=' ', char labelRight=' ')
Displays a basic graphical representation of the level of fulfillment or completeness of two segmente...
Definition SevenSegDisplays.cpp:226
SevenSegDisplays::setBlinkRate
bool setBlinkRate(const uint32_t &newOnRate, const uint32_t &newOffRate=0)
Changes the time parameters to use for the display blinking of the contents it shows.
Definition SevenSegDisplays.cpp:786
SevenSegDisplays::~SevenSegDisplays
~SevenSegDisplays()
Class destructor.
Definition SevenSegDisplays.cpp:54
SevenSegDisplays::write
bool write(const uint8_t &segments, const uint8_t &port)
Prints one character to the display, at a designated position (digit or port), without affecting the ...
Definition SevenSegDisplays.cpp:1058
SevenSegDisplays::getMaxBlinkRate
uint32_t getMaxBlinkRate()
Returns the maximum rate the display can be configured to blink at.
Definition SevenSegDisplays.cpp:400
SevenSegDisplays::getDspValMax
int32_t getDspValMax()
Returns a value equivalent to the greatest displayable number for the display.
Definition SevenSegDisplays.cpp:375
SevenSegDisplays::print
bool print(String text)
Displays a text string.
Definition SevenSegDisplays.cpp:566
SevenSegDisplays::setBlinkMask
void setBlinkMask(const bool *newBlnkMsk)
Sets a new blinking mask for the display.
Definition SevenSegDisplays.cpp:776
SevenSegDisplays::wait
bool wait()
Makes the display enter the "Waiting mode"
Definition SevenSegDisplays.cpp:980
SevenSegDisplays::getDspUndrlHwPtr
SevenSegDispHw * getDspUndrlHwPtr()
Returns a pointer to the underlying hardware display object.
Definition SevenSegDisplays.cpp:370
sevenSegDispHw.h
Header file for the SevenSegDisplays_ESP32 library, SevenSegDispHw class and subclasses.