Expose MPU-6050 FIFO and some helper functions #39
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm using the MPU-6050 to measure vibration, which requires rapid acceleration sampling. I achieve that by configuring the FIFO to store acceleration samples at 200Hz, accumulate 128 samples (power of 2 for FFT; 256 doesn't fit in the 1024b FIFO since each sample is 6B), then reading them out of the FIFO for processing (calculate magnitude, then FFT or actually ulab.utils.spectrogram). The reading needs to happen fast so that the FIFO doesn't overflow during the readout.
The FIFO itself is highly configurable, so it isn't reasonable for the library to track exactly how the user has configured it.
I also expose helper functions for scaling the samples that are read out of the FIFO, though the user still has to know how to unpack the raw bytes.
My surrounding code, very roughly, is: