Revision 26f98bcd Adafruit_BNO055.cpp

View differences:

Adafruit_BNO055.cpp
70 70
  /* Set to normal power mode */
71 71
  write8(BNO055_PWR_MODE_ADDR, POWER_MODE_NORMAL);
72 72
  delay(10);
73
  
74
  /* Set the output units */
75
  uint8_t unitsel = (0 << 7) | /* Orientation = Android */
76
                    (0 << 4) | /* Temperature = Celsius */
77
                    (0 << 2) | /* Euler = Degrees */
78
                    (1 << 1) | /* Gyro = Rads */
79
                    (0 << 0);  /* Accelerometer = m/s^2 */
80
  write8(BNO055_UNIT_SEL_ADDR, unitsel);
81

  
82
  /* Orientation = Android (0 << )*/
83
  /* Temperature = Celsisu (0 << 4)
84
  uint8_t unitsel = 
73 85

  
74 86
  /* Set the requested operating mode (see section 3.3) */
75 87
  write8(BNO055_OPR_MODE_ADDR, mode);
......
232 244
  x = (((uint16_t)buffer[1]) << 8) | ((uint16_t)buffer[0]);
233 245
  y = (((uint16_t)buffer[3]) << 8) | ((uint16_t)buffer[2]);
234 246
  z = (((uint16_t)buffer[5]) << 8) | ((uint16_t)buffer[4]);
235
  
236
  /* Assign to Vector */
237
  xyz[0] = (double)x;
238
  xyz[1] = (double)y;
239
  xyz[2] = (double)z;
247

  
248
  /* Convert the value to an appropriate range (section 3.6.4) */
249
  /* and assign the value to the Vector type */
250
  switch(vector_type)
251
  {
252
    case VECTOR_MAGNETOMETER:
253
      /* 1uT = 16 LSB */
254
      xyz[0] = ((double)x)/16.0;
255
      xyz[1] = ((double)y)/16.0;
256
      xyz[2] = ((double)z)/16.0;
257
      break;
258
    case VECTOR_GYROSCOPE:
259
      /* 1rps = 900 LSB */
260
      xyz[0] = ((double)x)/900.0;
261
      xyz[1] = ((double)y)/900.0;
262
      xyz[2] = ((double)z)/900.0;
263
      break;
264
    case VECTOR_EULER:
265
      /* 1 degree = 16 LSB */
266
      xyz[0] = ((double)x)/16.0;
267
      xyz[1] = ((double)y)/16.0;
268
      xyz[2] = ((double)z)/16.0;
269
      break;
270
    case VECTOR_ACCELEROMETER:
271
    case VECTOR_LINEARACCEL:
272
    case VECTOR_GRAVITY:
273
      /* 1m/s^2 = 100 LSB */
274
      xyz[0] = ((double)x)/100.0;
275
      xyz[1] = ((double)y)/100.0;
276
      xyz[2] = ((double)z)/100.0;
277
      break;
278
  }
240 279
  
241 280
  return xyz;
242 281
}

Also available in: Unified diff