Configuring sensors dynamically using serial bus from the host computer.

Dependencies:   MAG3110 mbed

Files at this revision

API Documentation at this revision

Comitter:
mja054
Date:
Sat Feb 15 00:46:41 2014 +0000
Parent:
1:bc87a80a5d2b
Commit message:
Send the time delay

Changed in this revision

final_code.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r bc87a80a5d2b -r a422a41dbea1 final_code.cpp
--- a/final_code.cpp	Wed Feb 12 22:40:58 2014 +0000
+++ b/final_code.cpp	Sat Feb 15 00:46:41 2014 +0000
@@ -16,6 +16,7 @@
 DigitalOut green(LED1);
 DigitalOut red(LED2);
 Timer tt;
+Timer epoch;
 SLCD slcd;
 TSISensor tsi;
 
@@ -113,16 +114,14 @@
     }
 }
 
-
 int main()
 {
     float acce1, acce2, acce3, magma1, magma2, magma3, light, touch;
-    
     pc.baud(BAUD_RATE);
     pc.attach(read);
 
-    while(true) {
-    
+    epoch.start();
+    while(true) {    
         tt.reset();
         red = 1;
         green = 0;
@@ -132,13 +131,14 @@
         wait(0.2);
 
         tt.start();
+        float time_elapsed = epoch.read();
         int time = tt.read_ms();
         if (facc) {
             if (a == 0){
                  acce1 = acc.getAccX();
                  acce2 = acc.getAccY();
                  acce3 = acc.getAccZ();
-                 pc.printf("a=%f,%f,%f\n", acce1, acce2, acce3);
+                 pc.printf("a=%f,%f,%f,z%f\n", acce1, acce2, acce3, time_elapsed);
                  a = aval;
             } else
                 a--;
@@ -148,7 +148,7 @@
                 magma1 = mag.readVal(MAG_OUT_X_MSB);
                 magma2 = mag.readVal(MAG_OUT_Y_MSB);
                 magma3 = mag.readVal(MAG_OUT_Z_MSB);
-                pc.printf("m=%f,%f,%f\n", magma1, magma2, magma3);
+                pc.printf("m=%f,%f,%f,z%f\n", magma1, magma2, magma3, time_elapsed);
                 m =mval;
             } else
                 m--;
@@ -156,7 +156,7 @@
         if (flight) {
             if(l == 0){
                 light = lightSensor.read();
-                pc.printf("l=%f\n", light);
+                pc.printf("l=%f,z%f\n", light, time_elapsed);
                 l=lval;
             } else
                 l--;
@@ -164,7 +164,7 @@
         if (ftouch) {
             if (t == 0){
                 touch = tsi.readPercentage();
-                pc.printf("t=%f\n", touch);
+                pc.printf("t=%f,z%f\n", touch, time_elapsed);
                 t= tval;
             } else
                 t--;
@@ -177,4 +177,4 @@
         else
             wait((MAX_TIME-(time1-time))/1000.0);
     }
-}
+}
\ No newline at end of file