加速度・ジャイロセンサ―

Fork of MPU-6050 by SSSRC 2016s

Revision:
6:01dbbf760e1a
Parent:
5:15198869706e
Child:
7:ea53dc62603d
--- a/MPU6050.h	Sun May 15 06:25:57 2016 +0000
+++ b/MPU6050.h	Sun May 15 06:48:16 2016 +0000
@@ -3,16 +3,6 @@
 
 #include "mbed.h"
 
-// Using the GY-521 breakout board, I set ADO to 0 by grounding through a 4k7 resistor
-// Seven-bit device address is 110100 for ADO = 0 and 110101 for ADO = 1
-#define ADO 0
-#if ADO
-#define MPU6050_ADDRESS 0x69<<1  // Device address when ADO = 1
-#else
-#define MPU6050_ADDRESS 0x68<<1  // Device address when ADO = 0
-#endif
-
-float deltat = 0.0f;                              // integration interval for both filter schemes
 /** MPU6050
  *
  * 三軸加速度&ジャイロセンサー
@@ -49,6 +39,8 @@
     MPU6050( PinName i2c_sda, PinName i2c_scl, int ad0 = 0)
     : i2c_p( new I2C( i2c_sda, i2c_scl ) ), i2c( *i2c_p ) {
 
+        // Using the GY-521 breakout board, I set ADO to 0 by grounding through a 4k7 resistor
+        // Seven-bit device address is 110100 for ADO = 0 and 110101 for ADO = 1
         if(ad0) {
             adr = 0x69;
         } else {
@@ -63,6 +55,7 @@
         _q[1] = 0.0f;
         _q[2] = 0.0f;
         _q[3] = 0.0f;
+        deltat = 0.0f;
 
         // parameters for 6 DoF sensor fusion calculations
         float PI = 3.14159265358979323846f;
@@ -669,9 +662,9 @@
     int _Ascale;
 
     float _q[4]; // vector to hold quaternion
-
     float beta;
     float zeta;
+    float deltat;    // integration interval for both filter schemes
 
     //I2C
     I2C     *i2c_p;