DFRobot / DFRobot_BMI160

MIT License
24 stars 22 forks source link

Minor correction in .cpp file #1

Closed renr3 closed 2 years ago

renr3 commented 6 years ago

Hello! First of all, great library. While using the method getSensorData, to get only acceleration or gyro data (not both together), I noticed an unexpected behaviour: the values were always constant. Looking through the source code, I noticed in the .cpp file needed a minor correction in the method getSensorData, that I posted below, on the bolded/italic parts. They need to be changed with each other for correct behaviour.

Similar corrections are needed on getAccelData and getGyroData methods.

What do you guys think?

Best regards

`int8_t DFRobot_BMI160::getSensorData(uint8_t type, int16_t* data) { int8_t rslt=BMI160_OK; if (type==onlyAccel){ rslt = getSensorData(BMI160_ACCEL_SEL, Oaccel, NULL, Obmi160); if(rslt == BMI160_OK){ data[0]=Ogyro->x; data[1]=Ogyro->y; data[2]=Ogyro->z; } }else if(type==onlyGyro){ rslt = getSensorData(BMI160_GYRO_SEL, NULL, Ogyro, Obmi160); if(rslt == BMI160OK){ data[0]=Oaccel->x; data[1]=Oaccel->y; data[2]=Oaccel->z;_ } }else if(type==bothAccelGyro){ rslt = DFRobot_BMI160::getSensorData((BMI160_ACCEL_SEL | BMI160_GYRO_SEL),Oaccel, Ogyro, Obmi160); if(rslt == BMI160_OK){ data[0]=Ogyro->x; data[1]=Ogyro->y; data[2]=Ogyro->z; data[3]=Oaccel->x; data[4]=Oaccel->y; data[5]=Oaccel->z; } }else{ rslt = BMI160_ERR_CHOOSE; }

return rslt; }`

Arya11111 commented 2 years ago

Thanks, it has been changed