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

Repository: hello_world_RGB

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
Committer:
ciryk
Date:
Thu Dec 10 14:20:28 2015 +0000
Revision:
3:c6e16ad073f6
Parent:
2:37ffab5933a1
Child:
4:630bc0ac793a
Added two doc instances

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ciryk 0:44d0a336da9d 1 #ifndef RGB_H
ciryk 0:44d0a336da9d 2 #define RGB_H
ciryk 0:44d0a336da9d 3
ciryk 0:44d0a336da9d 4 #include "mbed.h"
ciryk 0:44d0a336da9d 5 #include "color.h"
ciryk 1:e0b5972b1aad 6
ciryk 1:e0b5972b1aad 7 /** My HelloWorld class.
ciryk 1:e0b5972b1aad 8 * Used for printing "Hello World" on USB serial.
ciryk 2:37ffab5933a1 9 */
ciryk 0:44d0a336da9d 10 class RGB
ciryk 0:44d0a336da9d 11 {
ciryk 1:e0b5972b1aad 12
ciryk 0:44d0a336da9d 13
ciryk 0:44d0a336da9d 14 public :
ciryk 2:37ffab5933a1 15 /** Create RGB instance
ciryk 2:37ffab5933a1 16 */
ciryk 0:44d0a336da9d 17 RGB(PinName r_pin, PinName g_pin, PinName b_pin);
ciryk 3:c6e16ad073f6 18
ciryk 3:c6e16ad073f6 19 /** setColor instance
ciryk 3:c6e16ad073f6 20 *This will set the color
ciryk 3:c6e16ad073f6 21 */
ciryk 0:44d0a336da9d 22 void setColor(Color*color);
ciryk 3:c6e16ad073f6 23 /** setColor instance with RGB
ciryk 3:c6e16ad073f6 24 *This will set the color with given values red, green, blue
ciryk 3:c6e16ad073f6 25 */
ciryk 0:44d0a336da9d 26 void setColor(int red, int green, int blue);
ciryk 0:44d0a336da9d 27 void setColor(int color);
ciryk 0:44d0a336da9d 28
ciryk 0:44d0a336da9d 29 Color*getColor();
ciryk 0:44d0a336da9d 30
ciryk 0:44d0a336da9d 31 void Off();
ciryk 0:44d0a336da9d 32
ciryk 0:44d0a336da9d 33 PinName r_pin, b_pin, g_pin;
ciryk 0:44d0a336da9d 34
ciryk 0:44d0a336da9d 35 Color*color;
ciryk 0:44d0a336da9d 36
ciryk 0:44d0a336da9d 37 void invertColor(Color* color);
ciryk 0:44d0a336da9d 38
ciryk 0:44d0a336da9d 39 PwmOut* r_out;
ciryk 0:44d0a336da9d 40 PwmOut* b_out;
ciryk 0:44d0a336da9d 41 PwmOut* g_out;
ciryk 0:44d0a336da9d 42
ciryk 0:44d0a336da9d 43 static const int MAX_COLOR_VALUE = 255;
ciryk 0:44d0a336da9d 44
ciryk 0:44d0a336da9d 45 };
ciryk 0:44d0a336da9d 46
ciryk 0:44d0a336da9d 47 #endif