Skip to content

Commit

Permalink
Merge pull request #110 from caternuson/misc_fixes
Browse files Browse the repository at this point in the history
Change gyro units and fix gravity sensor type
  • Loading branch information
caternuson authored Aug 13, 2021
2 parents c70a80e + 24d174d commit 9f53f80
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
10 changes: 5 additions & 5 deletions Adafruit_BNO055.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ bool Adafruit_BNO055::getEvent(sensors_event_t *event,
event->acceleration.y = vec.y();
event->acceleration.z = vec.z();
} else if (vec_type == Adafruit_BNO055::VECTOR_GRAVITY) {
event->type = SENSOR_TYPE_ACCELEROMETER;
event->type = SENSOR_TYPE_GRAVITY;
vec = getVector(Adafruit_BNO055::VECTOR_GRAVITY);

event->acceleration.x = vec.x();
Expand All @@ -556,12 +556,12 @@ bool Adafruit_BNO055::getEvent(sensors_event_t *event,
event->orientation.y = vec.y();
event->orientation.z = vec.z();
} else if (vec_type == Adafruit_BNO055::VECTOR_GYROSCOPE) {
event->type = SENSOR_TYPE_ROTATION_VECTOR;
event->type = SENSOR_TYPE_GYROSCOPE;
vec = getVector(Adafruit_BNO055::VECTOR_GYROSCOPE);

event->gyro.x = vec.x();
event->gyro.y = vec.y();
event->gyro.z = vec.z();
event->gyro.x = vec.x() * SENSORS_DPS_TO_RADS;
event->gyro.y = vec.y() * SENSORS_DPS_TO_RADS;
event->gyro.z = vec.z() * SENSORS_DPS_TO_RADS;
} else if (vec_type == Adafruit_BNO055::VECTOR_MAGNETOMETER) {
event->type = SENSOR_TYPE_MAGNETIC_FIELD;
vec = getVector(Adafruit_BNO055::VECTOR_MAGNETOMETER);
Expand Down
1 change: 0 additions & 1 deletion Adafruit_BNO055.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ class Adafruit_BNO055 : public Adafruit_Sensor {

/* Unit selection register */
BNO055_UNIT_SEL_ADDR = 0X3B,
BNO055_DATA_SELECT_ADDR = 0X3C,

/* Mode registers */
BNO055_OPR_MODE_ADDR = 0X3D,
Expand Down
6 changes: 6 additions & 0 deletions examples/read_all_data/read_all_data.ino
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ void printEvent(sensors_event_t* event) {
y = event->acceleration.y;
z = event->acceleration.z;
}
else if (event->type == SENSOR_TYPE_GRAVITY) {
Serial.print("Gravity:");
x = event->acceleration.x;
y = event->acceleration.y;
z = event->acceleration.z;
}
else {
Serial.print("Unk:");
}
Expand Down

0 comments on commit 9f53f80

Please sign in to comment.