-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRGB_LED.cpp
More file actions
104 lines (100 loc) · 2.11 KB
/
Copy pathRGB_LED.cpp
File metadata and controls
104 lines (100 loc) · 2.11 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*!
* \class RGB_LED
* \file RGB_LED.cpp
*
* \author Michael Pillon
*
*/
#include "mbed.h"
#include "RGB_LED.hpp"
/*!
Constructor
*/
RGB_LED::RGB_LED(Type type, PinName redPin, PinName greenPin, PinName bluePin) :
type(type),
LED_ON(!type),
LED_OFF(type),
redLED(redPin),
greenLED(greenPin),
blueLED(bluePin)
{
setOff();
};
/*!
Set RGB LED to the colour red
*/
void RGB_LED::setRed() {
currentState = RED;
redLED = LED_ON;
greenLED = LED_OFF;
blueLED = LED_OFF;
}
/*!
Set RGB LED to the colour green
*/
void RGB_LED::setGreen() {
currentState = GREEN;
redLED = LED_OFF;
greenLED = LED_ON;
blueLED = LED_OFF;
}
/*!
Set RGB LED to the colour Blue
*/
void RGB_LED::setBlue() {
currentState = BLUE;
redLED = LED_OFF;
greenLED = LED_OFF;
blueLED = LED_ON;
}
/*!
Set RGB LED to the colour magenta
*/
void RGB_LED::setMagenta() {
currentState = MAGENTA;
redLED = LED_ON;
greenLED = LED_OFF;
blueLED = LED_ON;
}
/*!
Set RGB LED to the colour yellow
*/
void RGB_LED::setYellow() {
currentState = YELLOW;
redLED = LED_ON;
greenLED = LED_ON;
blueLED = LED_OFF;
}
/*!
Set RGB LED to the colour cyan
*/
void RGB_LED::setCyan() {
currentState = CYAN;
redLED = LED_OFF;
greenLED = LED_ON;
blueLED = LED_ON;
}
/*!
Set RGB LED to the colour white
*/
void RGB_LED::setWhite() {
currentState = WHITE;
redLED = LED_ON;
greenLED = LED_ON;
blueLED = LED_ON;
}
/*!
Set GRB LED to off
*/
void RGB_LED::setOff() {
currentState = OFF;
redLED = LED_OFF;
greenLED = LED_OFF;
blueLED = LED_OFF;
}
/*!
Get the current LED colour
*/
RGB_LED::State RGB_LED::getCurrentSate() {
return currentState;
}