my version of the RGBLed library. NOTHING changed, just wanted to put into my account.

Fork of RGBLed by Romain Berrada

Files at this revision

API Documentation at this revision

Comitter:
rominos2
Date:
Tue Sep 02 21:55:22 2014 +0000
Parent:
1:d492c575de97
Child:
3:be0a3c2ec426
Commit message:
Change from pointer to reference for the setColor method.

Changed in this revision

rgb.cpp Show annotated file Show diff for this revision Revisions of this file
rgb.h Show annotated file Show diff for this revision Revisions of this file
--- a/rgb.cpp	Tue Sep 02 21:34:05 2014 +0000
+++ b/rgb.cpp	Tue Sep 02 21:55:22 2014 +0000
@@ -4,13 +4,13 @@
 }
 
 RGB::RGB(PinName redPin, PinName greenPin, PinName bluePin) : _red(redPin), _green(greenPin), _blue(bluePin) {
-    this->setColor(&RGB::BLACK); // Clear the LED output
+    this->setColor(RGB::BLACK); // Clear the LED output
 }
 
-void RGB::setColor(Color* color) {
-    _red = color->_r;
-    _green = color->_g;
-    _blue = color->_b;
+void RGB::setColor(Color& color) {
+    _red = color._r;
+    _green = color._g;
+    _blue = color._b;
 }
 
 RGB::Color RGB::BLACK = RGB::Color(1,1,1);
--- a/rgb.h	Tue Sep 02 21:34:05 2014 +0000
+++ b/rgb.h	Tue Sep 02 21:55:22 2014 +0000
@@ -10,13 +10,13 @@
     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}; 
+        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) {  
+
+        while (true) {
             i = (i+1)%8;
             led.setColor(list[i]);
-            wait(1);
+            wait_ms(100);
         }
     }
     @endcode
@@ -48,10 +48,10 @@
     RGB(PinName redPin, PinName greenPin, PinName bluePin);    
     
     /** Change the color of the LED.
-        @param color the color (pointer) to display
+        @param color the color to display
         @see RGB::Color
     */
-    void setColor(RGB::Color* color);
+    void setColor(RGB::Color& color);
 
     static Color BLACK; /**< Black Color (no color) */
     static Color RED; /**< Red Color */