LedDisplay/vscode/OmobiLEDdisplayBluetooth/include/LedDisplayController.h

117 lines
2.9 KiB
C
Raw Normal View History

#ifndef LED_DISPLAY_CONTROLLER
#define LED_DISPLAY_CONTROLLER
#include <Arduino.h>
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#include <EEPROM.h>
2020-10-15 00:02:48 +02:00
#include "esp_task_wdt.h"
class LedDisplayController
{
public:
explicit LedDisplayController(Adafruit_NeoMatrix *matrix);
~LedDisplayController();
enum text_align_t
{
AlignLeft,
AlignCenter,
AlignRight
};
enum DisplayTextSetParameter
{
TextParameter = 0,
ActiveParameter,
RuntimeParameter,
ColorParameter,
AlignmentParameter,
ScrollParameter,
ScrollSpeedParameter,
ScrollCountParameter,
IndexParameter,
2020-10-15 00:02:48 +02:00
DisplayTextSetParameterCount /*!< Just for helping purposes */
};
enum GetSetTextSetParameterExitCode
{
Success,
InvalidParameterError,
ParameterNotWritableError,
ValueOutOfRangeError,
IndexOutOfRangeError,
ValueIsNullptrError,
InternalError
};
2020-10-15 00:02:48 +02:00
static const uint16_t maximumTextSets = 6;
static const uint16_t maximumTextLength = 256;
void loop();
// modifiers for the internal text sets
String getTextSetParameter(int index, DisplayTextSetParameter parameter);
GetSetTextSetParameterExitCode setTextSetParameter(int index, DisplayTextSetParameter parameter, String value);
// brightness control
int getBrightness();
bool setBrightness(int brightness);
private:
// matrix objects
TaskHandle_t displayUpdateTask;
Adafruit_NeoMatrix *matrix;
// matrix variables
uint16_t text_curr_nr;
uint32_t text_set_starttime;
int text_pos;
unsigned int text_pass;
unsigned int textpixel;
int disp_brightness;
bool disp_show;
// matrix control
void disp_init();
void disp_start_set();
void disp_scroll_text();
void show_matrix(const char *text, int pos, const char *color);
uint16_t colorFromHex(String hex);
// storage structs
typedef struct text_set_t
{
2020-10-15 00:02:48 +02:00
char text[maximumTextLength];
bool active;
uint16_t runtime;
char color[7];
text_align_t alignment;
bool scroll;
2020-10-15 00:02:48 +02:00
int scrollSpeed; /*!< Between 0 and 10 */
uint16_t scrollCount;
} text_set_t;
typedef struct sets_t
{
2020-10-15 00:02:48 +02:00
text_set_t sets[maximumTextSets];
char valid[3];
} sets_t;
// storage variables
2020-10-15 12:50:50 +02:00
const text_set_t defaultTextSet {"", false, 0, "", AlignCenter, false, 0, 0};
sets_t text_sets;
// storage control
GetSetTextSetParameterExitCode getSetTextSetParameter(int index, DisplayTextSetParameter parameter, String *value, bool set = false);
void storeTextSets();
bool loadTextSets();
};
// function for updater task on core 0
void updateDisplayGlobal(void *);
extern LedDisplayController *ledDisplayControllerGlobal;
#endif // LED_DISPLAY_CONTROLLER