![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Header file and functions
Diff: MPU6050.h
- Revision:
- 11:9b414412b09e
- Parent:
- 10:bd9665d14241
--- a/MPU6050.h Thu Feb 19 23:56:16 2015 +0000 +++ b/MPU6050.h Fri Feb 20 00:13:01 2015 +0000 @@ -269,31 +269,54 @@ */ void read( char adress, char *data, int length); - //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 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!) + * + * @param data - angle calculated using only accelerometer + * + */ + 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 + /**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 + * + * @param accOffset - accelerometer offset in angle + * @param gyroOffset - gyroscope offset in rad/s + * @param sampleSize - number of samples to be taken for calculating offsets + * + */ 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 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... + * + * @param angle - calculated accurate angle from complemetary filter + * @param accOffset - offset in angle for the accelerometer + * @param gyroOffset - offset in rad/s for the gyroscope + * @param interval - time before previous angle calculation and now + * + */ + void computeAngle (float *angle, float *accOffset, float *gyroOffset, float interval); - //function, which enables interrupts on MPU6050 INT pin + ///function, which enables interrupts on MPU6050 INT pin void enableInt( void ); - //disables interrupts + ///disables interrupts void disableInt( void ); - //function which sets the alpha value - constant for the complementary filter. default alpha = 0.97 + /**function which sets the alpha value - constant for the complementary filter. default alpha = 0.97 + * + * @param val - value the alpha (complementary filter constant) should be set to + * + */ void setAlpha(float val); private: