-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRGB.h
60 lines (49 loc) · 1.47 KB
/
RGB.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
/*
Object RGB
Intent: Light up a single RGB LED according to three colour inputs, directly to the hardware,
Interface:
Language is
Low =0, converted at on() stage
Three colours: between 0 to 255 - 255 means on, 0 meean off
durations in milliseconds
Ngradation of colour
Hardware
Three digital Hardware Pins
Translate From Hardware - High as a parameter need to be convered to LOW as an input to the hardware
Usage: First setPins, then repeatedly (setColour or NextColour, then switch on or shine to illuminate) then off. the LED
Choices:
Assume a differenet HW light for indicators, and headlamps etc. Heep it simple and separate hardware
retain colour even if off
*/
#ifndef RGB_h
#define RGB_h
#include "Arduino.h"
class RGB
{
public:
RGB();
RGB(int rPin, int gPin, int bPin);
void setPins(int rPin, int gPin, int bPin);
void setColour(int r, int g, int b);
void nextColour();
void on(int duration);
void on();
void off();
void setFlash(bool flashing);
void debug();
// void setFlash(bool flashing);
//void set(int r, int g, int b, bool temporary, int duration, bool flashing);
private:
void _ledWrite(int r, int g, int b);
int _rPin;
int _gPin;
int _bPin;
int _r;
int _g;
int _b;
int _RGBValue;
bool _isOn;
int _off = 255;
// bool _isFlashing;
};
#endif