 BMP085            barometer;
 Adafruit_SSD1306  display = Adafruit_SSD1306();
 
-// store accel and gyro values from MPU6050, and accel using unit "g"(float) 
+// store accel and gyro values from MPU6050, and accel using unit "g"(float)
 int16_t ax, ay, az;
 int16_t gx, gy, gz;
 int16_t mx, my, mz;

  az_f = az / 16384.0;

  // display tab-separated accel/gyro x/y/z values
   Serial.print("a/g:\t");
   Serial.print(ax_f); Serial.print("\t");
   Serial.print(ay_f); Serial.print("\t");
   Serial.print(az_f); Serial.print("\t");
   Serial.print(gx); Serial.print("\t");
   Serial.print(gy); Serial.print("\t");
   Serial.print(gz);Serial.print("\t");
   
   Serial.print("mag:\t");
   Serial.print(mx); Serial.print("\t");
   Serial.print(my); Serial.print("\t");
   Serial.print(mz); Serial.print("\t");

  // To calculate heading in degrees. 0 degree indicates North
   float heading = atan2(my, mz);
   if(heading < 0)
     heading += 2 * M_PI;
   heading *= 180/M_PI;
   Serial.print("heading:\t");
   Serial.print(heading); Serial.print("\t");

   // display measured values if appropriate
   Serial.print("T/P/A\t");
   Serial.print(temperature); Serial.print("\t");
   Serial.print(pressure); Serial.print("\t");
   Serial.print(altitude);
   Serial.println("");

  dtostrf(ax_f, 4, 2, tempbuffer[0]);   // -x.x
  dtostrf(ay_f, 4, 2, tempbuffer[1]);   // -x.x
  dtostrf(az_f, 4, 2, tempbuffer[2]);   // -x.x
  snprintf(displaybuffer[0], 21, "A %s %s %s", tempbuffer[0], tempbuffer[1], tempbuffer[2]);
  
  snprintf(displaybuffer[1], 21, "G: %+4d %+4d %+4d", gx, gy, gz);

  dtostrf(heading, 3, 0, tempbuffer[0]);   // xxx
  snprintf(displaybuffer[2], 21, "H: %s", tempbuffer[0]);

  dtostrf(temperature, 5, 2, tempbuffer[0]);   // -xx.x  
  dtostrf(pressure, 5, 2, tempbuffer[1]);   // -xx.x  
  snprintf(displaybuffer[3], 21, "T: %s, P: %s", tempbuffer[0], tempbuffer[1]);

//   Serial.println(displaybuffer[0]);
//   Serial.println(displaybuffer[1]);
//   Serial.println(displaybuffer[2]);
//   Serial.println(displaybuffer[3]);

  display.clearDisplay();
  display.setCursor(0,0);
  display.println(displaybuffer[0]);
//  display.println(displaybuffer[1]);
//  display.println(displaybuffer[2]);
//  display.println(displaybuffer[3]);
  delay(10);
  yield();
  display.display();

  delay(100);  
}

  pinMode(BUTTON_A, INPUT_PULLUP);
  pinMode(BUTTON_B, INPUT_PULLUP);
  pinMode(BUTTON_C, INPUT_PULLUP);

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.display();

  accelgyro.setI2CMasterModeEnabled(false);
  accelgyro.setI2CBypassEnabled(true) ;
  accelgyro.setSleepEnabled(false);
