Laboratory

Dependencies:   mbed BufferedSerial MMA8491 TSI MAG3110

Files at this revision

API Documentation at this revision

Comitter:
abm_mechatronika
Date:
Wed Feb 13 13:50:09 2019 +0000
Parent:
0:79cb20d1d3d4
Commit message:
Po konsultacji z promotorem

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 79cb20d1d3d4 -r 3bdde2447358 main.cpp
--- a/main.cpp	Fri Feb 08 12:09:11 2019 +0000
+++ b/main.cpp	Wed Feb 13 13:50:09 2019 +0000
@@ -32,7 +32,7 @@
 
 //Komunikacja
 BufferedSerial pc(USBTX,USBRX);
-BufferedSerial device(PTE22,PTE23); //TX, RX
+BufferedSerial device_zadajnik(PTE22,PTE23); //TX, RX
 char buffer[24];
 
 void calXY();
@@ -41,7 +41,7 @@
 int main()
 {
     pc.baud(115200);
-    device.baud(115200);
+    device_zadajnik.baud(115200);
     
     MMA8491 acc(I2C_SDA, I2C_SCL, PTA13);
 
@@ -56,12 +56,13 @@
     while (1) {
         wait(0.04);
         float data[3];
-        int xVal = mag.readVal(MAG_OUT_X_MSB);
-        int yVal = mag.readVal(MAG_OUT_Y_MSB);
-        float kierunek = mag.getHeading();
+        //int xVal = mag.readVal(MAG_OUT_X_MSB);
+        //int yVal = mag.readVal(MAG_OUT_Y_MSB);
+        float kierunek = mag.getHeading();  //kąt obrotu płytki XTRINSIC-SENSORS Board wzgledem osi północ-poludnie
         
+        //odczyt przyspieszen
         acc.acquire_MMA8491_data_g(data);
-        redLed = 1.0 - abs((long)data[0]);
+        redLed = 1.0 - abs((long)data[0]);  //sygnalizacja kierunku
         greenLed = 1.0 - abs((long)data[1]);
         blueLed = 1.0 - abs((long)data[2]);
         
@@ -70,17 +71,17 @@
             blueLed = ON;
         } else blueLed = OFF;*/
         
-        if (kierunek < 0) kierunek += 360.0;
+        // (kierunek < 0) kierunek += 360.0;    //?
         
         float x=(float)data[0];
         float y=(float)data[1];
         float z=(float)data[2];
 
         //pc.printf("%.2f %.2f %f\n\r",arc_tan_2(x,z),arc_tan_2(y,z), kierunek);
-        //device.printf("%.2f %.2f %.2f",data[0], data[1], data[2]);
-        //device.printf("%.2f %.2f %f\n\r",data[0], data[1], kierunek);
+        //device_zadajnik.printf("%.2f %.2f %.2f",data[0], data[1], data[2]);
+        //device_zadajnik.printf("%.2f %.2f %f\n\r",data[0], data[1], kierunek);
         sprintf((char*)buffer,"%.2f %.2f %f\n\r",arc_tan_2(x,z),arc_tan_2(y,z), kierunek);
-        device.printf(buffer);
+        device_zadajnik.printf(buffer); //ewentualnie "pc.printf(buffer);"
         //wait(0.2);
     }//koniec while()
 }//koniec main()