1#ifndef sevenSegDisplays_H
2#define sevenSegDisplays_H
5#include <SevenSegDispHw.h>
7const int MAX_DIGITS_PER_DISPLAY{8};
8const int MAX_DISPLAYS_QTY{10};
10class SevenSegDisplays {
11 static uint8_t _displaysCount;
12 static uint16_t _dspSerialNum;
13 static uint8_t _dspPtrArrLngth;
14 static SevenSegDisplays** _instancesLstPtr;
16 static TimerHandle_t _blinkTmrHndl;
17 static TimerHandle_t _waitTmrHndl;
19 static void tmrCbBlink(TimerHandle_t blinkTmrCbArg);
20 static void tmrCbWait(TimerHandle_t waitTmrCbArg);
23 uint8_t _waitChar {0xBF};
24 uint8_t _waitCount {0};
25 bool _waiting {
false};
26 unsigned long _waitRate {250};
27 unsigned long _waitTimer {0};
29 const unsigned long _minBlinkRate{100};
30 const unsigned long _maxBlinkRate{2000};
32 bool* _blinkMaskPtr{
nullptr};
33 uint8_t* _dspAuxBuffPtr{
nullptr};
34 bool _dspBuffChng{
false};
35 uint8_t* _dspBuffPtr{
nullptr};
36 uint8_t _dspDigitsQty{};
37 SevenSegDispHw _dspUndrlHw{};
38 SevenSegDisplays* _dspInstance;
39 uint16_t _dspInstNbr{0};
43 bool _blinking{
false};
44 bool _blinkShowOn{
false};
45 unsigned long _blinkTimer{0};
46 unsigned long _blinkOffRate{500};
47 unsigned long _blinkOnRate{500};
48 unsigned long _blinkRatesGCD{500};
50 String _charSet{
"0123456789AabCcdEeFGHhIiJLlnOoPqrStUuY-_=~* ."};
51 uint8_t _charLeds[45] = {
99 uint8_t _space {0xFF};
101 String _zeroPadding{
""};
102 String _spacePadding{
""};
104 unsigned long blinkTmrGCD(
unsigned long blnkOnTm,
unsigned long blnkOffTm);
105 void restoreDspBuff();
108 void updBlinkState();
112 SevenSegDisplays(SevenSegDispHw dspUndrlHw);
115 bool blink(
const unsigned long &onRate,
const unsigned long &offRate = 0);
117 bool doubleGauge(
const int &levelLeft,
const int &levelRight,
char labelLeft =
' ',
char labelRight =
' ');
118 bool gauge(
const int &level,
char label =
' ');
119 bool gauge(
const double &level,
char label =
' ');
120 uint8_t getDigitsQty();
121 uint32_t getDspValMax();
122 uint32_t getDspValMin();
123 uint16_t getInstanceNbr();
124 unsigned long getMaxBlinkRate();
125 unsigned long getMinBlinkRate();
131 bool print(String text);
132 bool print(
const int32_t &value,
bool rgtAlgn =
false,
bool zeroPad =
false);
133 bool print(
const double &value,
const unsigned int &decPlaces,
bool rgtAlgn =
false,
bool zeroPad =
false);
134 void resetBlinkMask();
135 void setBlinkMask(
const bool* newBlnkMsk);
136 bool setBlinkRate(
const unsigned long &newOnRate,
const unsigned long &newOffRate = 0);
137 bool setWaitChar (
const char &newChar);
138 bool setWaitRate(
const unsigned long &newWaitRate);
140 bool wait(
const unsigned long &newWaitRate);
141 bool write(
const uint8_t &segments,
const uint8_t &port);
142 bool write(
const String &character,
const uint8_t &port);
149 SevenSegDisplays _display;
151 int _beginStartVal{0};
152 bool _countRgthAlgn{
true};
153 bool _countZeroPad{
false};
155 ClickCounter(uint8_t ccSclk, uint8_t ccRclk, uint8_t ccDio,
bool rgthAlgn =
true,
bool zeroPad =
false,
bool commAnode =
true,
const uint8_t dspDigits = 4);
158 bool blink(
const unsigned long &onRate,
const unsigned long &offRate = 0);
160 bool countBegin(int32_t startVal = 0);
161 bool countDown(int32_t qty = 1);
163 bool countRestart(int32_t restartValue = 0);
165 bool countToZero(int32_t qty = 1);
166 bool countUp(int32_t qty = 1);
168 int32_t getStartVal();
170 bool setBlinkRate(
const unsigned long &newOnRate,
const unsigned long &newOffRate = 0);