Two simple classes for using the RGB led

Dependencies:   mbed

Dependents:   4180-lab3-RTOS 4180-FinalProject

Revision:
0:7a3ee33c0a53
Child:
1:0008e30a2bda
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SimpleRGB.cpp	Mon Oct 10 00:32:31 2016 +0000
@@ -0,0 +1,36 @@
+#include "SimpleRGB.h"
+
+
+// construct a LightColor object
+LightColor::LightColor(float r, float g, float b)
+    : red(r), green(g), blue(b)
+{
+}
+
+// construct an RGBLed object
+RGBLed::RGBLed(PinName rpin, PinName gpin, PinName bpin)
+    : _rpin(rpin), _gpin(gpin), _bpin(bpin)
+{
+    //50Hz PWM clock default a bit too low, go to 2000Hz (less flicker)
+    _rpin.period(0.0005);
+}
+
+// write directly to an RGBLed object
+void RGBLed::write(float red, float green, float blue) {
+    _rpin = red;
+    _gpin = green;
+    _bpin = blue;
+}
+
+// use a LightColor object to change the RGBLed
+void RGBLed::write(LightColor color) {
+    _rpin = color.red;
+    _gpin = color.green;
+    _bpin = color.blue;
+}
+
+// alow assingment of LightColor object to the RGBLed object
+RGBLed operator = (LightColor color) {
+    write(color);
+    return *this;
+}
\ No newline at end of file