2024-10-14 22:09:44 +02:00
|
|
|
#ifndef SimpLedRGB_h
|
|
|
|
#define SimpLedRGB_h
|
2024-10-14 12:04:46 +02:00
|
|
|
|
|
|
|
#include "Arduino.h"
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
float red;
|
|
|
|
float green;
|
|
|
|
float blue;
|
|
|
|
} Color;
|
|
|
|
|
2024-10-19 00:24:35 +02:00
|
|
|
const Color COLOR_CANDLE = {1.0, 0.5, 0.0};
|
|
|
|
const Color COLOR_VIOLET = {1.0, 0.0, 1.0};
|
|
|
|
const Color COLOR_GREEN = {0.0, 1.0, 0.0};
|
|
|
|
const Color COLOR_CYAN = {0.0, 0.5, 1.0};
|
|
|
|
const Color COLOR_RED = {1.0, 0.0, 0.0};
|
|
|
|
const Color COLOR_YELLOW = {1.0, 1.0, 0.0};
|
|
|
|
const Color COLOR_ORANGE = {1.0, 0.5, 0.0};
|
|
|
|
const Color COLOR_BLUE = {0.0, 0.0, 1.0};
|
|
|
|
|
2024-10-14 22:09:44 +02:00
|
|
|
class SimpLedRGB
|
2024-10-14 12:04:46 +02:00
|
|
|
{
|
|
|
|
int pin_red = 0;
|
|
|
|
int pin_green = 0;
|
|
|
|
int pin_blue = 0;
|
|
|
|
|
2024-10-19 00:24:35 +02:00
|
|
|
const double PULSE_PER_SECOND = ((PI * 2) / 1000.0);
|
|
|
|
|
2024-10-14 12:04:46 +02:00
|
|
|
Color color = {0.0, 0.0, 0.0};
|
|
|
|
|
|
|
|
public:
|
2024-10-14 22:09:44 +02:00
|
|
|
SimpLedRGB(int pinRed, int pinGreen, int pinBlue);
|
2024-10-14 12:04:46 +02:00
|
|
|
|
|
|
|
void begin();
|
|
|
|
|
|
|
|
void setColor(const Color &color);
|
|
|
|
|
|
|
|
void translateToColor(const Color &color, int duration_millis);
|
2024-10-19 00:24:35 +02:00
|
|
|
|
|
|
|
void rainbowCycle(int cycleDurationMillis);
|
|
|
|
|
2024-10-22 14:56:27 +02:00
|
|
|
void candle(const Color &color, float wind = 0.5);
|
2024-10-19 00:24:35 +02:00
|
|
|
|
|
|
|
void pulse(const Color &color, float timesPerSecond = 1.0, float amplitudeMin = 0.0, float amplitudeMax = 1.0);
|
2024-10-14 12:04:46 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|