Skip to content

Commit

Permalink
fixed 32 bit conversion error for accell and gyro
Browse files Browse the repository at this point in the history
  • Loading branch information
I-Connect authored Apr 30, 2020
1 parent c5d9682 commit 11d93f0
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion MPU6050.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,16 @@ Vector MPU6050::readRawAccel(void)
uint8_t zha = Wire.receive();
uint8_t zla = Wire.receive();
#endif


#ifdef ESP32
ra.XAxis = (int16_t)(xha << 8 | xla);
ra.YAxis = (int16_t)(yha << 8 | yla);
ra.ZAxis = (int16_t)(zha << 8 | zla);
#elif
ra.XAxis = xha << 8 | xla;
ra.YAxis = yha << 8 | yla;
ra.ZAxis = zha << 8 | zla;
#endif

return ra;
}
Expand Down Expand Up @@ -434,9 +440,15 @@ Vector MPU6050::readRawGyro(void)
uint8_t zla = Wire.receive();
#endif

#ifdef ESP32
rg.XAxis = (int16_t)(xha << 8 | xla);
rg.YAxis = (int16_t)(yha << 8 | yla);
rg.ZAxis = (int16_t)(zha << 8 | zla);
#elif
rg.XAxis = xha << 8 | xla;
rg.YAxis = yha << 8 | yla;
rg.ZAxis = zha << 8 | zla;
#endif

return rg;
}
Expand Down

0 comments on commit 11d93f0

Please sign in to comment.