Dist Sensor Test

Dependencies:   BertlLib mbed

Fork of BertlTemplate2 by michael hollegha

Files at this revision

API Documentation at this revision

Comitter:
hollegha2
Date:
Mon Apr 18 16:30:58 2016 +0000
Parent:
2:d24a3d2438a4
Commit message:
V1.0

Changed in this revision

BertlTemplate.cpp Show diff for this revision Revisions of this file
DistSensTest.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/BertlTemplate.cpp	Mon Feb 22 10:55:46 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-
-#include "mbed.h"
-#include "Serial_HL.h"
-#include "Bertl14.h"
-#include "BertlObjects.h"
-
-//              main=2^0  LS    ENC 2^2
-BusOut boardPow(p30,      P1_6, P1_7);
-
-int main(void)
-{
-    boardPow=1; wait_ms(10);
-    InitBertl();
-    pex.useISR=0; leds=9;
-    pex.ClearLeds();
-    
-    while(1)
-    {
-    }
-    
-    return 1;
-}
-
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DistSensTest.cpp	Mon Apr 18 16:30:58 2016 +0000
@@ -0,0 +1,49 @@
+#include "mbed.h"
+#include "Serial_HL.h"
+#include "Bertl14.h"
+#include "BertlObjects.h"
+
+SerialBLK pc(USBTX, USBRX);
+SvProtocol ua0(&pc);
+
+void CommandHandler();
+
+//              main=2^0  LS    ENC 2^2
+BusOut boardPow(p30,      P1_6, P1_7);
+
+int main(void)
+{
+    boardPow=1;
+    pc.format(8,SerialBLK::None,1);
+    pc.baud(115200);
+    InitBertl();
+    pex.useISR=0;
+    leds=9;
+    wait(1.0);
+    leds=6;
+
+    ua0.SvMessage("DistSensTest_4");
+
+    Timer stw;
+    stw.start();
+    while(1) {
+        CommandHandler();
+        if( ua0.acqON && (stw.read_ms()>10) ) {
+            stw.reset();
+            if( ua0.acqON ) {
+                us.StartMeas(); // for next cycle
+                ua0.WriteSvI16(1, us.distCM*100.0);
+            }
+        }
+    }
+    return 1;
+}
+
+void CommandHandler()
+{
+    uint8_t cmd;
+    if( !pc.IsDataAvail() )
+        return;
+    cmd = ua0.GetCommand();
+}
+