-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRGBEffects.h
More file actions
85 lines (71 loc) · 1.67 KB
/
RGBEffects.h
File metadata and controls
85 lines (71 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
RGBEffects - Library for making colour pattern effects with RGB LEDs.
*/
#ifndef RGBEffects_h
#define RGBEffects_h
#include "Arduino.h"
// change this to 1 to print out the colours being set. See RGBEffects::setLEDsColour
#define DEBUG_COLOURS_ENABLED (0)
struct rgb {
byte r, g, b;
};
struct point {
byte x, y, z;
};
/* Colour definitions */
const rgb RED = { 255, 0, 0 };
const rgb GREEN = { 0, 255, 0 };
const rgb BLUE = { 0, 0, 255 };
const rgb ORANGE = { 255, 165, 0 };
const rgb YELLOW = { 255, 255, 0 };
const rgb PURPLE = { 148, 0, 211 };
const rgb INDIGO = { 75, 0, 130 };
const rgb VIOLET = { 238, 130, 238 };
const rgb WHITE = { 255, 255, 255 };
const rgb OFF = { 0, 0, 0 };
enum RGBEffectType {
EFFECT_OFF = 0,
EFFECT_SOLID_RED,
EFFECT_SOLID_GREEN,
EFFECT_SOLID_BLUE,
EFFECT_SOLID_YELLOW,
EFFECT_SOLID_PURPLE,
EFFECT_SOLID_VIOLET,
EFFECT_SOLID_WHITE,
EFFECT_RAINBOW,
EFFECT_FADE,
EFFECT_CUBE,
EFFECT_BLINK,
EFFECT_COUNTER_FINAL // dont use this one, just for counting
};
#if DEBUG_COLOURS_ENABLED
void printColour(rgb colour);
void printColour(int red, int green, int blue);
#endif
class Effect {
public:
virtual void setup();
virtual rgb update();
};
class SolidEffect;
class RGBEffects
{
public:
RGBEffects(int redPin, int greenPin, int bluePin);
~RGBEffects();
void setEffect(RGBEffectType effect);
void nextEffect();
void update();
private:
int _redPin;
int _greenPin;
int _bluePin;
int _numLeds;
SolidEffect *_solidEffect; // this is ugly, but need to be able to change the colour
Effect * _effects[5];
int _currentEffectIndex;
RGBEffectType _curEffect;
void setLEDsColour(int red, int green, int blue);
void setLEDsColour(rgb colour);
};
#endif