RGB-Led driver, used to handle convertions between HEX and integer to regulate LEDS through the embed.
RGB-Led program
What is this about?
This program is created for managing RGB-Led's through a HTTP protocol
Main.cpp include
This is a short demo how to use the RGB and Color classes
RGB Class
This is the RGB Class with all the documentation
Import library
Public Member Functions |
|
RGB (PinName r_pin , PinName g_pin , PinName b_pin ) | |
Create
RGB
instance.
|
|
void | setColor ( Color * color ) |
setColor instance This will set the color
|
|
void | setColor (int red, int green, int blue) |
setColor instance with
RGB
This will set the color with given values red, green, blue
|
|
void | setColor (int color ) |
setColor instance with integer color This will set the color with given integer
|
|
Color * | getColor () |
getColor instance This will return the current color in a Color* object
|
|
void | Off () |
Off instance This will turn off all the leds.
|
|
void | invertColor ( Color * color ) |
invertColor instance This will invert every color
|
|
Data Fields |
|
PinName | r_pin |
pinNames r_pin declaration Declaration of PinName r_pin
|
|
PinName | b_pin |
pinNames b_pin declaration Declaration of PinName b_pin
|
|
PinName | g_pin |
pinNames g_pin declaration Declaration of PinName g_pin
|
|
Color * | color |
color declaration of type Color* Declaration of Color* color
|
|
PwmOut * | r_out |
PwmOut r_out declaration Declaration of PwmOut r_out.
|
|
PwmOut * | b_out |
PwmOut b_out declaration Declaration of PwmOut b_out.
|
|
PwmOut * | g_out |
PwmOut g_out declaration Declaration of PwmOut g_out.
|
|
Static Public Attributes |
|
static const int | MAX_COLOR_VALUE = 255 |
static const int MAX_COLOR_VALUE Sets the maximum color value, 255 for
RGB
|
Color Class
This is the Color Class with all the documentation
Import library
Public Types |
|
enum | colors |
enum of colors More... |
|
Public Member Functions |
|
Color (int red, int green, int blue) | |
Color
instance with red, green, blue as integers.
|
|
Color (int color) | |
Color
instance with an integer.
|
|
Color (float red, float green, float blue) | |
Color
instance with red, green, blue as floats.
|
|
int | getHex () |
getHex method Returns the color as a Hex
|
|
int | getRed () |
getRed method Returns the color red as an integer
|
|
int | getGreen () |
getGreen method Returns the color green as an integer
|
|
int | getBlue () |
getBlue method Returns the color blue as an integer
|
color.h@9:dc800c7bf78e, 2015-12-10 (annotated)
- Committer:
- ciryk
- Date:
- Thu Dec 10 14:51:05 2015 +0000
- Revision:
- 9:dc800c7bf78e
- Parent:
- 7:c99e1708714f
Main added;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ciryk | 0:44d0a336da9d | 1 | #ifndef COLOR_H |
ciryk | 0:44d0a336da9d | 2 | #define COLOR_H |
ciryk | 7:c99e1708714f | 3 | /** Color class |
ciryk | 7:c99e1708714f | 4 | * A Color class to manage the colors, from HEX to RGB or int. |
ciryk | 7:c99e1708714f | 5 | */ |
ciryk | 0:44d0a336da9d | 6 | class Color |
ciryk | 0:44d0a336da9d | 7 | { |
ciryk | 0:44d0a336da9d | 8 | public: |
ciryk | 7:c99e1708714f | 9 | /** enum of colors |
ciryk | 7:c99e1708714f | 10 | */ |
ciryk | 0:44d0a336da9d | 11 | enum colors { |
ciryk | 0:44d0a336da9d | 12 | RED= 0xFF0000, |
ciryk | 0:44d0a336da9d | 13 | GREEN = 0x00FF00, |
ciryk | 0:44d0a336da9d | 14 | BLUE = 0x0000FF, |
ciryk | 0:44d0a336da9d | 15 | CYAN = 0x00FFFF, |
ciryk | 0:44d0a336da9d | 16 | MAGENTA = 0xFF00FF, |
ciryk | 0:44d0a336da9d | 17 | YELLOW = 0xFFFFFF, |
ciryk | 0:44d0a336da9d | 18 | WHITE = 0xFFFFFF, |
ciryk | 0:44d0a336da9d | 19 | PINK = 0xFF69B4 |
ciryk | 0:44d0a336da9d | 20 | }; |
ciryk | 7:c99e1708714f | 21 | /** Color instance with red, green, blue as integers |
ciryk | 7:c99e1708714f | 22 | */ |
ciryk | 0:44d0a336da9d | 23 | Color(int red, int green, int blue); |
ciryk | 7:c99e1708714f | 24 | /** Color instance with an integer |
ciryk | 7:c99e1708714f | 25 | */ |
ciryk | 0:44d0a336da9d | 26 | Color(int color); |
ciryk | 7:c99e1708714f | 27 | /** Color instance with red, green, blue as floats |
ciryk | 7:c99e1708714f | 28 | */ |
ciryk | 0:44d0a336da9d | 29 | Color(float red, float green, float blue); |
ciryk | 7:c99e1708714f | 30 | /** getHex method |
ciryk | 7:c99e1708714f | 31 | *Returns the color as a Hex |
ciryk | 7:c99e1708714f | 32 | */ |
ciryk | 0:44d0a336da9d | 33 | int getHex(); |
ciryk | 7:c99e1708714f | 34 | /** getRed method |
ciryk | 7:c99e1708714f | 35 | *Returns the color red as an integer |
ciryk | 7:c99e1708714f | 36 | */ |
ciryk | 0:44d0a336da9d | 37 | int getRed(); |
ciryk | 7:c99e1708714f | 38 | /** getGreen method |
ciryk | 7:c99e1708714f | 39 | *Returns the color green as an integer |
ciryk | 7:c99e1708714f | 40 | */ |
ciryk | 0:44d0a336da9d | 41 | int getGreen(); |
ciryk | 7:c99e1708714f | 42 | /** getBlue method |
ciryk | 7:c99e1708714f | 43 | *Returns the color blue as an integer |
ciryk | 7:c99e1708714f | 44 | */ |
ciryk | 0:44d0a336da9d | 45 | int getBlue(); |
ciryk | 0:44d0a336da9d | 46 | |
ciryk | 0:44d0a336da9d | 47 | private: |
ciryk | 7:c99e1708714f | 48 | /** Declaration int red |
ciryk | 7:c99e1708714f | 49 | */ |
ciryk | 0:44d0a336da9d | 50 | int red; |
ciryk | 7:c99e1708714f | 51 | /** Declaration int blue |
ciryk | 7:c99e1708714f | 52 | */ |
ciryk | 0:44d0a336da9d | 53 | int blue; |
ciryk | 7:c99e1708714f | 54 | /** Declaration int green |
ciryk | 7:c99e1708714f | 55 | */ |
ciryk | 0:44d0a336da9d | 56 | int green; |
ciryk | 7:c99e1708714f | 57 | /** Declaration int color |
ciryk | 7:c99e1708714f | 58 | */ |
ciryk | 0:44d0a336da9d | 59 | int color; |
ciryk | 7:c99e1708714f | 60 | /** Declaration method floatToColorValue(float value) |
ciryk | 7:c99e1708714f | 61 | returns an int |
ciryk | 7:c99e1708714f | 62 | */ |
ciryk | 0:44d0a336da9d | 63 | int floatToColorValue(float value); |
ciryk | 7:c99e1708714f | 64 | /**Sets the maximum color value, 255 for RGB |
ciryk | 7:c99e1708714f | 65 | */ |
ciryk | 0:44d0a336da9d | 66 | static const int MAX_COLOR_VALUE = 255; |
ciryk | 0:44d0a336da9d | 67 | }; |
ciryk | 0:44d0a336da9d | 68 | |
ciryk | 0:44d0a336da9d | 69 | #endif |