RGB LED Class

Dependencies:   mbed

Fork of RGBLED by Steven Cheldelin

Revision:
0:7c0b6a649748
diff -r 000000000000 -r 7c0b6a649748 rgbled.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rgbled.cpp	Mon Jun 09 14:17:39 2014 +0000
@@ -0,0 +1,57 @@
+#include "mbed.h"
+#include "rgbled.h"
+
+rgbled::rgbled(PinName pin_red, PinName pin_green, PinName pin_blue)
+             : _pin_red(pin_red), _pin_green(pin_green), _pin_blue(pin_blue){
+    _on = false;
+    _off = !_on;
+    _pin_red = _off;
+    _pin_green = _off;
+    _pin_blue = _off;
+}
+
+void rgbled::active(bool a){
+    _on = a;
+    _off = !_on;
+}
+    
+void rgbled::_none(void){
+    _pin_red = _off;
+    _pin_green = _off;
+    _pin_blue = _off;
+}
+
+void rgbled::_red(void){
+    _pin_red = _on;
+    _pin_green = _off;
+    _pin_blue = _off;
+}
+
+void rgbled::_green(void){
+    _pin_red = _off;
+    _pin_green = _on;
+    _pin_blue = _off;
+}
+
+void rgbled::_blue(void){
+    _pin_red = _off;
+    _pin_green = _off;
+    _pin_blue = _on;
+}
+
+void rgbled::set(color c){
+        switch (c) {
+            case none :
+                _none();
+                break;
+            case red :
+                _red();
+                break;
+            case green :
+                _green();
+                break;
+            case blue :
+                _blue();
+                break;
+        }
+}