demo project

Dependencies:   AX-12A Dynamixel mbed iothub_client EthernetInterface NTPClient ConfigFile SDFileSystem iothub_amqp_transport mbed-rtos proton-c-mbed wolfSSL

Revision:
18:224289104fc0
Parent:
13:ffeff9b5e513
Child:
19:2f0ec9ac1238
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Utils/ControllerIo.cpp	Sat Jan 23 00:08:30 2016 +0000
@@ -0,0 +1,68 @@
+#include "mbed.h"
+#include "rtos.h"
+
+DigitalOut greenLed(LED_GREEN);
+DigitalOut redLed(LED_RED);
+DigitalOut blueLed(LED_BLUE);
+
+DigitalOut buzzer(D2, 1);
+
+
+int BuzzStopMs = 0;
+
+void ShowLedColor(int col)
+{
+    greenLed = 1;
+    redLed = 1;
+    blueLed = 1;
+    
+    if (col == 1)
+        greenLed = 0;
+    else if (col == 2)
+        redLed = 0;
+    else if (col == 3)
+        blueLed = 0;
+}
+
+void ShowLedGreen()
+{
+    ShowLedColor(1);
+}
+
+void ShowLedRed()
+{
+    ShowLedColor(2);
+}
+
+void ShowLedBlue()
+{
+    ShowLedColor(3);
+}
+
+void BuzzerStart()
+{
+    buzzer = 0;
+}
+
+void BuzzerStop()
+{
+    buzzer = 1;
+}
+
+void BuzzerStartMs(int nowMs, int durationMs)
+{
+    BuzzStopMs = nowMs + durationMs;
+    BuzzerStart();
+}
+
+void BuzzerPoll(int nowMs)
+{
+    if (BuzzStopMs != 0)
+    {
+        if (nowMs >= BuzzStopMs)
+        {
+            BuzzStopMs = 0;
+            BuzzerStop();
+        }
+    }
+}