Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: m3Dpi MQTT-Thermostat-example Final_project_Tran Final_project_Tran ... more
Diff: RGB.h
- Revision:
- 5:036a21c44cb7
- Parent:
- 2:ed46f45e1d66
- Child:
- 6:b5a88296bc50
--- a/RGB.h Wed Oct 21 17:12:10 2015 +0000
+++ b/RGB.h Thu Nov 19 08:06:05 2015 +0000
@@ -5,23 +5,43 @@
#ifndef RGB_H
#define RGB_H
+/** RGB class
+ * Used to control RGB leds using PWM modulation to dim the individual colors. 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)
+ */
class RGB{
public:
static const int OFF = 0;
+ /** Create a new RGB instance
+ * @param r_pin mbed PinName that supports PWM output assigned to the red led
+ * @param g_pin mbed PinName that supports PWM output assigned to the green led
+ * @param b_pin mbed PinName that supports PWM output assigned to the blue led
+ */
RGB(PinName r_pin, PinName g_pin, PinName b_pin);
- // void setIntensity(int intensity); // How are we gonna do this?
+
+ /** Set the color by giving an instance of an Color object
+ * @param color Pointer to an instance of an Color object
+ * @ref Color
+ */
void setColor(Color* color);
+
+ /** Set the color by giving an integer in hexadecimal notation
+ * @param color Color in hexadecimal notation (hex triplet). 24-bit RGB color as used in web colors.
+ * @note Each color is made up of 8 bits, 0xRRGGBB
+ */
void setColor(int color);
+
+ /** Get the current color of the RGB led
+ * @return instance of Color class containing the current set color
+ * @ref Color
+ */
Color* getColor();
- // void on(); // do we need this? what value to turn on to?
+ /// Turn the led off
void off();
- protected:
- //void setColor(int r, int g, int b);
-
private:
PwmOut* r_out;
PwmOut* g_out;