Added for gyro and testing

Revision:
10:bd9665d14241
Parent:
9:898effccce30
Child:
11:9b414412b09e
--- a/MPU6050.h	Thu Feb 19 00:15:52 2015 +0000
+++ b/MPU6050.h	Thu Feb 19 23:56:16 2015 +0000
@@ -73,19 +73,18 @@
 #define MPU6050_GYRO_RANGE_1000     2
 #define MPU6050_GYRO_RANGE_2000     3
 
-
-#define MPU6050_RA_INT_ENABLE 0x38  //interrupt address
-
+//interrupt address
+#define MPU6050_RA_INT_ENABLE 0x38  
 //define how the accelerometer is placed on surface
 #define X_AXIS 1
 #define Y_AXIS 2
 #define Z_AXIS 0
-
+//translation from radians to degrees
 #define RADIANS_TO_DEGREES 180/3.1415926536
-
+//constant used for the complementary filter, which ranges usually from 0.9 to 1.0
 #define ALPHA 0.96   //filter constant
-
-#define GYRO_SCALE 2.7176 //scale the gyro
+//scale the gyro
+#define GYRO_SCALE 2.7176 
 
 /** MPU6050 IMU library.
   *
@@ -270,12 +269,31 @@
      */
      void read( char adress, char *data, int length);
      
-    //added aditional functions
+    //function for calculating the angle from the accelerometer.
+    //it takes 3 values which correspond acceleration in X, Y and Z direction and calculates angles in degrees
+    //for pitch, roll and one more direction.. (NOT YAW!)
      void getAcceleroAngle( float *data );
+     
+     
+     //function which allows to produce the offset values for gyro and accelerometer.
+     //offset for gyro is simply a value, which needs to be substracted from original gyro rad/sec speed
+     //but offset for accelerometer is calculated in angles... later on might change that
+     //function simply takes the number of samples to be taken and calculated the average
      void getOffset(float *accOffset, float *gyroOffset, int sampleSize);
+     
+     //function for computing the angle, when accelerometer angle offset and gyro offset are both known.
+     //we also need to know how much time passed from previous calculation to now
+     //it produces the angle in degrees. However angles are produced from -90.0 to 90.0 degrees
+     //if anyone need smth different, they can update this library...
      void computeAngle (float *angle, float *accOffset, float *gyroOffset, float *currTime, float *prevTime);
+     
+     //function, which enables interrupts on MPU6050 INT pin
      void enableInt( void );
+     
+     //disables interrupts
      void disableInt( void );
+     
+     //function which sets the alpha value - constant for the complementary filter. default alpha = 0.97
      void setAlpha(float val);
      
      private:
@@ -283,9 +301,8 @@
      I2C connection;
      char currentAcceleroRange;
      char currentGyroRange;
-     float alpha;
+     float alpha;   
      
-
 };