simple RGB led library

Dependents:   m3Dpi MQTT-Thermostat-example Final_project_Tran Final_project_Tran ... more

RGB-fun

RGB library used to control RGB leds using PWM modulation to dim and mix the individual colors. The library uses a Color helper class to define the colors. It is possible to define colors in these ways:

  • web color notation: #FF00AA
  • Integer notation: 0 - 255
  • Floating point notation: 0.0 - 1.0

By combining red, green and blue a great amount of colors can be created. This class can accept color objects or colors in hexadecimal notation (web color notation).

Note

Effects and effectsmanager are still experimental and not documented.

RGB class reference

Import library

Public Member Functions

RGB (PinName r_pin, PinName g_pin, PinName b_pin)
Create a new RGB instance.
void setColor ( Color *color)
Set the color by giving an instance of an Color object.
void setColor (int color)
Set the color by giving an integer in hexadecimal notation.
Color * getColor ()
Get the current color of the RGB led.
void off ()
Turn the led off.

Color class reference

Import library

Public Types

enum Colors

Enum with named colors for easy use.

More...

Public Member Functions

Color (int red, int green, int blue)
Create Color instance, giving individual red, green and blue factors as integer values.
Color (float red, float green, float blue)
Create Color instance, giving individual red, green and blue factors as floating point values.
Color (int hexColor)
Create Color instance, giving red, green and blue factors as a single integer value.
int getHex ()
Get the color value as an integer in hexadecimal notation.
int getRed ()
Get the red factor of the color.
int getGreen ()
Get the green factor of the color.
int getBlue ()
Get the blue factor of the color.

Example

Repository: rgb-fun-helloworld

Committer:
sillevl
Date:
Thu Nov 19 08:16:58 2015 +0000
Revision:
6:b5a88296bc50
merged and added example

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sillevl 6:b5a88296bc50 1
sillevl 6:b5a88296bc50 2 #ifndef COLOR_H
sillevl 6:b5a88296bc50 3 #define COLOR_H
sillevl 6:b5a88296bc50 4
sillevl 6:b5a88296bc50 5 class Color
sillevl 6:b5a88296bc50 6 {
sillevl 6:b5a88296bc50 7
sillevl 6:b5a88296bc50 8 int red;
sillevl 6:b5a88296bc50 9 int green;
sillevl 6:b5a88296bc50 10 int blue;
sillevl 6:b5a88296bc50 11
sillevl 6:b5a88296bc50 12 void setColor(int red, int green, int blue);
sillevl 6:b5a88296bc50 13
sillevl 6:b5a88296bc50 14 public:
sillevl 6:b5a88296bc50 15
sillevl 6:b5a88296bc50 16 enum Colors {RED = 0xFF0000, GREEN = 0x00FF00, BLUE = 0x0000FF, CYAN = 0x00FFFF, MAGENTA = 0xFF00FF, YELLOW = 0xFFFF00, WHITE = 0xFFFFFF, BLACK = 0x000000};
sillevl 6:b5a88296bc50 17
sillevl 6:b5a88296bc50 18 Color(int red, int green, int blue);
sillevl 6:b5a88296bc50 19 Color(float red, float green, float blue);
sillevl 6:b5a88296bc50 20 Color(int hexColor);
sillevl 6:b5a88296bc50 21
sillevl 6:b5a88296bc50 22 int getHex();
sillevl 6:b5a88296bc50 23
sillevl 6:b5a88296bc50 24 int getRed();
sillevl 6:b5a88296bc50 25 int getGreen();
sillevl 6:b5a88296bc50 26 int getBlue();
sillevl 6:b5a88296bc50 27
sillevl 6:b5a88296bc50 28 };
sillevl 6:b5a88296bc50 29
sillevl 6:b5a88296bc50 30 #endif