Jamie Bowen / Mbed 2 deprecated RGBLED_K64F_6COLOURS

Dependencies:   mbed

Fork of RGBLED by Steven Cheldelin

Files at this revision

API Documentation at this revision

Comitter:
bohocode
Date:
Thu Jan 29 08:42:26 2015 +0000
Parent:
0:7c0b6a649748
Commit message:
Added yellow, cyan and magenta.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
rgbled.cpp Show annotated file Show diff for this revision Revisions of this file
rgbled.h Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Jun 09 14:17:39 2014 +0000
+++ b/main.cpp	Thu Jan 29 08:42:26 2015 +0000
@@ -9,9 +9,15 @@
     while(1){
         rgb.set(red);
         wait(1);
+        rgb.set(yellow);
+        wait(1);
         rgb.set(green);
         wait(1);
+        rgb.set(cyan);
+        wait(1);
         rgb.set(blue);
         wait(1);
+        rgb.set(magenta);
+        wait(1);
     }
 }        
\ No newline at end of file
--- a/rgbled.cpp	Mon Jun 09 14:17:39 2014 +0000
+++ b/rgbled.cpp	Thu Jan 29 08:42:26 2015 +0000
@@ -39,6 +39,24 @@
     _pin_blue = _on;
 }
 
+void rgbled::_cyan(void){
+    _pin_red = _off;
+    _pin_green = _on;
+    _pin_blue = _on;
+}
+
+void rgbled::_yellow(void){
+    _pin_red = _on;
+    _pin_green = _on;
+    _pin_blue = _off;
+}
+ 
+void rgbled::_magenta(void){
+    _pin_red = _on;
+    _pin_green = _off;
+    _pin_blue = _on;
+}    
+
 void rgbled::set(color c){
         switch (c) {
             case none :
@@ -47,11 +65,20 @@
             case red :
                 _red();
                 break;
+            case yellow :
+                _yellow();
+                break;
             case green :
                 _green();
                 break;
+            case cyan:
+                _cyan();
+                break;
             case blue :
                 _blue();
                 break;
+            case magenta :
+                _magenta();
+                break;
         }
 }
--- a/rgbled.h	Mon Jun 09 14:17:39 2014 +0000
+++ b/rgbled.h	Thu Jan 29 08:42:26 2015 +0000
@@ -5,7 +5,7 @@
 #include "mbed.h"
 
 // defines
-enum color {none, red, green, blue};
+enum color {none, red, yellow, green, cyan, blue, magenta};
 
 // rgb led
 class rgbled {
@@ -17,8 +17,11 @@
     bool _off;
     void _none(void);
     void _red(void);
+    void _yellow(void);
     void _green(void);
+    void _cyan(void);
     void _blue(void);
+    void _magenta(void);
 public:
     rgbled(PinName pin_red, PinName pin_green, PinName pin_blue);
     void active(bool a);