my version of the RGBLed library. NOTHING changed, just wanted to put into my account.
Fork of RGBLed by
Revision 3:be0a3c2ec426, committed 2014-09-03
- Comitter:
- rominos2
- Date:
- Wed Sep 03 10:13:45 2014 +0000
- Parent:
- 2:3c0889914cb2
- Child:
- 4:176363412797
- Commit message:
- Change the Library name for better understanding.; Change some data type for optimization.
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/RGBLed.cpp Wed Sep 03 10:13:45 2014 +0000
@@ -0,0 +1,23 @@
+#include "RGBLed.h"
+
+RGBLed::Color::Color(bool r, bool g, bool b) : _r(r), _g(g), _b(b) {
+}
+
+RGBLed::RGBLed(PinName redPin, PinName greenPin, PinName bluePin) : _red(redPin), _green(greenPin), _blue(bluePin) {
+ this->setColor(RGBLed::BLACK); // Clear the LED output
+}
+
+void RGBLed::setColor(Color& color) {
+ _red = color._r;
+ _green = color._g;
+ _blue = color._b;
+}
+
+RGBLed::Color RGBLed::BLACK = RGBLed::Color(1,1,1);
+RGBLed::Color RGBLed::RED = RGBLed::Color(0,1,1);
+RGBLed::Color RGBLed::GREEN = RGBLed::Color(1,0,1);
+RGBLed::Color RGBLed::BLUE = RGBLed::Color(1,1,0);
+RGBLed::Color RGBLed::MAGENTA = RGBLed::Color(0,1,0);
+RGBLed::Color RGBLed::CYAN = RGBLed::Color(1,0,0);
+RGBLed::Color RGBLed::YELLOW = RGBLed::Color(0,0,1);
+RGBLed::Color RGBLed::WHITE = RGBLed::Color(0,0,0);
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/RGBLed.h Wed Sep 03 10:13:45 2014 +0000
@@ -0,0 +1,64 @@
+#include "mbed.h"
+
+/** A light RGB LED Class \n
+ Warning : This library is for non-PWN LED \n
+ Here is an quick hello-world class that makes the LED blink with all colors. \n
+ @code
+ #include "mbed.h"
+ #include "rgb.h"
+
+ RGBLed led(LED_RED, LED_GREEN, LED_BLUE);
+
+ int main() {
+ RGBLed::Color list[8] = {RGBLed::BLACK, RGBLed::RED, RGBLed::GREEN, RGBLed::BLUE, RGBLed::MAGENTA, RGBLed::CYAN, RGBLed::YELLOW, RGBLed::WHITE};
+ int i = 0;
+
+ while (true) {
+ i = (i+1)%8;
+ led.setColor(list[i]);
+ wait_ms(100);
+ }
+ }
+ @endcode
+*/
+class RGBLed {
+private:
+ DigitalOut _red;
+ DigitalOut _green;
+ DigitalOut _blue;
+
+public:
+ /** RGB Color class \n
+ Colors have been defined and are ready to use in RGBLed class
+ */
+ class Color {
+ private:
+ bool _r; /**< Red component of the Color */
+ bool _g; /**< Green component of the Color */
+ bool _b; /**< Blue component of the Color */
+ Color(bool r, bool g, bool b); /**< Constructor */
+ friend class RGBLed;
+ };
+
+ /** Create a RGBLed, containing the informations about the LED pinout.
+ @param redPin the pin linked to the Red LED
+ @param greenPin the pin linked to the green LED
+ @param blue the pin linked to the blue LED
+ */
+ RGBLed(PinName redPin, PinName greenPin, PinName bluePin);
+
+ /** Change the color of the LED.
+ @param color the color to display
+ @see RGBLed::Color
+ */
+ void setColor(RGBLed::Color& color);
+
+ static Color BLACK; /**< Black Color (no color) */
+ static Color RED; /**< Red Color */
+ static Color GREEN; /**< Green Color */
+ static Color BLUE; /**< Blue Color */
+ static Color MAGENTA; /**< Magenta Color (Red + Blue) */
+ static Color CYAN; /**< Cyan Color (Green + Blue) */
+ static Color YELLOW; /**< Yellow Color (Red + Green) */
+ static Color WHITE; /**< White Color (Red + Green + Blue) */
+};
\ No newline at end of file
--- a/rgb.cpp Tue Sep 02 21:55:22 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-#include "rgb.h"
-
-RGB::Color::Color(uint8_t r, uint8_t g, uint8_t b) : _r(r), _g(g), _b(b) {
-}
-
-RGB::RGB(PinName redPin, PinName greenPin, PinName bluePin) : _red(redPin), _green(greenPin), _blue(bluePin) {
- this->setColor(RGB::BLACK); // Clear the LED output
-}
-
-void RGB::setColor(Color& color) {
- _red = color._r;
- _green = color._g;
- _blue = color._b;
-}
-
-RGB::Color RGB::BLACK = RGB::Color(1,1,1);
-RGB::Color RGB::RED = RGB::Color(0,1,1);
-RGB::Color RGB::GREEN = RGB::Color(1,0,1);
-RGB::Color RGB::BLUE = RGB::Color(1,1,0);
-RGB::Color RGB::MAGENTA = RGB::Color(0,1,0);
-RGB::Color RGB::CYAN = RGB::Color(1,0,0);
-RGB::Color RGB::YELLOW = RGB::Color(0,0,1);
-RGB::Color RGB::WHITE = RGB::Color(0,0,0);
\ No newline at end of file
--- a/rgb.h Tue Sep 02 21:55:22 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-#include "mbed.h"
-
-/** A light RGB LED Class \n
- Warning : This library is for non-PWN LED \n
- Here is an quick hello-world class that makes the LED blink with all colors. \n
- @code
- #include "mbed.h"
- #include "rgb.h"
-
- RGB led(LED_RED, LED_GREEN, LED_BLUE);
-
- int main() {
- RGB::Color list[8] = {RGB::BLACK, RGB::RED, RGB::GREEN, RGB::BLUE, RGB::MAGENTA, RGB::CYAN, RGB::YELLOW, RGB::WHITE};
- int i = 0;
-
- while (true) {
- i = (i+1)%8;
- led.setColor(list[i]);
- wait_ms(100);
- }
- }
- @endcode
-*/
-class RGB {
-private:
- DigitalOut _red;
- DigitalOut _green;
- DigitalOut _blue;
-
-public:
- /** RGB Color class \n
- Colors have been defined and are ready to use in RGB class
- */
- class Color {
- private:
- uint8_t _r; /**< Red component of the Color */
- uint8_t _g; /**< Green component of the Color */
- uint8_t _b; /**< Blue component of the Color */
- Color(uint8_t r, uint8_t g, uint8_t b); /**< Constructor */
- friend class RGB;
- };
-
- /** Create a RBG Object, containing the informations about the RGB pinout.
- @param redPin the pin linked to the Red LED
- @param greenPin the pin linked to the green LED
- @param blue the pin linked to the blue LED
- */
- RGB(PinName redPin, PinName greenPin, PinName bluePin);
-
- /** Change the color of the LED.
- @param color the color to display
- @see RGB::Color
- */
- void setColor(RGB::Color& color);
-
- static Color BLACK; /**< Black Color (no color) */
- static Color RED; /**< Red Color */
- static Color GREEN; /**< Green Color */
- static Color BLUE; /**< Blue Color */
- static Color MAGENTA; /**< Magenta Color (Red + Blue) */
- static Color CYAN; /**< Cyan Color (Green + Blue) */
- static Color YELLOW; /**< Yellow Color (Red + Green) */
- static Color WHITE; /**< White Color (Red + Green + Blue) */
-};
\ No newline at end of file
