Algoritmo funcionando com a biblioteca de inatividade utilizando dos dados do acelerômetro e a biblioteca de PeakSearch se utilizando dos dados filtrados pelo filtro Kalman.
Dependencies: mbed MatrixMath Matrix nrf51_rtc BMP180 MPU9250
Diff: main.cpp
- Revision:
- 1:d1002dc109b9
- Parent:
- 0:095b19b8fb7e
- Child:
- 2:5d0d7997e461
diff -r 095b19b8fb7e -r d1002dc109b9 main.cpp --- a/main.cpp Thu Mar 07 23:30:19 2019 +0000 +++ b/main.cpp Sat Mar 09 12:06:30 2019 +0000 @@ -35,7 +35,7 @@ char day1[10],day2[10]; //Store the day, to check if the day changed int frame=0; //store the frames int BaudRate=115200; //OpenLog's BaudRate -float TimeInterrupt=20000; //Interruption time in [us] 1/20000[us] =50[Hz] +float TimeInterrupt=50000; //Interruption time in [us] 1/20000[us] =50[Hz] float t1,t2; //time values double aa, ta; //altimeter and temperature values double ti; // temperature values - IMU @@ -81,6 +81,7 @@ if (!flagNewCapture) { + Open.printf("Get_Values \r\n"); ////////////////////////////Getting MPU Values///////////////////////// mpu9250.readAccelData(accelCount); // Read the x/y/z adc values @@ -213,41 +214,43 @@ mpu9250.MahonyQuaternionUpdate(ax, ay, az, gx, gy, gz, my, mx, mz); aa=Sensor1.Altitude_m(); ta=Sensor1.Temp_C(); - //////////////////////////// Is there a new step? ////////////////// SubDTW(); - - if (flagStep==true) - { - if (flagPrint==true) - { - ////////////////////////////Printing Values///////////////////////// - ask_time(buff); - //sprintf(buff_Values,"%2.4f,%2.4f,%2.4f,%2.4f,%2.4f,%2.4f,%2.4f,%2.4f,%2.4f,%2.2f,%2.0f,%2.0f,%d\r\n",ax, ay, az, gx, gy, gz, mx, my, mz, aa, ta, ti, frame); - sprintf(buff_Values,"Steps %d \r\n",steps); - strcat(buff,buff_Values); + - ///////////////////////////////Cheking if the day changed///////////////////////////////////// - ask_day(day2); - if (strcmp (day2,day1) != 0) //compare todays day with the day that the file was created - { - new_file(); //cria novo arquivo - ask_day(day1); - } // end if - ////////////////////////////////////////////////////////////////////////////////////////////// + + if (flagPrint==true) + { + ////////////////////////////Printing Values///////////////////////// + ask_time(buff); + //sprintf(buff_Values,"%2.4f,%2.4f,%2.4f,%2.4f,%2.4f,%2.4f,%2.4f,%2.4f,%2.4f,%2.2f,%2.0f,%2.0f,%d\r\n",ax, ay, az, gx, gy, gz, mx, my, mz, aa, ta, ti, frame); + sprintf(buff_Values,"Steps %d \r\n",steps); + strcat(buff,buff_Values); - Open.printf(buff); //Printing values on the SD card - flagNewCapture = false; - t2=t.read_us(); - if ((t2 - t1) < TimeInterrupt) - { - wait_us((TimeInterrupt) - (t2-t1)); - led=OFF; - }//end if time - led=ON; - flagPrint=false; - } //end if flag print - } //end if flag step + ///////////////////////////////Cheking if the day changed///////////////////////////////////// + ask_day(day2); + if (strcmp (day2,day1) != 0) //compare todays day with the day that the file was created + { + new_file(); //cria novo arquivo + ask_day(day1); + } // end if + ////////////////////////////////////////////////////////////////////////////////////////////// + if (flagStep==true) + { + Open.printf(buff); //Printing values on the SD card + } //end if flag step + + flagNewCapture = false; + t2=t.read_us(); + if ((t2 - t1) < TimeInterrupt) + { + wait_us((TimeInterrupt) - (t2-t1)); + led=OFF; + }//end if time + led=ON; + flagPrint=false; + } //end if flag print + else { flagPrint=true;