mix code vision 3. Using the previous algorithm to detect peaks as Nikoleta and Shiyao. Adding overlapping windows

Dependencies:   mpu9250_i2c biquadFilter peakdetection Eigen

Committer:
castlefei
Date:
Wed Nov 06 12:36:55 2019 +0000
Revision:
0:44701eab0261
Child:
1:92f42e198925
my test to read date from MPU9250

Who changed what in which revision?

UserRevisionLine numberNew contents of line
castlefei 0:44701eab0261 1 /*
castlefei 0:44701eab0261 2 * reading and print acc and gyro date from MPU9250
castlefei 0:44701eab0261 3 * in terminal:
castlefei 0:44701eab0261 4 * ls /dev/tty.*
castlefei 0:44701eab0261 5 * screen /dev/tty.usbmodem14102 9600
castlefei 0:44701eab0261 6 *
castlefei 0:44701eab0261 7 * mbed Microcontroller Library
castlefei 0:44701eab0261 8 * Copyright (c) 2018 ARM Limited
castlefei 0:44701eab0261 9 * SPDX-License-Identifier: Apache-2.0
castlefei 0:44701eab0261 10 */
castlefei 0:44701eab0261 11
castlefei 0:44701eab0261 12 #include "mbed.h"
castlefei 0:44701eab0261 13 #include "platform/mbed_thread.h"
castlefei 0:44701eab0261 14 #include "stats_report.h"
castlefei 0:44701eab0261 15 #include "MPU9250.h"
castlefei 0:44701eab0261 16
castlefei 0:44701eab0261 17 DigitalOut led1(LED1);
castlefei 0:44701eab0261 18 const int addr7bit = 0x68; // 7bit I2C address,AD0 is 0
castlefei 0:44701eab0261 19
castlefei 0:44701eab0261 20 #define SLEEP_TIME 1000 // (msec)
castlefei 0:44701eab0261 21
castlefei 0:44701eab0261 22 // main() runs in its own thread in the OS
castlefei 0:44701eab0261 23 int main()
castlefei 0:44701eab0261 24 {
castlefei 0:44701eab0261 25 //new mpu(data,clk,address),in constructor addr7bit<<1
castlefei 0:44701eab0261 26 mpu9250 *mpu = new mpu9250(p26,p27,addr7bit);
castlefei 0:44701eab0261 27 //scale of acc and gyro
castlefei 0:44701eab0261 28 mpu->initMPU9250(0x00,0x00);
castlefei 0:44701eab0261 29
castlefei 0:44701eab0261 30 float AccRead[3];
castlefei 0:44701eab0261 31 float GyroRead[3];
castlefei 0:44701eab0261 32 float TempRead[1];
castlefei 0:44701eab0261 33
castlefei 0:44701eab0261 34 while (true) {
castlefei 0:44701eab0261 35
castlefei 0:44701eab0261 36 //Blink LED and wait 1 seconds
castlefei 0:44701eab0261 37 led1 = !led1;
castlefei 0:44701eab0261 38 thread_sleep_for(SLEEP_TIME);
castlefei 0:44701eab0261 39 //read and convert date
castlefei 0:44701eab0261 40 mpu->ReadConvertAll(AccRead,GyroRead,TempRead);
castlefei 0:44701eab0261 41 printf("acc value is (%f,%f,%f).\n\r",AccRead[0],AccRead[1],AccRead[2]);
castlefei 0:44701eab0261 42 printf("gyro value is (%f,%f,%f).\n\r",GyroRead[0],GyroRead[1],GyroRead[2]);
castlefei 0:44701eab0261 43 printf("temp value is %f.\n\r",TempRead[0]);
castlefei 0:44701eab0261 44
castlefei 0:44701eab0261 45 }
castlefei 0:44701eab0261 46 }