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

Fork of RGBLed by Romain Berrada

Committer:
rominos2
Date:
Wed Sep 03 10:13:45 2014 +0000
Revision:
3:be0a3c2ec426
Child:
4:176363412797
Change the Library name for better understanding.; Change some data type for optimization.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rominos2 3:be0a3c2ec426 1 #include "mbed.h"
rominos2 3:be0a3c2ec426 2
rominos2 3:be0a3c2ec426 3 /** A light RGB LED Class \n
rominos2 3:be0a3c2ec426 4 Warning : This library is for non-PWN LED \n
rominos2 3:be0a3c2ec426 5 Here is an quick hello-world class that makes the LED blink with all colors. \n
rominos2 3:be0a3c2ec426 6 @code
rominos2 3:be0a3c2ec426 7 #include "mbed.h"
rominos2 3:be0a3c2ec426 8 #include "rgb.h"
rominos2 3:be0a3c2ec426 9
rominos2 3:be0a3c2ec426 10 RGBLed led(LED_RED, LED_GREEN, LED_BLUE);
rominos2 3:be0a3c2ec426 11
rominos2 3:be0a3c2ec426 12 int main() {
rominos2 3:be0a3c2ec426 13 RGBLed::Color list[8] = {RGBLed::BLACK, RGBLed::RED, RGBLed::GREEN, RGBLed::BLUE, RGBLed::MAGENTA, RGBLed::CYAN, RGBLed::YELLOW, RGBLed::WHITE};
rominos2 3:be0a3c2ec426 14 int i = 0;
rominos2 3:be0a3c2ec426 15
rominos2 3:be0a3c2ec426 16 while (true) {
rominos2 3:be0a3c2ec426 17 i = (i+1)%8;
rominos2 3:be0a3c2ec426 18 led.setColor(list[i]);
rominos2 3:be0a3c2ec426 19 wait_ms(100);
rominos2 3:be0a3c2ec426 20 }
rominos2 3:be0a3c2ec426 21 }
rominos2 3:be0a3c2ec426 22 @endcode
rominos2 3:be0a3c2ec426 23 */
rominos2 3:be0a3c2ec426 24 class RGBLed {
rominos2 3:be0a3c2ec426 25 private:
rominos2 3:be0a3c2ec426 26 DigitalOut _red;
rominos2 3:be0a3c2ec426 27 DigitalOut _green;
rominos2 3:be0a3c2ec426 28 DigitalOut _blue;
rominos2 3:be0a3c2ec426 29
rominos2 3:be0a3c2ec426 30 public:
rominos2 3:be0a3c2ec426 31 /** RGB Color class \n
rominos2 3:be0a3c2ec426 32 Colors have been defined and are ready to use in RGBLed class
rominos2 3:be0a3c2ec426 33 */
rominos2 3:be0a3c2ec426 34 class Color {
rominos2 3:be0a3c2ec426 35 private:
rominos2 3:be0a3c2ec426 36 bool _r; /**< Red component of the Color */
rominos2 3:be0a3c2ec426 37 bool _g; /**< Green component of the Color */
rominos2 3:be0a3c2ec426 38 bool _b; /**< Blue component of the Color */
rominos2 3:be0a3c2ec426 39 Color(bool r, bool g, bool b); /**< Constructor */
rominos2 3:be0a3c2ec426 40 friend class RGBLed;
rominos2 3:be0a3c2ec426 41 };
rominos2 3:be0a3c2ec426 42
rominos2 3:be0a3c2ec426 43 /** Create a RGBLed, containing the informations about the LED pinout.
rominos2 3:be0a3c2ec426 44 @param redPin the pin linked to the Red LED
rominos2 3:be0a3c2ec426 45 @param greenPin the pin linked to the green LED
rominos2 3:be0a3c2ec426 46 @param blue the pin linked to the blue LED
rominos2 3:be0a3c2ec426 47 */
rominos2 3:be0a3c2ec426 48 RGBLed(PinName redPin, PinName greenPin, PinName bluePin);
rominos2 3:be0a3c2ec426 49
rominos2 3:be0a3c2ec426 50 /** Change the color of the LED.
rominos2 3:be0a3c2ec426 51 @param color the color to display
rominos2 3:be0a3c2ec426 52 @see RGBLed::Color
rominos2 3:be0a3c2ec426 53 */
rominos2 3:be0a3c2ec426 54 void setColor(RGBLed::Color& color);
rominos2 3:be0a3c2ec426 55
rominos2 3:be0a3c2ec426 56 static Color BLACK; /**< Black Color (no color) */
rominos2 3:be0a3c2ec426 57 static Color RED; /**< Red Color */
rominos2 3:be0a3c2ec426 58 static Color GREEN; /**< Green Color */
rominos2 3:be0a3c2ec426 59 static Color BLUE; /**< Blue Color */
rominos2 3:be0a3c2ec426 60 static Color MAGENTA; /**< Magenta Color (Red + Blue) */
rominos2 3:be0a3c2ec426 61 static Color CYAN; /**< Cyan Color (Green + Blue) */
rominos2 3:be0a3c2ec426 62 static Color YELLOW; /**< Yellow Color (Red + Green) */
rominos2 3:be0a3c2ec426 63 static Color WHITE; /**< White Color (Red + Green + Blue) */
rominos2 3:be0a3c2ec426 64 };