DFRobot / DFRobot_BMI160

MIT License
24 stars 22 forks source link

Add timestamps when retrieving data #6

Closed LoJunKai closed 2 years ago

LoJunKai commented 2 years ago

Create new functions for getAccelData(), getGyroData(), getAccelGyroData() which will also return the timestamp of the sensor data.

Usage: For getAccelData() and getGyroData(),

int16_t accel[3] = {0};
uint32_t timestamp;
bmi160.getAccelData(accel, &timestamp);

For getAccelGyroData(),

int16_t accelGyro[6] = {0};
uint32_t timestamp[2] = {0};
bmi160.getAccelGyroData(accelGyro, timestamp);

Do note that to convert timestamp to relative time lapsed in seconds, do the following: (timestamp * 39) / 1000000.0 as BMI160 sensortime is a 39µs resolution time stamp generated by a real-time clock. Source.

Arya11111 commented 2 years ago

Thanks for your suggestion.