Seven Segments Displays Agnostic Library for ESP32 (Arduino) v3.2.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/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();
229 virtual bool begin(uint32_t updtLps = 0);
247 bool blink();
275 bool blink(const uint32_t &onRate, const uint32_t &offRate = 0);
290 void clear();
325 bool doubleGauge(const int &levelLeft, const int &levelRight, char labelLeft = ' ', char labelRight = ' ');
333 bool end();
367 bool gauge(const int &level, char label = ' ');
410 bool gauge(const double &level, char label = ' ');
416 uint8_t getCurBrghtnssLvl();
431 uint8_t getDigitsQty();
437 uint8_t getDspCount();
444 bool getDspIsDmmbl();
457 SevenSegDispHw* getDspUndrlHwPtr();
472 int32_t getDspValMax();
486 int32_t getDspValMin();
493 bool getIsOn();
511 uint32_t getMaxBlinkRate();
519 uint8_t getMaxBrghtnssLvl();
537 uint32_t getMinBlinkRate();
545 uint8_t getMinBrghtnssLvl();
563 uint16_t getSerialNbr();
578 bool isBlank();
592 bool isBlinking();
608 bool isWaiting();
623 bool noBlink();
638 bool noWait();
664 bool print(String text);
686 bool print(const int32_t &value, bool rgtAlgn = false, bool zeroPad = false);
712 bool print(const double &value, const unsigned int &decPlaces, bool rgtAlgn = false, bool zeroPad = false);
724 void resetBlinkMask();
748 void setBlinkMask(const bool* newBlnkMsk);
769 bool setBlinkRate(const uint32_t &newOnRate, const uint32_t &newOffRate = 0);
781 bool setBrghtnssLvl(const uint8_t &newBrghtnssLvl);
798 bool setWaitChar (const char &newChar);
816 bool setWaitRate(const uint32_t &newWaitRate);
822 void turnOff();
828 void turnOn();
836 void turnOn(const uint8_t &newBrghtnssLvl);
855 bool wait();
868 bool wait(const uint32_t &newWaitRate);
885 bool write(const uint8_t &segments, const uint8_t &port);
902 bool write(const String &character, const uint8_t &port);
903};
904
905#endif //_SevenSegDisplays_H_
SevenSegDispHw.h
Header file for the SevenSegDisplays_ESP32 library, SevenSegDispHw class and subclasses.
SevenSegDispHw
Base abstract class models a generic Seven Segment display hardware.
Definition SevenSegDispHw.h:61
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::getMinBrghtnssLvl
uint8_t getMinBrghtnssLvl()
Returns the minimum brightness value setting for the display.
Definition SevenSegDisplays.cpp:390
SevenSegDisplays::getMinBlinkRate
uint32_t getMinBlinkRate()
Returns the minimum rate the display can be configured to blink at.
Definition SevenSegDisplays.cpp:405
SevenSegDisplays::turnOff
void turnOff()
Turns the display module off.
Definition SevenSegDisplays.cpp:899
SevenSegDisplays::setBrghtnssLvl
bool setBrghtnssLvl(const uint8_t &newBrghtnssLvl)
Set the brightness level for the display.
Definition SevenSegDisplays.cpp:827
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:860
SevenSegDisplays::getDspIsDmmbl
bool getDspIsDmmbl()
Returns the logic value indicating if the display is dimmable.
Definition SevenSegDisplays.cpp:360
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::getIsOn
bool getIsOn()
Returns a logic value indicating if the display is in On state.
Definition SevenSegDisplays.cpp:365
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:842
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::getCurBrghtnssLvl
uint8_t getCurBrghtnssLvl()
Returns the current brightness level of the display.
Definition SevenSegDisplays.cpp:345
SevenSegDisplays::end
bool end()
Ends the activity of the display.
Definition SevenSegDisplays.cpp:283
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::turnOn
void turnOn()
Turns the display module on.
Definition SevenSegDisplays.cpp:905
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:1062
SevenSegDisplays::getMaxBrghtnssLvl
uint8_t getMaxBrghtnssLvl()
Returns the maximum brightness value setting for the display.
Definition SevenSegDisplays.cpp:385
SevenSegDisplays::begin
virtual bool begin(uint32_t updtLps=0)
Sets up the hardware display to work, and starts the display activities.
Definition SevenSegDisplays.cpp:89
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:984
SevenSegDisplays::getDspUndrlHwPtr
SevenSegDispHw * getDspUndrlHwPtr()
Returns a pointer to the underlying hardware display object.
Definition SevenSegDisplays.cpp:370