Added support for different sensor addresses

Fork of MPU6050 by wisnu pamungkas

Only the MPU6050 constructor was changed. MPU6050 was added as a class member instead of being #defined

Files at this revision

API Documentation at this revision

Comitter:
nirvana77
Date:
Wed May 13 21:19:07 2015 +0000
Parent:
0:0e23b7f6dccd
Commit message:
added support for two sensors

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	Thu Feb 20 04:12:51 2014 +0000
+++ b/MPU6050.cpp	Wed May 13 21:19:07 2015 +0000
@@ -3,7 +3,8 @@
  */
 #include "MPU6050.h"
 
-MPU6050::MPU6050(PinName sda, PinName scl) : connection(sda, scl) {
+MPU6050::MPU6050(PinName sda, PinName scl,uint8_t address) : connection(sda, scl) {
+    this->MPU6050_ADDRESS = address;
     this->setSleepMode(false);
     
     //Initializations:
--- a/MPU6050.h	Thu Feb 20 04:12:51 2014 +0000
+++ b/MPU6050.h	Wed May 13 21:19:07 2015 +0000
@@ -15,9 +15,9 @@
 /**
  * Defines
  */
-#ifndef MPU6050_ADDRESS
-    #define MPU6050_ADDRESS             0x68 // address pin low (GND), default for InvenSense evaluation board
-#endif
+//#ifndef MPU6050_ADDRESS
+//   #define MPU6050_ADDRESS             0x68 // address pin low (GND), default for InvenSense evaluation board
+//#endif
 
 #ifdef MPU6050_ES
         #define DOUBLE_ACCELERO
@@ -83,6 +83,8 @@
   */
 class MPU6050 {
     public:
+    uint8_t MPU6050_ADDRESS ;
+
      /**
      * Constructor.
      *
@@ -91,7 +93,7 @@
      * @param sda - mbed pin to use for the SDA I2C line.
      * @param scl - mbed pin to use for the SCL I2C line.
      */
-     MPU6050(PinName sda, PinName scl);
+     MPU6050(PinName sda, PinName scl,uint8_t address);
      
 
      /**