I have a realtime acquisition that happens every 1/10 of a second (the loop fires about every 100ms)... I would like to continually build an array of 5 collected values and then send it off to another part of the program (produced consumed), and then zero the array and do it again, continually.
Any suggestions on how to do this? My example just seems to build an array of 5 of the current reading, not the last 5 readings... wondering if there is a way to only execute the loop on "consumed deque" (not sure if I'm saying that right).
Solved! Go to Solution.
I solved it I think... changed it to a while loop instead of the FOR loop which was executing 5 times every while loop iteration.
It is generally a bad idea to constantly resize arrays (does not matter too much with such small arrays, but it's a bad habit!)
All you need is an array initialize with 5 element where you replace the oldest and send it off whenver five have been replaced.
Here's a quick draft. Modify as needed.