Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of MPU6050 by
Revision 1:cf3a9ec7205e, committed 2017-01-05
- Comitter:
- ritarosakai
- Date:
- Thu Jan 05 05:04:56 2017 +0000
- Parent:
- 0:6d1b9bcd64ca
- Child:
- 2:c68be621f2f1
- Commit message:
- add readraw; change to use FPU
Changed in this revision
| MPU6050.cpp | Show annotated file Show diff for this revision Revisions of this file |
| MPU6050.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/MPU6050.cpp Mon Sep 19 05:09:07 2016 +0000
+++ b/MPU6050.cpp Thu Jan 05 05:04:56 2017 +0000
@@ -30,12 +30,29 @@
char data2[6];
if (read_data(ADDRESS, MPU6050_GYRO_XOUT_H, data, 6)) {
read_data(ADDRESS, MPU6050_ACCEL_XOUT_H, data2, 6);
- *gx = float(short(data[0] << 8 | data[1]))*0.0305;
- *gy = float(short(data[2] << 8 | data[3]))*0.0305;
- *gz = float(short(data[4] << 8 | data[5]))*0.0305;
- *ax = float(short(data2[0] << 8 | data2[1]))*0.000122;
- *ay = float(short(data2[2] << 8 | data2[3]))*0.000122;
- *az = float(short(data2[4] << 8 | data2[5]))*0.000122;
+ *gx = float(short(data[0] << 8 | data[1]))*0.0305f;
+ *gy = float(short(data[2] << 8 | data[3]))*0.0305f;
+ *gz = float(short(data[4] << 8 | data[5]))*0.0305f;
+ *ax = float(short(data2[0] << 8 | data2[1]))*0.000122f;
+ *ay = float(short(data2[2] << 8 | data2[3]))*0.000122f;
+ *az = float(short(data2[4] << 8 | data2[5]))*0.000122f;
+ return true;
+ }
+ return false;
+}
+
+bool MPU6050::readraw(int *gx, int *gy, int *gz,int *ax, int *ay, int *az)
+{
+ char data[6];
+ char data2[6];
+ if (read_data(ADDRESS, MPU6050_GYRO_XOUT_H, data, 6)) {
+ read_data(ADDRESS, MPU6050_ACCEL_XOUT_H, data2, 6);
+ *gx = int(short(data[0] << 8 | data[1]));
+ *gy = int(short(data[2] << 8 | data[3]));
+ *gz = int(short(data[4] << 8 | data[5]));
+ *ax = int(short(data2[0] << 8 | data2[1]));
+ *ay = int(short(data2[2] << 8 | data2[3]));
+ *az = int(short(data2[4] << 8 | data2[5]));
return true;
}
return false;
--- a/MPU6050.h Mon Sep 19 05:09:07 2016 +0000
+++ b/MPU6050.h Thu Jan 05 05:04:56 2017 +0000
@@ -120,6 +120,7 @@
void start(void);
char getID(void);
bool read(float *gx, float *gy, float *gz,float *ax, float *ay, float *az);
+ bool readraw(int *gx, int *gy, int *gz,int *ax, int *ay, int *az);
private:
I2C _MPU6050;
float gx, gy, gz,ax,ay,az;
