wooooo

Dependencies:   GYRO_DISCO_L476VG mbed BSP_DISCO_L476VG COMPASS_DISCO_L476VG

Files at this revision

API Documentation at this revision

Comitter:
Leonnn
Date:
Fri Jun 12 13:48:55 2020 +0000
Parent:
7:4d02d2486949
Commit message:
LA FUSION :O

Changed in this revision

COMPASS_DISCO_L476VG.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 4d02d2486949 -r 97589b322a4f COMPASS_DISCO_L476VG.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/COMPASS_DISCO_L476VG.lib	Fri Jun 12 13:48:55 2020 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ST/code/COMPASS_DISCO_L476VG/#6508fa5521e0
diff -r 4d02d2486949 -r 97589b322a4f main.cpp
--- a/main.cpp	Fri Jun 12 12:49:53 2020 +0000
+++ b/main.cpp	Fri Jun 12 13:48:55 2020 +0000
@@ -1,39 +1,48 @@
 #include "mbed.h"
 #include "GYRO_DISCO_L476VG.h"
+#include "COMPASS_DISCO_L476VG.h"
+#define PI 3.14159265358979323846
 
+COMPASS_DISCO_L476VG compass;
 GYRO_DISCO_L476VG gyro;
+
 Serial pc(SERIAL_TX, SERIAL_RX);
 Ticker tick_mesure;
 
 volatile bool flag_mesure = 0;
 
-void mesure(void){flag_mesure = 1;}
+void mesure(void){flag_mesure = 1;}//   ISR mesure
 
 int main()
 {
     float GyroBuffer[3], offset, GyrY;
     offset = 0;
     wait(0.5);
-    for(int i=0; i<100; i++){
+    for(int i=0; i<100; i++){//     séquence de mise à 0
         gyro.GetXYZ(GyroBuffer);
         offset = offset + GyroBuffer[1];
         wait(0.01);
     }
-    offset = offset/100;
+    offset = offset/100;//-----------------fin mise à 0
     
     tick_mesure.attach(&mesure, 0.01);
     pc.baud(115200);
-    float angle = 0;
-    unsigned int count = 0;
+    
+    unsigned int count = 0;   
+    float Gyr_angle = 0;
+    float Acc_angle;
+    int16_t AccBuffer[3];
   
     while(1) {  
-        if(flag_mesure){
+        if(flag_mesure){//  mesure Gyro
             gyro.GetXYZ(GyroBuffer);
             GyrY = GyroBuffer[1]-offset;
-            angle = angle + GyrY/100;
+            Gyr_angle = Gyr_angle + GyrY/100;
+            Acc_angle = atan2((float)AccBuffer[0], (float)AccBuffer[2])*180.0/PI;
             
             if(count > 9){
-                pc.printf("$%f %f;", offset/1000, angle/1000);
+                compass.AccGetXYZ(AccBuffer);       
+                pc.printf("$%f %f;", Acc_angle, Gyr_angle/1000);
                 count = 0;
             }
             else
diff -r 4d02d2486949 -r 97589b322a4f mbed-os.lib
--- a/mbed-os.lib	Fri Jun 12 12:49:53 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://github.com/ARMmbed/mbed-os/#b81aeff1a3e171c6421984faa2cc18d0e35746c0
diff -r 4d02d2486949 -r 97589b322a4f mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Jun 12 13:48:55 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file