my version of the RGBLed library. NOTHING changed, just wanted to put into my account.

Fork of RGBLed by Romain Berrada

Committer:
igalloway
Date:
Mon Dec 29 03:03:56 2014 +0000
Revision:
6:050081bc1393
Parent:
5:b125e5a28295
trying to add self-documentation to code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rominos2 4:176363412797 1 /*
rominos2 4:176363412797 2 Copyright (c) 2014 Romain Berrada
rominos2 4:176363412797 3
rominos2 4:176363412797 4 Permission is hereby granted, free of charge, to any person obtaining a copy of this software
rominos2 4:176363412797 5 and associated documentation files (the "Software"), to deal in the Software without restriction,
rominos2 4:176363412797 6 including without limitation the rights to use, copy, modify, merge, publish, distribute,
rominos2 4:176363412797 7 sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
rominos2 4:176363412797 8 furnished to do so, subject to the following conditions:
rominos2 4:176363412797 9
rominos2 4:176363412797 10 The above copyright notice and this permission notice shall be included in all copies or
rominos2 4:176363412797 11 substantial portions of the Software.
rominos2 4:176363412797 12
rominos2 4:176363412797 13 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
rominos2 4:176363412797 14 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
rominos2 4:176363412797 15 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
rominos2 4:176363412797 16 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
rominos2 4:176363412797 17 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
rominos2 4:176363412797 18 */
rominos2 4:176363412797 19
rominos2 5:b125e5a28295 20 #ifndef INCLUDE_RGBLED_H
rominos2 5:b125e5a28295 21 #define INCLUDE_RGBLED_H
rominos2 5:b125e5a28295 22
rominos2 3:be0a3c2ec426 23 #include "mbed.h"
rominos2 3:be0a3c2ec426 24
rominos2 3:be0a3c2ec426 25 /** A light RGB LED Class \n
rominos2 3:be0a3c2ec426 26 Warning : This library is for non-PWN LED \n
rominos2 3:be0a3c2ec426 27 Here is an quick hello-world class that makes the LED blink with all colors. \n
rominos2 3:be0a3c2ec426 28 @code
rominos2 3:be0a3c2ec426 29 #include "mbed.h"
igalloway 6:050081bc1393 30 #include "RGBLed.h" //was -> #include "rgb.h"
igalloway 6:050081bc1393 31
rominos2 3:be0a3c2ec426 32
rominos2 3:be0a3c2ec426 33 RGBLed led(LED_RED, LED_GREEN, LED_BLUE);
rominos2 3:be0a3c2ec426 34
rominos2 3:be0a3c2ec426 35 int main() {
rominos2 3:be0a3c2ec426 36 RGBLed::Color list[8] = {RGBLed::BLACK, RGBLed::RED, RGBLed::GREEN, RGBLed::BLUE, RGBLed::MAGENTA, RGBLed::CYAN, RGBLed::YELLOW, RGBLed::WHITE};
rominos2 3:be0a3c2ec426 37 int i = 0;
rominos2 3:be0a3c2ec426 38
rominos2 3:be0a3c2ec426 39 while (true) {
rominos2 3:be0a3c2ec426 40 i = (i+1)%8;
rominos2 3:be0a3c2ec426 41 led.setColor(list[i]);
rominos2 3:be0a3c2ec426 42 wait_ms(100);
rominos2 3:be0a3c2ec426 43 }
rominos2 3:be0a3c2ec426 44 }
rominos2 3:be0a3c2ec426 45 @endcode
rominos2 3:be0a3c2ec426 46 */
rominos2 3:be0a3c2ec426 47 class RGBLed {
rominos2 3:be0a3c2ec426 48 private:
rominos2 3:be0a3c2ec426 49 DigitalOut _red;
rominos2 3:be0a3c2ec426 50 DigitalOut _green;
rominos2 3:be0a3c2ec426 51 DigitalOut _blue;
rominos2 3:be0a3c2ec426 52
rominos2 3:be0a3c2ec426 53 public:
rominos2 3:be0a3c2ec426 54 /** RGB Color class \n
rominos2 3:be0a3c2ec426 55 Colors have been defined and are ready to use in RGBLed class
rominos2 3:be0a3c2ec426 56 */
rominos2 3:be0a3c2ec426 57 class Color {
rominos2 3:be0a3c2ec426 58 private:
rominos2 3:be0a3c2ec426 59 bool _r; /**< Red component of the Color */
rominos2 3:be0a3c2ec426 60 bool _g; /**< Green component of the Color */
rominos2 3:be0a3c2ec426 61 bool _b; /**< Blue component of the Color */
rominos2 3:be0a3c2ec426 62 Color(bool r, bool g, bool b); /**< Constructor */
rominos2 3:be0a3c2ec426 63 friend class RGBLed;
rominos2 3:be0a3c2ec426 64 };
rominos2 3:be0a3c2ec426 65
rominos2 3:be0a3c2ec426 66 /** Create a RGBLed, containing the informations about the LED pinout.
rominos2 3:be0a3c2ec426 67 @param redPin the pin linked to the Red LED
rominos2 3:be0a3c2ec426 68 @param greenPin the pin linked to the green LED
rominos2 3:be0a3c2ec426 69 @param blue the pin linked to the blue LED
rominos2 3:be0a3c2ec426 70 */
rominos2 3:be0a3c2ec426 71 RGBLed(PinName redPin, PinName greenPin, PinName bluePin);
rominos2 3:be0a3c2ec426 72
rominos2 3:be0a3c2ec426 73 /** Change the color of the LED.
rominos2 3:be0a3c2ec426 74 @param color the color to display
rominos2 3:be0a3c2ec426 75 @see RGBLed::Color
rominos2 3:be0a3c2ec426 76 */
rominos2 3:be0a3c2ec426 77 void setColor(RGBLed::Color& color);
rominos2 3:be0a3c2ec426 78
rominos2 3:be0a3c2ec426 79 static Color BLACK; /**< Black Color (no color) */
rominos2 3:be0a3c2ec426 80 static Color RED; /**< Red Color */
rominos2 3:be0a3c2ec426 81 static Color GREEN; /**< Green Color */
rominos2 3:be0a3c2ec426 82 static Color BLUE; /**< Blue Color */
rominos2 3:be0a3c2ec426 83 static Color MAGENTA; /**< Magenta Color (Red + Blue) */
rominos2 3:be0a3c2ec426 84 static Color CYAN; /**< Cyan Color (Green + Blue) */
rominos2 3:be0a3c2ec426 85 static Color YELLOW; /**< Yellow Color (Red + Green) */
rominos2 3:be0a3c2ec426 86 static Color WHITE; /**< White Color (Red + Green + Blue) */
rominos2 5:b125e5a28295 87 };
rominos2 5:b125e5a28295 88
rominos2 5:b125e5a28295 89 #endif