JBWOPR
Loading...
Searching...
No Matches
jbwoprhelpers.h
1
8
9#ifndef ARDUINO_WOPR_JBWOPRHELPERS_H
10#define ARDUINO_WOPR_JBWOPRHELPERS_H
11
12#include <string>
13#include <sstream>
14#include <time.h>
15#include <jblogger.h>
16
18enum JBTextAlignment {
19 LEFT = 0,
20 CENTER,
21 RIGHT
22};
23
24
35public:
38 static void configure(JBLogger* log, std::string ntpServer = "", std::string timeOffsetString = "");
39
43 static int64_t getUtcOffsetInSeconds();
44
50 static bool getTime(tm* info);
51
52
57 static bool setTime(const std::string currentDateTime);
58
59private:
60 static bool _isInitialized;
61 static std::string _ntpServer;
62 static std::string _timeOffsetString;
63 static JBLogger* _log;
64};
65
68public:
73 static std::string getCenteredString(const std::string str, const uint32_t length, char padChar = ' ');
74
79 static std::string getRightAlignedString(std::string str, uint32_t length, char padChar = ' ');
80
84 static std::string rgbToString(uint32_t rgbValue);
85
89 static uint32_t stringToRgb(std::string rgbString);
90
91};
92
93#endif //ARDUINO_WOPR_JBWOPRHELPERS_H
This class contains helper functions for string related tasks.
Definition jbwoprhelpers.h:67
static std::string rgbToString(uint32_t rgbValue)
Get hex coded color string.
Definition jbwoprhelpers.cpp:147
static std::string getRightAlignedString(std::string str, uint32_t length, char padChar=' ')
Get right aligned string.
Definition jbwoprhelpers.cpp:134
static std::string getCenteredString(const std::string str, const uint32_t length, char padChar=' ')
Get centered string.
Definition jbwoprhelpers.cpp:117
static uint32_t stringToRgb(std::string rgbString)
Get RGB value from hex coded color string.
Definition jbwoprhelpers.cpp:157
This class contains helper functions for time related tasks.
Definition jbwoprhelpers.h:34
static int64_t getUtcOffsetInSeconds()
Get UTC offset in seconds.
Definition jbwoprhelpers.cpp:23
static bool getTime(tm *info)
Get local time.
Definition jbwoprhelpers.cpp:49
static void configure(JBLogger *log, std::string ntpServer="", std::string timeOffsetString="")
Configure helper with NTP Server and time offset.
Definition jbwoprhelpers.cpp:17
static bool setTime(const std::string currentDateTime)
Definition jbwoprhelpers.cpp:85