63 lines
1.1 KiB
C++
63 lines
1.1 KiB
C++
#pragma once
|
|
|
|
// System Inlcudes
|
|
#include <Arduino.h>
|
|
#include <mutex>
|
|
|
|
#define RED 0x00FF00
|
|
#define GREEN 0xFF0000
|
|
#define BLUE 0x0000FF
|
|
#define WHITE 0xFFFFFF
|
|
#define YELLOW 0xFFFF00
|
|
#define CYAN 0xFF00FF
|
|
#define MAGENTA 0x00FFFF
|
|
#define ORANGE 0xA5FF00
|
|
#define PURPLE 0x008080
|
|
#define PINK 0x69FFB4
|
|
#define LIME 0xCD3232
|
|
#define SKY_BLUE 0xCE87EB
|
|
#define GOLD 0xD7FF00
|
|
#define TURQUOISE 0xE040D0
|
|
#define INDIGO 0x004B82
|
|
#define GRAY 0x808080
|
|
|
|
class RGBled
|
|
{
|
|
public:
|
|
enum LedStatus
|
|
{
|
|
OK = GREEN,
|
|
ERROR = RED,
|
|
INIT = YELLOW,
|
|
DATA_A = CYAN,
|
|
DATA_B = MAGENTA,
|
|
DATA_ALL = ORANGE,
|
|
IDLE = GRAY
|
|
};
|
|
|
|
struct color_t
|
|
{
|
|
uint8_t a, g, r, b;
|
|
};
|
|
|
|
union color_u
|
|
{
|
|
uint32_t status;
|
|
color_t color;
|
|
};
|
|
|
|
public:
|
|
RGBled(const uint8_t pin = 48);
|
|
~RGBled();
|
|
|
|
void setStatus(const LedStatus s);
|
|
const LedStatus getSatus(void);
|
|
|
|
private:
|
|
void writeStatus(const LedStatus s);
|
|
|
|
private:
|
|
LedStatus m_status = LedStatus::IDLE;
|
|
std::mutex m_mutex;
|
|
const uint8_t m_led;
|
|
}; |