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:51:05 2015 +0000
Revision:
9:dc800c7bf78e
Parent:
7:c99e1708714f
Main added;

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 7:c99e1708714f 7 /** RGB-Led class
ciryk 7:c99e1708714f 8 * A RGB-LED class to control RGB-Leds
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 4:630bc0ac793a 27 /** setColor instance with integer color
ciryk 4:630bc0ac793a 28 *This will set the color with given integer
ciryk 4:630bc0ac793a 29 */
ciryk 0:44d0a336da9d 30 void setColor(int color);
ciryk 0:44d0a336da9d 31
ciryk 4:630bc0ac793a 32 /** getColor instance
ciryk 4:630bc0ac793a 33 *This will return the current color in a Color* object
ciryk 4:630bc0ac793a 34 */
ciryk 0:44d0a336da9d 35 Color*getColor();
ciryk 0:44d0a336da9d 36
ciryk 4:630bc0ac793a 37 /** Off instance
ciryk 4:630bc0ac793a 38 *This will turn off all the leds
ciryk 4:630bc0ac793a 39 */
ciryk 0:44d0a336da9d 40 void Off();
ciryk 0:44d0a336da9d 41
ciryk 5:d1ef75d89543 42 /** pinNames r_pin declaration
ciryk 5:d1ef75d89543 43 *Declaration of PinName r_pin
ciryk 4:630bc0ac793a 44 */
ciryk 5:d1ef75d89543 45 PinName r_pin;
ciryk 5:d1ef75d89543 46 /** pinNames b_pin declaration
ciryk 5:d1ef75d89543 47 *Declaration of PinName b_pin
ciryk 5:d1ef75d89543 48 */
ciryk 5:d1ef75d89543 49 PinName b_pin;
ciryk 5:d1ef75d89543 50 /** pinNames g_pin declaration
ciryk 5:d1ef75d89543 51 *Declaration of PinName g_pin
ciryk 5:d1ef75d89543 52 */
ciryk 5:d1ef75d89543 53 PinName g_pin;
ciryk 6:cc2732aa536f 54 /** color declaration of type Color*
ciryk 6:cc2732aa536f 55 *Declaration of Color* color
ciryk 6:cc2732aa536f 56 */
ciryk 0:44d0a336da9d 57 Color*color;
ciryk 6:cc2732aa536f 58 /** invertColor instance
ciryk 6:cc2732aa536f 59 *This will invert every color
ciryk 6:cc2732aa536f 60 */
ciryk 0:44d0a336da9d 61 void invertColor(Color* color);
ciryk 6:cc2732aa536f 62 /** PwmOut r_out declaration
ciryk 6:cc2732aa536f 63 *Declaration of PwmOut r_out
ciryk 6:cc2732aa536f 64 */
ciryk 0:44d0a336da9d 65 PwmOut* r_out;
ciryk 6:cc2732aa536f 66 /** PwmOut b_out declaration
ciryk 6:cc2732aa536f 67 *Declaration of PwmOut b_out
ciryk 6:cc2732aa536f 68 */
ciryk 0:44d0a336da9d 69 PwmOut* b_out;
ciryk 6:cc2732aa536f 70 /** PwmOut g_out declaration
ciryk 6:cc2732aa536f 71 *Declaration of PwmOut g_out
ciryk 6:cc2732aa536f 72 */
ciryk 0:44d0a336da9d 73 PwmOut* g_out;
ciryk 6:cc2732aa536f 74 /** static const int MAX_COLOR_VALUE
ciryk 6:cc2732aa536f 75 *Sets the maximum color value, 255 for RGB
ciryk 6:cc2732aa536f 76 */
ciryk 0:44d0a336da9d 77 static const int MAX_COLOR_VALUE = 255;
ciryk 0:44d0a336da9d 78
ciryk 0:44d0a336da9d 79 };
ciryk 0:44d0a336da9d 80
ciryk 0:44d0a336da9d 81 #endif