my version of the RGBLed library. NOTHING changed, just wanted to put into my account.
Fork of RGBLed by
RGBLed.h
- Committer:
- rominos2
- Date:
- 2014-09-03
- Revision:
- 3:be0a3c2ec426
- Child:
- 4:176363412797
File content as of revision 3:be0a3c2ec426:
#include "mbed.h"
/** A light RGB LED Class \n
Warning : This library is for non-PWN LED \n
Here is an quick hello-world class that makes the LED blink with all colors. \n
@code
#include "mbed.h"
#include "rgb.h"
RGBLed led(LED_RED, LED_GREEN, LED_BLUE);
int main() {
RGBLed::Color list[8] = {RGBLed::BLACK, RGBLed::RED, RGBLed::GREEN, RGBLed::BLUE, RGBLed::MAGENTA, RGBLed::CYAN, RGBLed::YELLOW, RGBLed::WHITE};
int i = 0;
while (true) {
i = (i+1)%8;
led.setColor(list[i]);
wait_ms(100);
}
}
@endcode
*/
class RGBLed {
private:
DigitalOut _red;
DigitalOut _green;
DigitalOut _blue;
public:
/** RGB Color class \n
Colors have been defined and are ready to use in RGBLed class
*/
class Color {
private:
bool _r; /**< Red component of the Color */
bool _g; /**< Green component of the Color */
bool _b; /**< Blue component of the Color */
Color(bool r, bool g, bool b); /**< Constructor */
friend class RGBLed;
};
/** Create a RGBLed, containing the informations about the LED pinout.
@param redPin the pin linked to the Red LED
@param greenPin the pin linked to the green LED
@param blue the pin linked to the blue LED
*/
RGBLed(PinName redPin, PinName greenPin, PinName bluePin);
/** Change the color of the LED.
@param color the color to display
@see RGBLed::Color
*/
void setColor(RGBLed::Color& color);
static Color BLACK; /**< Black Color (no color) */
static Color RED; /**< Red Color */
static Color GREEN; /**< Green Color */
static Color BLUE; /**< Blue Color */
static Color MAGENTA; /**< Magenta Color (Red + Blue) */
static Color CYAN; /**< Cyan Color (Green + Blue) */
static Color YELLOW; /**< Yellow Color (Red + Green) */
static Color WHITE; /**< White Color (Red + Green + Blue) */
};
