fork from > MPU6050 library that is kinda beta and will probably never leave beta but it might help some people.

Fork of MPU6050 by Erik -

Files at this revision

API Documentation at this revision

Comitter:
c201075
Date:
Sun May 20 05:49:35 2018 +0000
Parent:
2:5c63e20c50f3
Commit message:
mpu????????LED?????????????

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
diff -r 5c63e20c50f3 -r 56c385fd3617 MPU6050.cpp
--- a/MPU6050.cpp	Mon Sep 10 21:26:25 2012 +0000
+++ b/MPU6050.cpp	Sun May 20 05:49:35 2018 +0000
@@ -85,40 +85,40 @@
     this->write(MPU6050_ACCELERO_CONFIG_REG, temp);
 }
 
-int MPU6050::getAcceleroRawX( void ) {
+short MPU6050::getAcceleroRawX( void ) {
     short retval;
     char data[2];
     this->read(MPU6050_ACCEL_XOUT_H_REG, data, 2);
     retval = (data[0]<<8) + data[1];
-    return (int)retval;
+    return retval;
 }
     
-int MPU6050::getAcceleroRawY( void ) {
+short MPU6050::getAcceleroRawY( void ) {
     short retval;
     char data[2];
     this->read(MPU6050_ACCEL_YOUT_H_REG, data, 2);
     retval = (data[0]<<8) + data[1];
-    return (int)retval;
+    return retval;
 }
 
-int MPU6050::getAcceleroRawZ( void ) {
+short MPU6050::getAcceleroRawZ( void ) {
     short retval;
     char data[2];
     this->read(MPU6050_ACCEL_ZOUT_H_REG, data, 2);
     retval = (data[0]<<8) + data[1];
-    return (int)retval;
+    return retval;
 }
 
-void MPU6050::getAcceleroRaw( int *data ) {
+void MPU6050::getAcceleroRaw( short *data ) {
     char temp[6];
     this->read(MPU6050_ACCEL_XOUT_H_REG, temp, 6);
-    data[0] = (int)(short)((temp[0]<<8) + temp[1]);
-    data[1] = (int)(short)((temp[2]<<8) + temp[3]);
-    data[2] = (int)(short)((temp[4]<<8) + temp[5]);
+    data[0] = (short)((temp[0]<<8) + temp[1]);
+    data[1] = (short)((temp[2]<<8) + temp[3]);
+    data[2] = (short)((temp[4]<<8) + temp[5]);
 }
 
 void MPU6050::getAccelero( float *data ) {
-    int temp[3];
+    short temp[3];
     this->getAcceleroRaw(temp);
     if (currentAcceleroRange == MPU6050_ACCELERO_RANGE_2G) {
         data[0]=(float)temp[0] / 16384.0 * 9.81;
@@ -161,40 +161,40 @@
     this->write(MPU6050_GYRO_CONFIG_REG, temp);
 }
 
-int MPU6050::getGyroRawX( void ) {
+short MPU6050::getGyroRawX( void ) {
     short retval;
     char data[2];
     this->read(MPU6050_GYRO_XOUT_H_REG, data, 2);
     retval = (data[0]<<8) + data[1];
-    return (int)retval;
+    return retval;
 }
     
-int MPU6050::getGyroRawY( void ) {
+short MPU6050::getGyroRawY( void ) {
     short retval;
     char data[2];
     this->read(MPU6050_GYRO_YOUT_H_REG, data, 2);
     retval = (data[0]<<8) + data[1];
-    return (int)retval;
+    return retval;
 }
 
-int MPU6050::getGyroRawZ( void ) {
+short MPU6050::getGyroRawZ( void ) {
     short retval;
     char data[2];
     this->read(MPU6050_GYRO_ZOUT_H_REG, data, 2);
     retval = (data[0]<<8) + data[1];
-    return (int)retval;
+    return retval;
 }
 
-void MPU6050::getGyroRaw( int *data ) {
+void MPU6050::getGyroRaw( short *data ) {
     char temp[6];
     this->read(MPU6050_GYRO_XOUT_H_REG, temp, 6);
-    data[0] = (int)(short)((temp[0]<<8) + temp[1]);
-    data[1] = (int)(short)((temp[2]<<8) + temp[3]);
-    data[2] = (int)(short)((temp[4]<<8) + temp[5]);
+    data[0] = (short)((temp[0]<<8) + temp[1]);
+    data[1] = (short)((temp[2]<<8) + temp[3]);
+    data[2] = (short)((temp[4]<<8) + temp[5]);
 }
 
 void MPU6050::getGyro( float *data ) {
-    int temp[3];
+    short temp[3];
     this->getGyroRaw(temp);
     if (currentGyroRange == MPU6050_GYRO_RANGE_250) {
         data[0]=(float)temp[0] / 7505.7;
diff -r 5c63e20c50f3 -r 56c385fd3617 MPU6050.h
--- a/MPU6050.h	Mon Sep 10 21:26:25 2012 +0000
+++ b/MPU6050.h	Sun May 20 05:49:35 2018 +0000
@@ -16,7 +16,7 @@
  * Defines
  */
 #ifndef MPU6050_ADDRESS
-    #define MPU6050_ADDRESS             0x69 // address pin low (GND), default for InvenSense evaluation board
+#define MPU6050_ADDRESS             0x68 // address pin low (GND), default for InvenSense evaluation board
 #endif
 
 #ifdef MPU6050_ES
@@ -132,28 +132,28 @@
      *
      * @return 16-bit signed integer x-axis accelero data
      */   
-     int getAcceleroRawX( void );
+     short getAcceleroRawX( void );
      
      /**
      * Reads the accelero y-axis.
      *
      * @return 16-bit signed integer y-axis accelero data
      */   
-     int getAcceleroRawY( void );
+     short getAcceleroRawY( void );
      
      /**
      * Reads the accelero z-axis.
      *
      * @return 16-bit signed integer z-axis accelero data
      */   
-     int getAcceleroRawZ( void );
+     short getAcceleroRawZ( void );
      
      /**
      * Reads all accelero data.
      *
      * @param data - pointer to signed integer array with length three: data[0] = X, data[1] = Y, data[2] = Z
      */   
-     void getAcceleroRaw( int *data );
+     void getAcceleroRaw( short *data );
      
      /**
      * Reads all accelero data, gives the acceleration in m/s2
@@ -178,28 +178,28 @@
      *
      * @return 16-bit signed integer x-axis gyro data
      */   
-     int getGyroRawX( void );
+     short getGyroRawX( void );
      
      /**
      * Reads the gyro y-axis.
      *
      * @return 16-bit signed integer y-axis gyro data
      */   
-     int getGyroRawY( void );
+     short getGyroRawY( void );
      
      /**
      * Reads the gyro z-axis.
      *
      * @return 16-bit signed integer z-axis gyro data
      */   
-     int getGyroRawZ( void );
+     short getGyroRawZ( void );
      
      /**
      * Reads all gyro data.
      *
      * @param data - pointer to signed integer array with length three: data[0] = X, data[1] = Y, data[2] = Z
      */   
-     void getGyroRaw( int *data );  
+     void getGyroRaw( short *data );  
      
      /**
      * Reads all gyro data, gives the gyro in rad/s