Skip to content
Browse files

Adjust MPU6050::dmpGetLinearAccel() to use 8192 for 1g value, update …

…OFFSET register access methods
  • Loading branch information...
1 parent 30f6289 commit 63e04ba4030f04244dbc3417bca5fefd7778cd5e @jrowberg committed May 20, 2013
Showing with 38 additions and 38 deletions.
  1. +12 −12 Arduino/MPU6050/MPU6050.cpp
  2. +12 −12 Arduino/MPU6050/MPU6050.h
  3. +14 −14 Arduino/MPU6050/MPU6050_6Axis_MotionApps20.h
View
24 Arduino/MPU6050/MPU6050.cpp
@@ -2722,31 +2722,31 @@ uint8_t MPU6050::getOTPBankValid() {
void MPU6050::setOTPBankValid(bool enabled) {
I2Cdev::writeBit(devAddr, MPU6050_RA_XG_OFFS_TC, MPU6050_TC_OTP_BNK_VLD_BIT, enabled);
}
-int8_t MPU6050::getXGyroOffset() {
+int8_t MPU6050::getXGyroOffsetTC() {
I2Cdev::readBits(devAddr, MPU6050_RA_XG_OFFS_TC, MPU6050_TC_OFFSET_BIT, MPU6050_TC_OFFSET_LENGTH, buffer);
return buffer[0];
}
-void MPU6050::setXGyroOffset(int8_t offset) {
+void MPU6050::setXGyroOffsetTC(int8_t offset) {
I2Cdev::writeBits(devAddr, MPU6050_RA_XG_OFFS_TC, MPU6050_TC_OFFSET_BIT, MPU6050_TC_OFFSET_LENGTH, offset);
}
// YG_OFFS_TC register
-int8_t MPU6050::getYGyroOffset() {
+int8_t MPU6050::getYGyroOffsetTC() {
I2Cdev::readBits(devAddr, MPU6050_RA_YG_OFFS_TC, MPU6050_TC_OFFSET_BIT, MPU6050_TC_OFFSET_LENGTH, buffer);
return buffer[0];
}
-void MPU6050::setYGyroOffset(int8_t offset) {
+void MPU6050::setYGyroOffsetTC(int8_t offset) {
I2Cdev::writeBits(devAddr, MPU6050_RA_YG_OFFS_TC, MPU6050_TC_OFFSET_BIT, MPU6050_TC_OFFSET_LENGTH, offset);
}
// ZG_OFFS_TC register
-int8_t MPU6050::getZGyroOffset() {
+int8_t MPU6050::getZGyroOffsetTC() {
I2Cdev::readBits(devAddr, MPU6050_RA_ZG_OFFS_TC, MPU6050_TC_OFFSET_BIT, MPU6050_TC_OFFSET_LENGTH, buffer);
return buffer[0];
}
-void MPU6050::setZGyroOffset(int8_t offset) {
+void MPU6050::setZGyroOffsetTC(int8_t offset) {
I2Cdev::writeBits(devAddr, MPU6050_RA_ZG_OFFS_TC, MPU6050_TC_OFFSET_BIT, MPU6050_TC_OFFSET_LENGTH, offset);
}
@@ -2812,31 +2812,31 @@ void MPU6050::setZAccelOffset(int16_t offset) {
// XG_OFFS_USR* registers
-int16_t MPU6050::getXGyroOffsetUser() {
+int16_t MPU6050::getXGyroOffset() {
I2Cdev::readBytes(devAddr, MPU6050_RA_XG_OFFS_USRH, 2, buffer);
return (((int16_t)buffer[0]) << 8) | buffer[1];
}
-void MPU6050::setXGyroOffsetUser(int16_t offset) {
+void MPU6050::setXGyroOffset(int16_t offset) {
I2Cdev::writeWord(devAddr, MPU6050_RA_XG_OFFS_USRH, offset);
}
// YG_OFFS_USR* register
-int16_t MPU6050::getYGyroOffsetUser() {
+int16_t MPU6050::getYGyroOffset() {
I2Cdev::readBytes(devAddr, MPU6050_RA_YG_OFFS_USRH, 2, buffer);
return (((int16_t)buffer[0]) << 8) | buffer[1];
}
-void MPU6050::setYGyroOffsetUser(int16_t offset) {
+void MPU6050::setYGyroOffset(int16_t offset) {
I2Cdev::writeWord(devAddr, MPU6050_RA_YG_OFFS_USRH, offset);
}
// ZG_OFFS_USR* register
-int16_t MPU6050::getZGyroOffsetUser() {
+int16_t MPU6050::getZGyroOffset() {
I2Cdev::readBytes(devAddr, MPU6050_RA_ZG_OFFS_USRH, 2, buffer);
return (((int16_t)buffer[0]) << 8) | buffer[1];
}
-void MPU6050::setZGyroOffsetUser(int16_t offset) {
+void MPU6050::setZGyroOffset(int16_t offset) {
I2Cdev::writeWord(devAddr, MPU6050_RA_ZG_OFFS_USRH, offset);
}
View
24 Arduino/MPU6050/MPU6050.h
@@ -682,16 +682,16 @@ class MPU6050 {
// XG_OFFS_TC register
uint8_t getOTPBankValid();
void setOTPBankValid(bool enabled);
- int8_t getXGyroOffset();
- void setXGyroOffset(int8_t offset);
+ int8_t getXGyroOffsetTC();
+ void setXGyroOffsetTC(int8_t offset);
// YG_OFFS_TC register
- int8_t getYGyroOffset();
- void setYGyroOffset(int8_t offset);
+ int8_t getYGyroOffsetTC();
+ void setYGyroOffsetTC(int8_t offset);
// ZG_OFFS_TC register
- int8_t getZGyroOffset();
- void setZGyroOffset(int8_t offset);
+ int8_t getZGyroOffsetTC();
+ void setZGyroOffsetTC(int8_t offset);
// X_FINE_GAIN register
int8_t getXFineGain();
@@ -718,16 +718,16 @@ class MPU6050 {
void setZAccelOffset(int16_t offset);
// XG_OFFS_USR* registers
- int16_t getXGyroOffsetUser();
- void setXGyroOffsetUser(int16_t offset);
+ int16_t getXGyroOffset();
+ void setXGyroOffset(int16_t offset);
// YG_OFFS_USR* register
- int16_t getYGyroOffsetUser();
- void setYGyroOffsetUser(int16_t offset);
+ int16_t getYGyroOffset();
+ void setYGyroOffset(int16_t offset);
// ZG_OFFS_USR* register
- int16_t getZGyroOffsetUser();
- void setZGyroOffsetUser(int16_t offset);
+ int16_t getZGyroOffset();
+ void setZGyroOffset(int16_t offset);
// INT_ENABLE register (DMP functions)
bool getIntPLLReadyEnabled();
View
28 Arduino/MPU6050/MPU6050_6Axis_MotionApps20.h
@@ -1,6 +1,6 @@
// I2Cdev library collection - MPU6050 I2C device class, 6-axis MotionApps 2.0 implementation
// Based on InvenSense MPU-6050 register map document rev. 2.0, 5/19/2011 (RM-MPU-6000A-00)
-// 6/18/2012 by Jeff Rowberg <jeff@rowberg.net>
+// 5/20/2013 by Jeff Rowberg <jeff@rowberg.net>
// Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib
//
// Changelog:
@@ -313,10 +313,10 @@ uint8_t MPU6050::dmpInitialize() {
DEBUG_PRINTLN(otpValid ? F("valid!") : F("invalid!"));
// get X/Y/Z gyro offsets
- DEBUG_PRINTLN(F("Reading gyro offset values..."));
- int8_t xgOffset = getXGyroOffset();
- int8_t ygOffset = getYGyroOffset();
- int8_t zgOffset = getZGyroOffset();
+ DEBUG_PRINTLN(F("Reading gyro offset TC values..."));
+ int8_t xgOffsetTC = getXGyroOffsetTC();
+ int8_t ygOffsetTC = getYGyroOffsetTC();
+ int8_t zgOffsetTC = getZGyroOffsetTC();
DEBUG_PRINT(F("X gyro offset = "));
DEBUG_PRINTLN(xgOffset);
DEBUG_PRINT(F("Y gyro offset = "));
@@ -374,15 +374,15 @@ uint8_t MPU6050::dmpInitialize() {
DEBUG_PRINTLN(F("Clearing OTP Bank flag..."));
setOTPBankValid(false);
- DEBUG_PRINTLN(F("Setting X/Y/Z gyro offsets to previous values..."));
- setXGyroOffset(xgOffset);
- setYGyroOffset(ygOffset);
- setZGyroOffset(zgOffset);
+ DEBUG_PRINTLN(F("Setting X/Y/Z gyro offset TCs to previous values..."));
+ setXGyroOffsetTC(xgOffsetTC);
+ setYGyroOffsetTC(ygOffsetTC);
+ setZGyroOffsetTC(zgOffsetTC);
- DEBUG_PRINTLN(F("Setting X/Y/Z gyro user offsets to zero..."));
- setXGyroOffsetUser(0);
- setYGyroOffsetUser(0);
- setZGyroOffsetUser(0);
+ //DEBUG_PRINTLN(F("Setting X/Y/Z gyro user offsets to zero..."));
+ //setXGyroOffset(0);
+ //setYGyroOffset(0);
+ //setZGyroOffset(0);
DEBUG_PRINTLN(F("Writing final memory update 1/7 (function unknown)..."));
uint8_t dmpUpdate[16], j;
@@ -398,7 +398,7 @@ uint8_t MPU6050::dmpInitialize() {
resetFIFO();
DEBUG_PRINTLN(F("Reading FIFO count..."));
- uint8_t fifoCount = getFIFOCount();
+ uint16_t fifoCount = getFIFOCount();
uint8_t fifoBuffer[128];
DEBUG_PRINT(F("Current FIFO count="));

0 comments on commit 63e04ba

Please sign in to comment.
Something went wrong with that request. Please try again.