I am using this code to get velocity using change in height. For height measurement, I am using a bmp390 sensor and the height is calculated taking ground as reference.
I don't notice any difference in delay generation using your method over mine. Will your method make my code more efficient in terms of processing load?
Perry’s suggestion is better at timing slippage, however, it can result in abnormal results under certain instances; won’t get into those at the moment.
How are you checking? It's only a few minutes since I posted that, so you would not notice with your naked eyes! You might notice with your eyes pointed at the display of an oscilloscope.
Processing load is negligible in either case. Doing it that way ensures the interval increases by 100 (or whatever) every time, even if the exact 100 point is missed.
There's a while loop in the Adafruit library that's active while parsing fifo frames. My guess is you're using this library and this is contributing to the 4ms timing discrepancy.
I guess you'll need to look through your full code (I don't see it here).
My original code comprises of a lot of sensors and 8-9 functions, that's why I only sent a part of it. And the test code which generated 104 ms delay is this one