Calibration questions

I could use some advice about how to code for the calibration of the BMI160.  Consider that I will want to have the user hit a calibration button and initiate a gyro and accelerometer calibration process.  Consider a button for each for simplicity of this question.  What do I need to do in my functions tied to each of these buttons?  I see that the API has some internal test capabilities.  Are these related to the calibration process or is there some other command I haven't seen yet?

For the accelerometer calibration the user will have to put the product flat on a desk then hit the button which will start my routine.  They then need to rotate the device in a 360 degree circle.  Can you explain the necessary things my code needs to do to initiate the process, and to know when it is done, what it needs to read, what calculations or data it needs to do to write back to the calibration so that the device is 'calibrated'?  I assume the same type of calling patterns would be needed for the gyro except that the user needs to rotate it 360 degrees in x, then y, then z axis.  How can my code know that each of these stages is completed and to move on to the next one, or when the process is completed, how to lock that in?

Or am I thinking about calibration all wrong?  Please suggest a more productive way of approaching this if I am not on the right track.

1 reply