Custom ring buffer written from scratch to allow data collection at a rigid rate, while allowing writing that data to either serial or an SD card whenever time allows.
Diff: ServoRingBuffer.cpp
- Revision:
- 2:da00ed8a1cd5
- Parent:
- 0:01fb4588b738
--- a/ServoRingBuffer.cpp Mon Apr 06 21:10:08 2015 +0000
+++ b/ServoRingBuffer.cpp Wed Apr 29 21:52:23 2015 +0000
@@ -97,12 +97,12 @@
static unsigned int currentReadIdx;
for (ii = 0; ii < readsRemaining(); ii ++) {
currentReadIdx = (lastRead + 1) % BUFFER_SIZE;
+ fprintf(txtFile,"%d,", ringBuffer[currentReadIdx].time);
for(jj=0;jj<NUMBER_OF_SPINDLES;jj++)
{
fprintf(txtFile,"%d,%d,", ringBuffer[currentReadIdx].myServoData[jj].pos,
ringBuffer[currentReadIdx].myServoData[jj].force);
}
- fprintf(txtFile,"%d,", ringBuffer[currentReadIdx].time);
fprintf(txtFile,"%d,", ringBuffer[currentReadIdx].direction);
fprintf(txtFile,"%d\n", ringBuffer[currentReadIdx].cycle);
lastRead = currentReadIdx;