This commit is contained in:
2026-04-11 00:40:33 +02:00
parent eaeb515074
commit d41a99ee88
4 changed files with 95 additions and 6 deletions

View File

@@ -0,0 +1,29 @@
#include <led.h>
RGBled::RGBled(const uint8_t pin, const uint8_t num)
{
m_led = Adafruit_NeoPixel(num, pin, NEO_GRB + NEO_KHZ800);
m_led.begin();
m_led.setPixelColor(0, RED);
m_led.show();
}
RGBled::~RGBled()
{
m_led.clear();
}
void RGBled::setStatus(const LedStatus s)
{
if (m_status == s) return;
m_status = s;
RGB_BUILTIN_LED_COLOR_ORDER
m_led.setPixelColor(0, s);
m_led.setBrightness(16);
m_led.show();
}
const RGBled::LedStatus RGBled::getSatus(void)
{
return m_status;
}

View File

@@ -0,0 +1,48 @@
#pragma once
// System Inlcudes
#include <Arduino.h>
#include <Adafruit_NeoPixel.h>
#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
};
public:
RGBled(const uint8_t pin = 48, const uint8_t num = 1);
~RGBled();
void setStatus(const LedStatus s);
const LedStatus getSatus(void);
private:
Adafruit_NeoPixel m_led;
LedStatus m_status = LedStatus::IDLE;
};