my version of the RGBLed library. NOTHING changed, just wanted to put into my account.
Fork of RGBLed by
RGBLed.h
00001 /* 00002 Copyright (c) 2014 Romain Berrada 00003 00004 Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00005 and associated documentation files (the "Software"), to deal in the Software without restriction, 00006 including without limitation the rights to use, copy, modify, merge, publish, distribute, 00007 sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 00008 furnished to do so, subject to the following conditions: 00009 00010 The above copyright notice and this permission notice shall be included in all copies or 00011 substantial portions of the Software. 00012 00013 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00014 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00015 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00016 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00017 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00018 */ 00019 00020 #ifndef INCLUDE_RGBLED_H 00021 #define INCLUDE_RGBLED_H 00022 00023 #include "mbed.h" 00024 00025 /** A light RGB LED Class \n 00026 Warning : This library is for non-PWN LED \n 00027 Here is an quick hello-world class that makes the LED blink with all colors. \n 00028 @code 00029 #include "mbed.h" 00030 #include "RGBLed.h" //was -> #include "rgb.h" 00031 00032 00033 RGBLed led(LED_RED, LED_GREEN, LED_BLUE); 00034 00035 int main() { 00036 RGBLed::Color list[8] = {RGBLed::BLACK, RGBLed::RED, RGBLed::GREEN, RGBLed::BLUE, RGBLed::MAGENTA, RGBLed::CYAN, RGBLed::YELLOW, RGBLed::WHITE}; 00037 int i = 0; 00038 00039 while (true) { 00040 i = (i+1)%8; 00041 led.setColor(list[i]); 00042 wait_ms(100); 00043 } 00044 } 00045 @endcode 00046 */ 00047 class RGBLed { 00048 private: 00049 DigitalOut _red; 00050 DigitalOut _green; 00051 DigitalOut _blue; 00052 00053 public: 00054 /** RGB Color class \n 00055 Colors have been defined and are ready to use in RGBLed class 00056 */ 00057 class Color { 00058 private: 00059 bool _r; /**< Red component of the Color */ 00060 bool _g; /**< Green component of the Color */ 00061 bool _b; /**< Blue component of the Color */ 00062 Color(bool r, bool g, bool b); /**< Constructor */ 00063 friend class RGBLed; 00064 }; 00065 00066 /** Create a RGBLed, containing the informations about the LED pinout. 00067 @param redPin the pin linked to the Red LED 00068 @param greenPin the pin linked to the green LED 00069 @param blue the pin linked to the blue LED 00070 */ 00071 RGBLed(PinName redPin, PinName greenPin, PinName bluePin); 00072 00073 /** Change the color of the LED. 00074 @param color the color to display 00075 @see RGBLed::Color 00076 */ 00077 void setColor(RGBLed::Color& color); 00078 00079 static Color BLACK; /**< Black Color (no color) */ 00080 static Color RED; /**< Red Color */ 00081 static Color GREEN; /**< Green Color */ 00082 static Color BLUE; /**< Blue Color */ 00083 static Color MAGENTA; /**< Magenta Color (Red + Blue) */ 00084 static Color CYAN; /**< Cyan Color (Green + Blue) */ 00085 static Color YELLOW; /**< Yellow Color (Red + Green) */ 00086 static Color WHITE; /**< White Color (Red + Green + Blue) */ 00087 }; 00088 00089 #endif
Generated on Tue Jul 12 2022 21:47:52 by
1.7.2
