Samples acceleration at 100 Hz for 10 seconds. At the end of the 10 seconds, turns on: - LED1 if the board stayed horizontal for most time - LED2 if the board stayed on the long edge for most time - LED3 if the board stayed on the short edge for most time

Dependencies:   BSP_B-L475E-IOT01

Revision:
2:52e9bb32964b
Parent:
1:164c6bd28b13
--- a/main.cpp	Thu Dec 06 16:18:47 2018 +0000
+++ b/main.cpp	Thu Dec 06 16:36:32 2018 +0000
@@ -57,26 +57,26 @@
     led3 = led3_status;
 }
 
-bool is_board_horizontal() {
+bool is_board_horizontal(int16_t pDataXYZ[3]) {
     return (pDataXYZ[2] < 1030 && pDataXYZ[2] > 950) || (pDataXYZ[2] < -950 && pDataXYZ[2] > -1030);
 }
 
-bool is_board_vertical_short() {
+bool is_board_vertical_short(int16_t pDataXYZ[3]) {
     return (pDataXYZ[0] < -950  && pDataXYZ[0] > -1030) || (pDataXYZ[0] < 1030 && pDataXYZ[0] > 950);
 }
 
-bool is_board_vertical_long() {
+bool is_board_vertical_long(int16_t pDataXYZ[3]) {
     return (pDataXYZ[1] < 1030 && pDataXYZ[1] > 950) || (pDataXYZ[1] < -950 && pDataXYZ[1] > -1030);
 }
 
 void write_positions_on_file() {
     int16_t pDataXYZ[3] = {0};
     BSP_ACCELERO_AccGetXYZ(pDataXYZ);
-    if (is_board_vertical_short()) {
+    if (is_board_vertical_short(pDataXYZ)) {
             fprintf(f, "%d\n", 0);
-        } else if (is_board_vertical_long()) {
+        } else if (is_board_vertical_long(pDataXYZ)) {
             fprintf(f, "%d\n", 1);
-        } else if (is_board_horizontal()) {
+        } else if (is_board_horizontal(pDataXYZ)) {
              fprintf(f, "%d\n", 2);
         } else {
              fprintf(f, "%d\n", -1);
@@ -115,7 +115,7 @@
             toggle_led(0,0,1);
         }
       
-      printf("Press the restart button to sample again.");
+      printf("Press the restart button to sample again.\n");
       fflush(stdout);
       int err = fclose(f);
       printf("%s\n", (err < 0 ? "Fail :(" : "OK"));