Modified getOffset for calibrating Thermal Drift coefficients.
Fork of ITG3200 by
Modified to make getOffset() function easier to use.
Diff: ITG3200.h
- Revision:
- 7:43b936a53b64
- Parent:
- 6:a7ad6046824c
- Child:
- 8:ac0365ab3cef
--- a/ITG3200.h Thu Sep 13 14:36:13 2012 +0000 +++ b/ITG3200.h Sat Sep 29 14:34:17 2012 +0000 @@ -103,8 +103,9 @@ * * @param sda - mbed pin to use for the SDA I2C line. * @param scl - mbed pin to use for the SCL I2C line. + * @param fastmode Sets the internal I2C interface to use 400kHz clock. */ - ITG3200(PinName sda, PinName scl); + ITG3200(PinName sda, PinName scl, bool fastmode = false); /** * Get the identity of the device. @@ -284,8 +285,9 @@ * Typical sensitivity is 14.375 LSB/(degrees/sec). * * @param readings The output buffer array that has at least 3 length. + * @param subtractOffset Make the returned values subtracted of zero offset. */ - void getGyroXYZ(int readings[3]); + void getGyroXYZ(int readings[3], bool subtractOffset = true); /** * Burst read the outputs on the x,y,z-axis gyroscope and convert them into degrees per second. @@ -298,8 +300,9 @@ * Burst read the outputs on the x,y,z-axis gyroscope and convert them into degrees per second. * * @param readings The output buffer array that has at least 3 length. + * @param subtractOffset Make the returned values subtracted of zero offset. */ - void getGyroXYZRadians(double readings[3]); + void getGyroXYZRadians(double readings[3], bool subtractOffset = true); /** * Get the power management configuration. @@ -396,6 +399,20 @@ return calibSamples; } + /** + * Returns the I2C object that this object is using for communication. + */ + I2C &getI2C(){ + return i2c_; + } + + /** + * Returns internal offset values for zero adjusting. Returned pointer is pointing an array of 3 elements. + */ + const int *getOffset()const{ + return offset; + } + protected: /** @@ -426,7 +443,7 @@ int offset[3]; long calibSamples; - + private: I2C i2c_; @@ -450,10 +467,12 @@ }; -inline void ITG3200::getGyroXYZ(int readings[3]){ +inline void ITG3200::getGyroXYZ(int readings[3], bool subtractOffset){ getRawGyroXYZ(readings); - for(int i = 0; i < 3; i++) - readings[i] -= offset[i]; + if(subtractOffset){ + for(int i = 0; i < 3; i++) + readings[i] -= offset[i]; + } } inline void ITG3200::getGyroXYZDegrees(double readings[3]){ @@ -463,9 +482,9 @@ readings[i] = intData[i] * 2000. / 32767.; } -inline void ITG3200::getGyroXYZRadians(double readings[3]){ +inline void ITG3200::getGyroXYZRadians(double readings[3], bool subtractOffset){ int intData[3]; - getGyroXYZ(intData); + getGyroXYZ(intData, subtractOffset); for(int i = 0; i < 3; i++) readings[i] = intData[i] * 2000. / 32767. * 2. * M_PI / 360.; }