71 lines
1.8 KiB
C++
71 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include <Arduino.h>
|
|
|
|
#define DEBUGLOG_DEFAULT_LOG_LEVEL_INFO
|
|
#include <DebugLog.h>
|
|
|
|
#include <mutex>
|
|
|
|
namespace drivers
|
|
{
|
|
|
|
class Led
|
|
{
|
|
|
|
public:
|
|
typedef struct
|
|
{
|
|
uint8_t r;
|
|
uint8_t g;
|
|
uint8_t b;
|
|
} color_t;
|
|
|
|
const color_t COLOR_OFF = {0, 0, 0};
|
|
const color_t COLOR_RED = {255, 0, 0};
|
|
const color_t COLOR_ORANGE = {255, 127, 0};
|
|
const color_t COLOR_YELLOW = {255, 255, 0};
|
|
const color_t COLOR_CHARTREUSE = {127, 255, 0};
|
|
const color_t COLOR_GREEN = {0, 255, 0};
|
|
const color_t COLOR_CYAN = {0, 255, 255};
|
|
const color_t COLOR_SKYBLUE = {0, 127, 255};
|
|
const color_t COLOR_BLUE = {0, 0, 255};
|
|
const color_t COLOR_VIOLET = {127, 0, 255};
|
|
const color_t COLOR_MAGENTA = {255, 0, 255};
|
|
|
|
public:
|
|
Led();
|
|
~Led();
|
|
|
|
void setEnforce(const bool enf);
|
|
void setColor(const color_t color);
|
|
void flashColor(const uint16_t tOn, const color_t color);
|
|
void blinkColor(const uint16_t tOn, const uint16_t tOff, const color_t color);
|
|
void blinkAlternate(const uint16_t tOn, const uint16_t tOff, const color_t color1, const color_t color2);
|
|
void blinkStop();
|
|
|
|
private:
|
|
static void flashHandle(TimerHandle_t th);
|
|
static void blinkTask(void *params);
|
|
|
|
private:
|
|
const uint8_t c_ledPin = 38;
|
|
|
|
color_t m_color1;
|
|
color_t m_color2;
|
|
color_t m_colorDefault;
|
|
|
|
uint16_t m_tOn;
|
|
uint16_t m_tOff;
|
|
|
|
TaskHandle_t m_blinkTask;
|
|
TimerHandle_t m_flashTimer;
|
|
|
|
bool m_flashing;
|
|
bool m_enforce;
|
|
|
|
std::mutex m_ledMutex;
|
|
};
|
|
|
|
}
|