Easyuino  1.1.0
RGBLedTest.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 RGBLedTest.h
26 */
27 #ifndef _EASYUINO_RGB_LET_TEST_h
28 #define _EASYUINO_RGB_LED_TEST_h
29 
30 #include "Easyuino.h"
31 #include "ManualTest.h"
32 
33 using Easyuino::RGBLed;
34 
35 class RGBLedTest : public ManualTest {
36 
37  private:
38  RGBLed* rgbLedCatode;
39 
40  public:
41  RGBLedTest(Stream &debugStream, uint8_t redPin, uint8_t greenPin, uint8_t bluePin) :
42  ManualTest(debugStream) {
43  rgbLedCatode = new RGBLed(redPin, greenPin, bluePin, RGBLed::COMMON_CATODE);
44  }
45 
46  protected:
47  void testsSetup() {
48  rgbLedCatode->begin();
49  }
50 
51  void tests() {
52  testStart("RED LED");
53  rgbLedCatode->setColor(255, 0, 0);
54  testEnd();
55 
56  testStart("GREEN LED");
57  rgbLedCatode->setColor(0, 255, 0);
58  testEnd();
59 
60  testStart("BLUE LED");
61  rgbLedCatode->setColor(0, 0, 255);
62  testEnd();
63 
64  testStart("LED OFF");
65  rgbLedCatode->turnOff();
66  testEnd();
67 
68  testStart("LED ORANGE");
69  rgbLedCatode->setColor("#ff6600");
70  testEnd();
71 
72  testStart("GREEN LED");
73  rgbLedCatode->setColor(RGBLed::Color::GREEN);
74  testEnd();
75 
76  testStart("PINK LED");
77  rgbLedCatode->setColor(RGBLed::Color::PINK);
78  testEnd();
79 
80  testStart("WHITE LED");
81  rgbLedCatode->setColor(RGBLed::Color::WHITE);
82  testEnd();
83 
84  testStart("FIREBRICK LED");
85  rgbLedCatode->setColor(RGBLed::Color::FIREBRICK);
86  testEnd();
87 
88  testStart("END RGB LED => LED OFF");
89  rgbLedCatode->end();
90  testEnd();
91 
92  testStart("LED MAINTAIN OFF");
93  rgbLedCatode->setColor(0,0,255);
94  testEnd();
95  }
96 
97  void afterTestSuite() {
98  rgbLedCatode->end();
99  delete rgbLedCatode;
100  rgbLedCatode = NULL;
101  }
102 
103 };
104 
105 #endif
Definition: RGBLed.h:48
Definition: RGBLedTest.h:35
Definition: ManualTest.h:42