Slightly modified version (to work with processing GUI)

Dependencies:   ITG3200 mbed

Fork of 6DoF_IMU_readvalue by Ryo Nakabayashi

Revision:
5:e4a11d519322
Parent:
4:c7d5863b2576
diff -r c7d5863b2576 -r e4a11d519322 main.cpp
--- a/main.cpp	Thu Oct 24 20:31:54 2013 +0000
+++ b/main.cpp	Wed Feb 05 22:12:32 2014 +0000
@@ -8,7 +8,7 @@
 ADXL345_I2C accel(p28, p27);
 
 int main() {
-    char str[512];
+    char str[296];
     rn42.baud(115200);
     gyro.setWhoAmI(0x68);
     //pc.printf("Now starting 6-degrees-of-freedom (ITG-3200 ADXL345) test...\n");
@@ -16,7 +16,7 @@
     //pc.printf("Gyro Devide ID is: 0x%02x\n", gyro.getWhoAmI());
      
      
-    int accel_read[3] = {0, 0, 0};
+    short int accel_read[3] = {0, 0, 0};
     
     // Accel setup
     // These are here to test whether any of the initialization fails. It will print the failure
@@ -24,25 +24,25 @@
          rn42.printf("didn't intitialize power control\n"); 
          return 0;  }
     //Full resolution, +/-16g, 4mg/LSB.
-    wait(.001);
+    //wait(.001);
      
-    if(accel.setDataFormatControl(0x0B)){
-        rn42.printf("didn't set data format\n");
-        return 0;  }
-    wait(.001);
+    //if(accel.setDataFormatControl(0x0B)){
+      //  rn42.printf("didn't set data format\n");
+      //  return 0;  }
+    //wait(.001);
     
     //3.2kHz data rate.
-    if(accel.setDataRate(ADXL345_1600HZ)){
-       rn42.printf("didn't set data rate\n");
-       return 0;    }
-    wait(.001);
+    //if(accel.setDataRate(ADXL345_3200HZ)){
+      // rn42.printf("didn't set data rate\n");
+      // return 0;    }
+    //wait(.001);
      
     //Measurement mode.
     
-    if(accel.setPowerControl(MeasurementMode)) {
-       rn42.printf("didn't set the power control to measurement\n"); 
-       return 0;   
-    }
+    //if(accel.setPowerControl(MeasurementMode)) {
+      // rn42.printf("didn't set the power control to measurement\n"); 
+      // return 0;   
+    //}
      
     // Gyro setup   
     gyro.setLpBandwidth(LPFBW_256HZ);
@@ -53,8 +53,11 @@
         
         accel.getOutput(accel_read);
         
-        sprintf(str, "%i,%i,%i,%i,%i,%i,%i,A", (int16_t)accel_read[0], (int16_t)accel_read[1], (int16_t)accel_read[2],
-                                                     gyro.getGyroX(), gyro.getGyroY(), gyro.getGyroZ(), (int16_t)gyro.getTemperature());  
+        /*sprintf(str, "%i,%i,%i,%i,%i,%i,%i,A", (int16_t)accel_read[0], (int16_t)accel_read[1], (int16_t)accel_read[2],
+                                                     gyro.getGyroX(), gyro.getGyroY(), gyro.getGyroZ(), (int16_t)gyro.getTemperature());*/  
+                                                     
+        sprintf(str, "%i,%i,%i,%i,%i,%iA", (int16_t)accel_read[0], (int16_t)accel_read[1], (int16_t)accel_read[2],
+                                                     gyro.getGyroX(), gyro.getGyroY(), gyro.getGyroZ());
         rn42.printf(str);
         
         /*