From a5b93cb5a341b08d7064f6617ebf5e1198975dff Mon Sep 17 00:00:00 2001 From: Guylain Plante Date: Mon, 17 Apr 2023 22:32:34 -0400 Subject: [PATCH] Added functions getSensorRawValues() --- src/BMI088.cpp | 24 +++++++++++++++++++----- src/BMI088.h | 5 +++++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/BMI088.cpp b/src/BMI088.cpp index c6ca973..61cb2ae 100644 --- a/src/BMI088.cpp +++ b/src/BMI088.cpp @@ -861,10 +861,9 @@ bool Bmi088Accel::getDrdyStatus() /* reads the BMI088 accel */ void Bmi088Accel::readSensor() -{ - /* accel data */ +{ uint16_t temp_uint11; - int16_t accel[3], temp_int11; + int16_t temp_int11; readRegisters(ACC_ACCEL_DATA_ADDR,9,_buffer); accel[0] = (_buffer[1] << 8) | _buffer[0]; accel[1] = (_buffer[3] << 8) | _buffer[2]; @@ -887,6 +886,12 @@ void Bmi088Accel::readSensor() temp_c = (float) temp_int11 * 0.125f + 23.0f; } +void Bmi088Accel::getSensorRawValues(int16_t* accelX, int16_t* accelY, int16_t* accelZ) { + *accelX = accel[0]; + *accelY = accel[1]; + *accelZ = accel[2]; +} + /* returns the x acceleration, m/s/s */ float Bmi088Accel::getAccelX_mss() { @@ -1419,8 +1424,6 @@ bool Bmi088Gyro::getDrdyStatus() /* reads the BMI088 gyro */ void Bmi088Gyro::readSensor() { - /* accel data */ - int16_t gyro[3]; readRegisters(GYRO_DATA_ADDR,6,_buffer); gyro[0] = (_buffer[1] << 8) | _buffer[0]; gyro[1] = (_buffer[3] << 8) | _buffer[2]; @@ -1430,6 +1433,12 @@ void Bmi088Gyro::readSensor() gyro_rads[2] = (float) (gyro[0] * tZ[0] + gyro[1] * tZ[1] + gyro[2] * tZ[2]) / 32767.0f * gyro_range_rads; } +void Bmi088Gyro::getSensorRawValues(int16_t* gyroX, int16_t* gyroY, int16_t* gyroZ) { + *gyroX = gyro[0]; + *gyroY = gyro[1]; + *gyroZ = gyro[2]; +} + /* returns the x gyro, rad/s */ float Bmi088Gyro::getGyroX_rads() { @@ -1725,6 +1734,11 @@ void Bmi088::readSensor() gyro->readSensor(); } +void Bmi088::getSensorRawValues(int16_t* accelX, int16_t* accelY, int16_t* accelZ, int16_t* gyroX, int16_t* gyroY, int16_t* gyroZ) { + accel->getSensorRawValues(accelX, accelY, accelZ); + gyro->getSensorRawValues(gyroX, gyroY, gyroZ); +} + float Bmi088::getAccelX_mss() { return accel->getAccelX_mss(); diff --git a/src/BMI088.h b/src/BMI088.h index a8909f7..d8b5966 100644 --- a/src/BMI088.h +++ b/src/BMI088.h @@ -81,6 +81,7 @@ class Bmi088Accel { bool mapDrdyInt2(bool enable); bool getDrdyStatus(); void readSensor(); + void getSensorRawValues(int16_t* accelX, int16_t* accelY, int16_t* accelZ); float getAccelX_mss(); float getAccelY_mss(); float getAccelZ_mss(); @@ -177,6 +178,7 @@ class Bmi088Accel { // accel full scale range float accel_range_mss; // accel data + int16_t accel[3]; float accel_mss[3]; // temperature data float temp_c; @@ -242,6 +244,7 @@ class Bmi088Gyro { bool mapDrdyInt4(bool enable); bool getDrdyStatus(); void readSensor(); + void getSensorRawValues(int16_t* gyroX, int16_t* gyroY, int16_t* gyroZ); float getGyroX_rads(); float getGyroY_rads(); float getGyroZ_rads(); @@ -314,6 +317,7 @@ class Bmi088Gyro { // gyro full scale range float gyro_range_rads; // gyro data + int16_t gyro[3]; float gyro_rads[3]; // self test bool selfTest(); @@ -375,6 +379,7 @@ class Bmi088 { bool mapSync(SyncPin pin); bool pinModeDrdy(PinMode mode, PinLevel level); void readSensor(); + void getSensorRawValues(int16_t* accelX, int16_t* accelY, int16_t* accelZ, int16_t* gyroX, int16_t* gyroY, int16_t* gyroZ); float getAccelX_mss(); float getAccelY_mss(); float getAccelZ_mss();