-
Notifications
You must be signed in to change notification settings - Fork 6
/
RGB_LED.h
111 lines (96 loc) · 2.52 KB
/
RGB_LED.h
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#ifndef RGB_LED_h
#define RGB_LED_h
#if ARDUINO >= 100
#include <Arduino.h>
#else
#include <WProgram.h>
#include <wiring.h>
#endif
//colours
#define Black 0
#define White 1
#define Red 2
#define Green 3
#define Blue 4
#define Yellow 5
#define Purple 6
#define Aqua 7
//functions
#define Random -1
#define Solid 0
#define Fade 1
#define FadeRandom 3
#define Step1 4
#define Step2 5
#define StepRandom 6
#define Blink 10
//PERCENT FUNCTION
float linear(float x);
float quadratic(float x);
float cos2(float x);
float waveup(float x);
float wavefaster(float x);
class RGB_LED
{
public:
// SETUP
RGB_LED(byte pinR,byte pinG,byte pinB);
RGB_LED(bool inverted, byte pinR,byte pinG,byte pinB);
void setCallback(float (*CallBack)(float x));
// SET
void set(byte Rvalue,byte Gvalue,byte Bvalue);
void setSpeed(unsigned long speedValue);
void setPercentFade(float FadeValue);
void fadeTo(byte Rvalue,byte Gvalue,byte Bvalue,unsigned long speedValue);
void setFunction(byte functionValue);
void setRandom();
void setColour(byte colour);
void fadeToColour(byte colour,unsigned long speedValue);
void setFunctionCount(int FunctionCount);
//GET
unsigned long getSpeed();
float getPercentFade();
byte getFunction();
byte getCurrentRValue();
byte getCurrentGValue();
byte getCurrentBValue();
int getFunctionCount();
// CHECKING
boolean hasFinished();
// COMMANDS
void run();
void runOff();
void stop();
void delay(unsigned long delayValue);
private:
byte R_Pin;
byte G_Pin;
byte B_Pin;
byte R_Set_value;
byte G_Set_value;
byte B_Set_value;
byte R_Last_value;
byte G_Last_value;
byte B_Last_value;
byte R_Current_value;
byte G_Current_value;
byte B_Current_value;
byte R_Future_value;
byte G_Future_value;
byte B_Future_value;
unsigned long Speed = 2000;
unsigned long starting_time;
int function=0;
int count;
bool invertedPins=false;
float (*FadeFunctionCallBack) (float x);
void writeOutput();
void FunctionsFinished();
void FadeFunction();
void FadeRandomFunction();
void StepRGBWFunction();
void StepAllFunction();
void StepRandomFunction();
void BlinkFunction();
};
#endif