Sensor Data - first assignment CO838

Dependencies:   mbed C12832 FXOS8700Q LM75B eCompass_FPU_Lib

Sensor Data - Project developed by Jean-Paul Saysana (jls44)

First assignment for the Internet of Things and Mobile Devices CO838 module

University of Kent (2016-2017)

Functionalities:

- Temperature Sensor

- Compass

- Music box

- Potentiometer that changes LED colours

Libraries used: C12832, eCompass_FPU_Lib, FXOS8700Q, LM75B

Revision:
0:4b83b332b327
diff -r 000000000000 -r 4b83b332b327 src/LED.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/LED.cpp	Fri Feb 24 11:25:05 2017 +0000
@@ -0,0 +1,40 @@
+/* Developed by Jean-Paul Saysana - jls44 - MSc Student in Computer Security*/
+/* Internet of Things and Mobile Devices - CO838 University of Kent*/
+
+#include "LED.h"
+
+LED::LED(PinName R, PinName G, PinName B) : red(R), green(G), blue(B) {
+}
+
+/* switch on selected color of led and turn off the rest. */
+void LED::SwitchOn(eLED color) {
+    switch (color) {
+      case RED:
+        red = 1;
+        SwitchOff(blue);
+        SwitchOff(green);
+        break;
+      case BLUE:
+        blue = 1;
+        SwitchOff(red);
+        SwitchOff(green);
+        break;
+      case GREEN:
+        green = 1;
+        SwitchOff(blue);
+        SwitchOff(red);
+        break;
+    };
+}
+
+/* switch off selected led */
+void LED::SwitchOff(DigitalOut p) {
+    p = 0;
+}
+
+/* switch off every led (white) */
+void LED::SwitchOffAll() {
+    red = 0;
+    green =0;
+    blue = 0;
+}