Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added functions getSensorRawValues() #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions src/BMI088.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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()
{
Expand Down Expand Up @@ -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];
Expand All @@ -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()
{
Expand Down Expand Up @@ -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();
Expand Down
5 changes: 5 additions & 0 deletions src/BMI088.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down