some cleanup

This commit is contained in:
Dorian Zedler 2020-10-15 00:02:48 +02:00
parent d74da783b3
commit 40a190e324
Signed by: dorian
GPG key ID: D3B255CB8BC7CD37
3 changed files with 14 additions and 14 deletions

View file

@ -5,8 +5,8 @@
#include <Adafruit_GFX.h> #include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h> #include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h> #include <Adafruit_NeoPixel.h>
#include "esp_task_wdt.h"
#include <EEPROM.h> #include <EEPROM.h>
#include "esp_task_wdt.h"
class LedDisplayController class LedDisplayController
{ {
@ -32,7 +32,7 @@ public:
ScrollSpeedParameter, ScrollSpeedParameter,
ScrollCountParameter, ScrollCountParameter,
IndexParameter, IndexParameter,
DisplayTextSetParameterCount DisplayTextSetParameterCount /*!< Just for helping purposes */
}; };
enum GetSetTextSetParameterExitCode enum GetSetTextSetParameterExitCode
@ -46,8 +46,8 @@ public:
InternalError InternalError
}; };
static const uint16_t MaximumTextSets = 6; static const uint16_t maximumTextSets = 6;
static const uint16_t MaximumTextLength = 256; static const uint16_t maximumTextLength = 256;
void loop(); void loop();
@ -84,19 +84,19 @@ private:
// storage structs // storage structs
typedef struct text_set_t typedef struct text_set_t
{ {
char text[MaximumTextLength]; char text[maximumTextLength];
bool active; bool active;
uint16_t runtime; uint16_t runtime;
char color[7]; char color[7];
text_align_t alignment; text_align_t alignment;
bool scroll; bool scroll;
int scrollSpeed; int scrollSpeed; /*!< Between 0 and 10 */
uint16_t scrollCount; uint16_t scrollCount;
} text_set_t; } text_set_t;
typedef struct sets_t typedef struct sets_t
{ {
text_set_t sets[MaximumTextSets]; text_set_t sets[maximumTextSets];
char valid[3]; char valid[3];
} sets_t; } sets_t;

View file

@ -49,7 +49,7 @@ void LedDisplayController::loop()
String LedDisplayController::getTextSetParameter(int index, DisplayTextSetParameter parameter) String LedDisplayController::getTextSetParameter(int index, DisplayTextSetParameter parameter)
{ {
if (index < 0 || index > this->MaximumTextSets || parameter < 0 || parameter >= DisplayTextSetParameterCount) if (index < 0 || index > this->maximumTextSets || parameter < 0 || parameter >= DisplayTextSetParameterCount)
return ""; return "";
String value = ""; String value = "";
@ -101,7 +101,7 @@ void LedDisplayController::disp_start_set()
//Serial.printf("[%lu] Meet start set condition. Curr set is %d. \n", millis(), text_curr_nr); //Serial.printf("[%lu] Meet start set condition. Curr set is %d. \n", millis(), text_curr_nr);
if (0 < text_set_starttime || text_sets.sets[text_curr_nr].text == '\0' || text_sets.sets[text_curr_nr].active == false) if (0 < text_set_starttime || text_sets.sets[text_curr_nr].text == '\0' || text_sets.sets[text_curr_nr].active == false)
text_curr_nr++; text_curr_nr++;
if (text_curr_nr == MaximumTextSets) if (text_curr_nr == maximumTextSets)
text_curr_nr = 0; text_curr_nr = 0;
text_pass = 0; text_pass = 0;
if (text_sets.sets[text_curr_nr].text != '\0' && text_sets.sets[text_curr_nr].active == true) if (text_sets.sets[text_curr_nr].text != '\0' && text_sets.sets[text_curr_nr].active == true)
@ -181,7 +181,7 @@ LedDisplayController::GetSetTextSetParameterExitCode LedDisplayController::getSe
{ {
if (parameter < 0 || parameter >= DisplayTextSetParameterCount) if (parameter < 0 || parameter >= DisplayTextSetParameterCount)
return InvalidParameterError; return InvalidParameterError;
else if (index < 0 || index >= this->MaximumTextSets) else if (index < 0 || index >= this->maximumTextSets)
return IndexOutOfRangeError; return IndexOutOfRangeError;
else if (value == nullptr) else if (value == nullptr)
return ValueIsNullptrError; return ValueIsNullptrError;
@ -318,7 +318,7 @@ bool LedDisplayController::loadTextSets()
strncpy(defaultTextSets.valid, "OK", sizeof(defaultTextSets.valid)); strncpy(defaultTextSets.valid, "OK", sizeof(defaultTextSets.valid));
for (int i = 0; i < this->MaximumTextSets; i++) for (int i = 0; i < this->maximumTextSets; i++)
{ {
text_set_t defaultTextSet{ text_set_t defaultTextSet{
"", "",

View file

@ -45,7 +45,7 @@ void OmobiLedDisplay::onDataReceived(String dataString)
case GetAllTextSetsCommand: case GetAllTextSetsCommand:
{ {
// cycle through all text sets // cycle through all text sets
for (int textSetIndex = 0; textSetIndex < LedDisplayController::MaximumTextSets; textSetIndex++) for (int textSetIndex = 0; textSetIndex < LedDisplayController::maximumTextSets; textSetIndex++)
{ {
if (this->ledDisplayController->getTextSetParameter(textSetIndex, LedDisplayController::TextParameter) == "") if (this->ledDisplayController->getTextSetParameter(textSetIndex, LedDisplayController::TextParameter) == "")
continue; continue;
@ -75,8 +75,8 @@ void OmobiLedDisplay::onDataReceived(String dataString)
} }
replyStatus = Success; replyStatus = Success;
replyData["maximumTextSets"] = LedDisplayController::MaximumTextSets; replyData["maximumTextSets"] = LedDisplayController::maximumTextSets;
replyData["maximumTextLength"] = LedDisplayController::MaximumTextLength; replyData["maximumTextLength"] = LedDisplayController::maximumTextLength;
break; break;
} }