demo project

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

Revision:
13:ffeff9b5e513
Parent:
10:9b21566a5ddb
--- a/ControllerIo.cpp	Thu Jan 07 17:31:23 2016 +0000
+++ b/ControllerIo.cpp	Fri Jan 15 22:02:46 2016 +0000
@@ -5,6 +5,10 @@
 DigitalOut redLed(LED_RED);
 DigitalOut blueLed(LED_BLUE);
 
+DigitalOut buzzer(D2, 1);
+
+
+int BuzzStopMs = 0;
 
 void ShowLedColor(int col)
 {
@@ -29,7 +33,36 @@
 {
     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();
+        }
+    }
+}