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
|
rgb.cpp@9:dc800c7bf78e, 2015-12-10 (annotated)
- Committer:
- ciryk
- Date:
- Thu Dec 10 14:51:05 2015 +0000
- Revision:
- 9:dc800c7bf78e
- Parent:
- 0:44d0a336da9d
Main added;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ciryk | 0:44d0a336da9d | 1 | |
ciryk | 0:44d0a336da9d | 2 | #include "rgb.h" |
ciryk | 0:44d0a336da9d | 3 | |
ciryk | 0:44d0a336da9d | 4 | RGB::RGB(PinName r_pin, PinName g_pin, PinName b_pin){ |
ciryk | 0:44d0a336da9d | 5 | this->r_out = new PwmOut(r_pin); |
ciryk | 0:44d0a336da9d | 6 | this->g_out = new PwmOut(g_pin); |
ciryk | 0:44d0a336da9d | 7 | this->b_out = new PwmOut(b_pin); |
ciryk | 0:44d0a336da9d | 8 | } |
ciryk | 0:44d0a336da9d | 9 | |
ciryk | 0:44d0a336da9d | 10 | void RGB::setColor(Color* color){ |
ciryk | 0:44d0a336da9d | 11 | this->color = color; |
ciryk | 0:44d0a336da9d | 12 | invertColor(color); |
ciryk | 0:44d0a336da9d | 13 | r_out->write (this->color->getRed()); |
ciryk | 0:44d0a336da9d | 14 | g_out->write (this->color->getGreen()); |
ciryk | 0:44d0a336da9d | 15 | b_out->write (this->color->getBlue()); |
ciryk | 0:44d0a336da9d | 16 | } |
ciryk | 0:44d0a336da9d | 17 | void RGB::setColor(int red, int green, int blue){ |
ciryk | 0:44d0a336da9d | 18 | this->color = new Color(red,green,blue); |
ciryk | 0:44d0a336da9d | 19 | } |
ciryk | 0:44d0a336da9d | 20 | void RGB::setColor(int color){ |
ciryk | 0:44d0a336da9d | 21 | this->color = new Color(color); |
ciryk | 0:44d0a336da9d | 22 | |
ciryk | 0:44d0a336da9d | 23 | } |
ciryk | 0:44d0a336da9d | 24 | void RGB::invertColor(Color* color){ |
ciryk | 0:44d0a336da9d | 25 | this->color = new Color( |
ciryk | 0:44d0a336da9d | 26 | MAX_COLOR_VALUE - color->getRed(), |
ciryk | 0:44d0a336da9d | 27 | MAX_COLOR_VALUE - color->getGreen(), |
ciryk | 0:44d0a336da9d | 28 | MAX_COLOR_VALUE - color->getBlue() |
ciryk | 0:44d0a336da9d | 29 | ); |
ciryk | 0:44d0a336da9d | 30 | } |
ciryk | 0:44d0a336da9d | 31 | void RGB::Off(){ |
ciryk | 0:44d0a336da9d | 32 | this->color = new Color(0,0,0); |
ciryk | 0:44d0a336da9d | 33 | } |
ciryk | 0:44d0a336da9d | 34 | |
ciryk | 0:44d0a336da9d | 35 | Color* RGB::getColor(){ |
ciryk | 0:44d0a336da9d | 36 | return this->color; |
ciryk | 0:44d0a336da9d | 37 | } |