Iniversity work

Dependencies:   mbed MMA8452

Files at this revision

API Documentation at this revision

Comitter:
vinceP
Date:
Sun Sep 03 18:39:10 2017 +0000
Parent:
2:8d0e48d38611
Commit message:
Mise a niveau du code

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 8d0e48d38611 -r 7db4d7f82176 main.cpp
--- a/main.cpp	Sat Sep 02 20:02:17 2017 +0000
+++ b/main.cpp	Sun Sep 03 18:39:10 2017 +0000
@@ -16,11 +16,17 @@
 int main() {
    int number = 10;
    char c[50];
+   int x  = 0,y = 0,z = 0;
    while(1) {
       sprintf(c,"%f", number);
       pc.printf("x:%c \r\n",c[0]);
       pc.printf("x:%s \r\n",c);
-      //calculateAngle();
+      //Code de la librairie
+      //Sort les valeur en int
+      //acc.readXYZCounts(&x,&y,&z); //<-- to use
+      //sort les valeur en double (c'est l'accélération
+      //acc.readXYZGravity(&x,&y,&z);
+      //calculateAngle(x,y,z);
       wait(1);
       number--;
    }
@@ -28,9 +34,9 @@
 
 void calculateAngle(int x,int y, int z){
     //double x, y, z;
-    float val = 180.0 / 3.1416;
+    float val = 0.5 * 180.0 / 3.1416;
     double calcule = (1-2*((x*x+y*y)/(x*x+y*y+z*z)));
-    //acc.readXYZGravity(&x,&y,&z);
+    //;
     /*x = -0.016;
     y = -0.877;
     z = 0.499;*/
@@ -41,10 +47,11 @@
     //float crossProductVector = sqrt(x*x+y*y);
     //float t = -1*asin(crossProductVector/amplitude)*val; //was z before
     //float e = 0.5*acos(1-2*((pow(x,2)+pow(y,2))/((pow(x,2)+pow(y,2)+pow(z,2)))))*val;
-    float e2 = 0.5*acos(calcule)*val;
+    float e2 = acos(calcule)*val;
     pc.printf("x:%lf   y:%lf z:%lf\r\n",x,y,z);
     pc.printf("angle: %lf\r\n",e2);
 }
+//possibilité de changement du type de valeur en paramêtre
 void display(int number){
     char c[6];
     //Explication de la fonction sprintf https://www.tutorialspoint.com/c_standard_library/c_function_sprintf.htm