1

Fork of MPU6050 by Stanislav Dudin

Revision:
1:cf3a9ec7205e
Parent:
0:6d1b9bcd64ca
Child:
2:c68be621f2f1
diff -r 6d1b9bcd64ca -r cf3a9ec7205e MPU6050.cpp
--- 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;