sfas
Dependents: Bracky-MPU6050-DMP
Fork of MPU6050 by
Diff: MyMPU6050.h
- Revision:
- 10:6167cc7e7d60
- Parent:
- 9:ac76b5b24b18
- Child:
- 11:feab67f916fe
diff -r ac76b5b24b18 -r 6167cc7e7d60 MyMPU6050.h --- a/MyMPU6050.h Sat Dec 05 00:40:23 2015 +0000 +++ b/MyMPU6050.h Sat Dec 05 09:04:10 2015 +0000 @@ -25,7 +25,9 @@ void loop() { // if programming failed, don't try to do anything if (!dmpReady) return; - + +// _pc->printf("dmp ready\n"); + // wait for MPU interrupt or extra packet(s) available if (!mpuInterrupt && fifoCount < packetSize) { return; @@ -40,7 +42,9 @@ // . // . } - + +// _pc->printf("mpu interrupt \n"); + // reset interrupt flag and get INT_STATUS byte mpuInterrupt = false; mpuIntStatus = mpu.getIntStatus(); @@ -80,12 +84,13 @@ float newDTheta = gyroData[2]/180.0*M_PI; if (!thetaInitFlag && abs(newTheta-theta)>0.3) { - _pc->printf("IMU interrupt clash\n"); +// _pc->printf("IMU interrupt clash\n"); mpu.resetFIFO(); } else { thetaInitFlag = false; theta = newTheta; dtheta = newDTheta; +// _pc->printf("loop %f\n", theta); } @@ -98,6 +103,7 @@ } float getTheta(){ +// _pc->printf("%f\n", theta); return theta; } @@ -111,9 +117,18 @@ checkpin.rise(NULL); } + void disableInterrupt(){ + mpuInterrupt = false; + checkpin.rise(NULL); + } + void enable(){ setup(); } + + void enableInterrupt(){ + checkpin.rise(this, &MyMPU6050::dmpDataReady); + } private: @@ -133,9 +148,9 @@ VectorFloat gravity; // [x, y, z] gravity vector float ypr[3]; // [yaw, pitch, roll] yaw/pitch/roll container and gravity vector int16_t gyroData[3]; - float theta; + volatile float theta; bool thetaInitFlag; - float dtheta; + volatile float dtheta; InterruptIn checkpin; volatile bool mpuInterrupt;