53 lines
876 B
C++
53 lines
876 B
C++
/// © MiroZ 2024
|
|
|
|
#ifndef __LED_H__
|
|
#define __LED_H__
|
|
|
|
#include <stdint.h>
|
|
#include <Adafruit_NeoPixel.h>
|
|
#include "TaskMgr.h"
|
|
#include <System.h>
|
|
|
|
|
|
class Led
|
|
{
|
|
struct LED_QUEUE
|
|
{
|
|
uint8_t program;
|
|
uint8_t r;
|
|
uint8_t g;
|
|
uint8_t b;
|
|
};
|
|
|
|
public:
|
|
|
|
enum PROGRAM
|
|
{
|
|
STEADY,
|
|
PULSATING
|
|
};
|
|
|
|
protected:
|
|
Adafruit_NeoPixel *m_strip;
|
|
TaskHandle_t m_task = nullptr;
|
|
uint8_t m_brightness = 100;
|
|
|
|
uint8_t scale(uint8_t val){ return (uint8_t)((int)val*m_brightness/100); }
|
|
|
|
Queue<struct LED_QUEUE> m_queue;
|
|
|
|
protected:
|
|
void run();
|
|
void steady(uint8_t r, uint8_t g, uint8_t b, uint8_t delay);
|
|
|
|
public:
|
|
Led(uint32_t led_pin);
|
|
virtual ~Led();
|
|
|
|
public:
|
|
void setBrightness(uint8_t brightness);
|
|
void setColor(uint8_t r, uint8_t g, uint8_t b);
|
|
void setPulse(uint8_t r, uint8_t g, uint8_t b);
|
|
};
|
|
|
|
#endif /* __LED_H__ */ |