Open akda5id opened 2 months ago
Ok, a bit more poking around, and more careful reading of the datasheet, and turns out what I wanted was "Stream" mode not fifo. Now reading .acceleration()
gets me the most recent data, and I can burst reads until the queue is empty, after which I get the same data as the last read. And not reseting the queue with Bypass
anymore, of course.
I still wonder if there is a way to see the depth of the queue, I was thinking checking for .accel_status().unwrap().xyz_new_data()
might be it, but looks like that flag gets cleared on the first read, and doesn't get reset until new data is written, which, yeah, is correct. I just have to know how deep I want to read I guess?
I'm poking around, and trying to understand how the fifo is set up. EDIT: Skip the rest of this comment, I have resolved most of my confusion in the second comment in the thread.
From the datasheet it seems you have to set fifo mode to bypass to clear the fifo after you read it, which seems to be sorta working, but I am not sure if this is how the reading is intended, I seem to always get "dead" data for the first
sensor.acceleration()
read. Is there a better way to read a chunk from the buffer? Is there a way to see how much is in the buffer? In my bogus test code below, I am intentionally reading too far, and just get duplicated data for the last item(s).