Revision f0ebdf46

View differences:

Adafruit_BNO055.cpp
510 510
}
511 511

  
512 512
/*!
513
 *  @brief  Reads the sensor and returns the data as a sensors_event_t
514
 *  @param  event
515
 *  @param  vec_type
516
 *          specify the type of reading
517
 *  @return always returns true
518
 */
519
bool Adafruit_BNO055::getEvent(sensors_event_t *event, adafruit_vector_type_t vec_type)
520
{
521
  /* Clear the event */
522
  memset(event, 0, sizeof(sensors_event_t));
523

  
524
  event->version = sizeof(sensors_event_t);
525
  event->sensor_id = _sensorID;
526
  event->timestamp = millis();
527

  
528
  //read the data according to vec_type
529
  imu::Vector<3> vec;
530
  if (vec_type == Adafruit_BNO055::VECTOR_LINEARACCEL)
531
  {
532
    event->type = SENSOR_TYPE_ACCELEROMETER;
533
    vec = getVector(Adafruit_BNO055::VECTOR_LINEARACCEL);
534

  
535
    event->acceleration.x = vec.x();
536
    event->acceleration.y = vec.y();
537
    event->acceleration.z = vec.z();
538
  }
539
  else if (vec_type == Adafruit_BNO055::VECTOR_ACCELEROMETER)
540
  {
541
    event->type = SENSOR_TYPE_ACCELEROMETER;
542
    vec = getVector(Adafruit_BNO055::VECTOR_ACCELEROMETER);
543

  
544
    event->acceleration.x = vec.x();
545
    event->acceleration.y = vec.y();
546
    event->acceleration.z = vec.z();
547
  }
548
  else if (vec_type == Adafruit_BNO055::VECTOR_GRAVITY)
549
  {
550
    event->type = SENSOR_TYPE_ACCELEROMETER;
551
    vec = getVector(Adafruit_BNO055::VECTOR_GRAVITY);
552

  
553
    event->acceleration.x = vec.x();
554
    event->acceleration.y = vec.y();
555
    event->acceleration.z = vec.z();
556
  }
557
  else if (vec_type == Adafruit_BNO055::VECTOR_EULER)
558
  {
559
    event->type = SENSOR_TYPE_ORIENTATION;
560
    vec = getVector(Adafruit_BNO055::VECTOR_EULER);
561

  
562
    event->orientation.x = vec.x();
563
    event->orientation.y = vec.y();
564
    event->orientation.z = vec.z();
565
  }
566
  else if (vec_type == Adafruit_BNO055::VECTOR_GYROSCOPE)
567
  {
568
    event->type = SENSOR_TYPE_ROTATION_VECTOR;
569
    vec = getVector(Adafruit_BNO055::VECTOR_GYROSCOPE);
570

  
571
    event->gyro.x = vec.x();
572
    event->gyro.y = vec.y();
573
    event->gyro.z = vec.z();
574
  }
575
  else if (vec_type == Adafruit_BNO055::VECTOR_MAGNETOMETER)
576
  {
577
    event->type = SENSOR_TYPE_MAGNETIC_FIELD;
578
    vec = getVector(Adafruit_BNO055::VECTOR_MAGNETOMETER);
579

  
580
    event->magnetic.x = vec.x();
581
    event->magnetic.y = vec.y();
582
    event->magnetic.z = vec.z();
583
  }
584
  
585

  
586
  return true;
587
}
588

  
589

  
590
/*!
513 591
 *  @brief  Reads the sensor's offset registers into a byte array
514 592
 *  @param  calibData
515 593
 *  @return true if read is successful
Adafruit_BNO055.h
300 300

  
301 301
  /* Adafruit_Sensor implementation */
302 302
  bool getEvent(sensors_event_t *);
303
  bool getEvent(sensors_event_t *, adafruit_vector_type_t);
303 304
  void getSensor(sensor_t *);
304 305

  
305 306
  /* Functions to deal with raw calibration data */
......
309 310
  void setSensorOffsets(const adafruit_bno055_offsets_t &offsets_type);
310 311
  bool isFullyCalibrated();
311 312

  
313
  /* Power managments functions */
314
  void enterSuspendMode();
315
  void enterNormalMode();
316

  
312 317
private:
313 318
  byte read8(adafruit_bno055_reg_t);
314 319
  bool readLen(adafruit_bno055_reg_t, byte *buffer, uint8_t len);

Also available in: Unified diff