Easyuino  1.2.0
RGBLed.h
1 /*
2 MIT License
3 
4 Copyright (c) 2017 André Pires
5 
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12 
13 The above copyright notice and this permission notice shall be included in all
14 copies or substantial portions of the Software.
15 
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 SOFTWARE.
23 */
24 /*
25 RGBLed.h
26 */
27 #ifndef _EASYUINO_RGB_LED_h
28 #define _EASYUINO_RGB_LED_h
29 
30 #include "Utilities.h"
31 #include "Device.h"
32 
33 namespace Easyuino {
34 
36  enum LedType : uint8_t {
37  COMMON_ANODE,
38  COMMON_CATODE
39  };
40 
42  enum Color : uint8_t {
43  RED, GREEN, BLUE, YELLOW, WHITE, ORANGE, PINK, SALMON, VIOLET, AQUA, BROWN,
44  FIREBRICK, DARKGREY, OLIVE, SKYBLUE
45  };
46 
48  class RGBLed : public Device {
49 
50  private:
52  LedType _ledType;
53 
55  uint8_t _redPin;
57  uint8_t _greenPin;
59  uint8_t _bluePin;
60 
61  public:
67  RGBLed(IN uint8_t redPin, IN uint8_t greenPin, IN uint8_t bluePin);
68 
75  RGBLed(IN uint8_t redPin, IN uint8_t greenPin, IN uint8_t bluePin, IN LedType ledType);
76 
77  /* Destructor */
78  ~RGBLed();
79 
80  #pragma region Public Device API Methods
81 
82  bool begin();
83 
84  void end();
85 
86  #pragma endregion
87 
88  #pragma region Public RGBLed API Methods
89 
91  void turnOff();
92 
98  void setColor(IN uint8_t red, IN uint8_t green, IN uint8_t blue);
99 
103  void setColor(IN char hexadecimalColorCode[8]);
104 
108  void setColor(IN Color color);
109 
110  #pragma endregion
111 
112  };
113 
114 };
115 
116 #endif
void turnOff()
Turns off the led.
void setColor(IN uint8_t red, IN uint8_t green, IN uint8_t blue)
Set the led's color based on the RGB code.
RGBLed API allows to easily interact with a RGB led to set its color for example. ...
Definition: RGBLed.h:48
RGBLed(IN uint8_t redPin, IN uint8_t greenPin, IN uint8_t bluePin)
Constructor for a COMMON CATODE RGBLed.
Definition: Button.h:38
void end()
Used to stop the device API.
General class that provides the common API behaviour for all the devices/sensors. ...
Definition: Device.h:42
bool begin()
Used to put the device ready to receive requests.