NRF+MPU6050

Dependencies:   mbed nRF24L01P

Revision:
4:1b985e622d26
Parent:
3:46535ec6d8b1
Child:
5:6a93542b8922
diff -r 46535ec6d8b1 -r 1b985e622d26 MPU6050.h
--- a/MPU6050.h	Mon Mar 18 03:39:29 2019 +0000
+++ b/MPU6050.h	Wed Mar 20 10:44:31 2019 +0000
@@ -153,7 +153,7 @@
 int Ascale = AFS_2G;
 
 //Set up I2C, (SDA,SCL)
-I2C i2c(PB_7,PB_6);
+
 
 //DigitalOut myled(LED1);
    
@@ -185,18 +185,21 @@
 int lastUpdate = 0, firstUpdate = 0, Now = 0;     // used to calculate integration interval                               // used to calculate integration interval
 float q[4] = {1.0f, 0.0f, 0.0f, 0.0f};            // vector to hold quaternion
 
-class MPU6050 {
+class mpu6050 {
  
     protected:
+    I2C i2c;
+    Timer t;
  
     public:
   //===================================================================================================================
 //====== Set of useful function to access acceleratio, gyroscope, and temperature data
 //===================================================================================================================
 
-    MPU6050(PinName SDA,PinName SCL)
+    mpu6050(PinName SDA,PinName SCL):i2c(SDA,SCL)
 {
-    I2C i2c(SDA,SCL);
+    t.start();
+    i2c.frequency(400000);
 }
     void writeByte(uint8_t address, uint8_t subAddress, uint8_t data)
 {
@@ -772,7 +775,7 @@
 
     // Serial print and/or display at 0.5 s rate independent of data rates
     delt_t = t.read_ms() - count1;
-    if (delt_t > 500) { // update LCD once per half-second independent of read rate
+    if (delt_t > 50) { // update LCD once per half-second independent of read rate
 
 //    pc.printf("ax = %f", 1000*ax); 
 //    pc.printf(" ay = %f", 1000*ay);