Fork of Alexander Lill's BNO055_fusion library
Diff: BNO055.cpp
- Revision:
- 7:f0eb18503c27
- Parent:
- 6:07d01bf36ad0
- Child:
- 8:46134e7474e7
--- a/BNO055.cpp Wed Aug 23 09:44:43 2017 +0000 +++ b/BNO055.cpp Sun Jan 28 19:35:11 2018 +0000 @@ -55,7 +55,7 @@ } /////////////// Read data & normalize ///////////////////// -void BNO055::get_Euler_Angles(BNO055_EULER_TypeDef *el) +void BNO055::get_euler_angles(BNO055_EULER_TypeDef *result) { uint8_t deg_or_rad; int16_t h,p,r; @@ -76,29 +76,29 @@ p = dt[3] << 8 | dt[2]; r = dt[5] << 8 | dt[4]; if (deg_or_rad) { - el->h = (double)h / 900; - el->p = (double)p / 900; - el->r = (double)r / 900; + result->h = (double)h / 900; + result->p = (double)p / 900; + result->r = (double)r / 900; } else { - el->h = (double)h / 16; - el->p = (double)p / 16; - el->r = (double)r / 16; + result->h = (double)h / 16; + result->p = (double)p / 16; + result->r = (double)r / 16; } } -void BNO055::get_quaternion(BNO055_QUATERNION_TypeDef *qua) +void BNO055::get_quaternion(BNO055_QUATERNION_TypeDef *result) { select_page(0); dt[0] = BNO055_QUATERNION_W_LSB; _i2c.write(chip_addr, dt, 1, true); _i2c.read(chip_addr, dt, 8, false); - qua->w = dt[1] << 8 | dt[0]; - qua->x = dt[3] << 8 | dt[2]; - qua->y = dt[5] << 8 | dt[4]; - qua->z = dt[7] << 8 | dt[6]; + result->w = dt[1] << 8 | dt[0]; + result->x = dt[3] << 8 | dt[2]; + result->y = dt[5] << 8 | dt[4]; + result->z = dt[7] << 8 | dt[6]; } -void BNO055::get_linear_accel(BNO055_LIN_ACC_TypeDef *la) +void BNO055::get_linear_accel(BNO055_VECTOR_TypeDef *result) { uint8_t ms2_or_mg; int16_t x,y,z; @@ -119,17 +119,17 @@ y = dt[3] << 8 | dt[2]; z = dt[5] << 8 | dt[4]; if (ms2_or_mg) { - la->x = (double)x; - la->y = (double)y; - la->z = (double)z; + result->x = (double)x; + result->y = (double)y; + result->z = (double)z; } else { - la->x = (double)x / 100; - la->y = (double)y / 100; - la->z = (double)z / 100; + result->x = (double)x / 100; + result->y = (double)y / 100; + result->z = (double)z / 100; } } -void BNO055::get_gravity(BNO055_GRAVITY_TypeDef *gr) +void BNO055::get_gravity(BNO055_VECTOR_TypeDef *result) { uint8_t ms2_or_mg; int16_t x,y,z; @@ -150,17 +150,17 @@ y = dt[3] << 8 | dt[2]; z = dt[5] << 8 | dt[4]; if (ms2_or_mg) { - gr->x = (double)x; - gr->y = (double)y; - gr->z = (double)z; + result->x = (double)x; + result->y = (double)y; + result->z = (double)z; } else { - gr->x = (double)x / 100; - gr->y = (double)y / 100; - gr->z = (double)z / 100; + result->x = (double)x / 100; + result->y = (double)y / 100; + result->z = (double)z / 100; } } -void BNO055::get_chip_temperature(BNO055_TEMPERATURE_TypeDef *tmp) +void BNO055::get_chip_temperature(BNO055_TEMPERATURE_TypeDef *result) { uint8_t c_or_f; @@ -181,9 +181,9 @@ _i2c.write(chip_addr, dt, 1, true); _i2c.read(chip_addr, dt, 1, false); if (c_or_f) { - tmp->acc_chip = (int8_t)dt[0] * 2; + result->acc_chip = (int8_t)dt[0] * 2; } else { - tmp->acc_chip = (int8_t)dt[0]; + result->acc_chip = (int8_t)dt[0]; } dt[0] = BNO055_TEMP_SOURCE; dt[1] = 1; @@ -193,9 +193,9 @@ _i2c.write(chip_addr, dt, 1, true); _i2c.read(chip_addr, dt, 1, false); if (c_or_f) { - tmp->gyr_chip = (int8_t)dt[0] * 2; + result->gyr_chip = (int8_t)dt[0] * 2; } else { - tmp->gyr_chip = (int8_t)dt[0]; + result->gyr_chip = (int8_t)dt[0]; } } @@ -484,5 +484,3 @@ change_fusion_mode(current_mode); return d; } - -