template for jeff
Dependencies: mbed MPU6050_template ledControl2 USBDevice
Diff: main.cpp
- Revision:
- 8:7b491d7b6d9d
- Parent:
- 7:3e1e78b34e1a
- Child:
- 10:72bbd203b210
diff -r 3e1e78b34e1a -r 7b491d7b6d9d main.cpp --- a/main.cpp Wed Aug 05 13:15:31 2015 +0000 +++ b/main.cpp Wed Oct 21 08:22:49 2020 +0000 @@ -57,13 +57,22 @@ #include "MPU6050.h" #include "ledControl.h" +//! Variable debug +#define DEBUG /* */ /* Defined in the MPU6050.cpp file */ // I2C i2c(p9,p10); // setup i2c (SDA,SCL) +//! Instance pc de classe Serial Serial pc(USBTX,USBRX); // default baud rate: 9600 +//! Instance mpu6050 de classe MPU6050 MPU6050 mpu6050; // class: MPU6050, object: mpu6050 +//! instance toggler1 de classe Ticker +//! instance filer de classe Ticker +// Ticker +// A Ticker is used to call a function at a recurring interval. +// You can use as many separate Ticker objects as you require. Ticker toggler1; Ticker filter; @@ -92,15 +101,19 @@ /* Uncomment below if you want to see accel and gyro data */ -// pc.printf(" _____________________________________________________________ \r\n"); -// pc.printf("| Accelerometer(g) | ax=%.3f | ay=%.3f | az=%.3f \r\n",ax,ay,az); -// pc.printf("| Gyroscope(deg/s) | gx=%.3f | gy=%.3f | gz=%.3f \r\n",gx,gy,gz); -// pc.printf("|_____________________________________________________________ \r\n\r\n"); + pc.printf(" _____________________________________________________________ \r\n"); + pc.printf("| Accelerometer(g) | ax=%.3f | ay=%.3f | az=%.3f \r\n",ax,ay,az); + pc.printf("| Gyroscope(deg/s) | gx=%.3f | gy=%.3f | gz=%.3f \r\n",gx,gy,gz); + pc.printf("|_____________________________________________________________ \r\n\r\n"); // -// wait(2.5); + wait(2.5); - filter.attach(&compFilter, 0.005); // Call the complementaryFilter func. every 5 ms (200 Hz sampling period) + //filter.attach(&compFilter, 0.005); // Call the complementaryFilter func. every 5 ms (200 Hz sampling period) + #ifdef DEBUG + pc.printf(" [Debug On] \r\n"); + mpu6050.complementaryFilter(&pitchAngle, &rollAngle); + #endif pc.printf(" _______________\r\n"); pc.printf("| Pitch: %.3f \r\n",pitchAngle); pc.printf("| Roll: %.3f \r\n",rollAngle);