A set of data recording functions to locally store data in a circular buffer, with functions for offloading to an SD Card when convenient. dataRecorderr.h shows accessible functions to the main program - all direct SD operations are abstracted away by the library. When using this library, #include dataRecorder.h
Dependencies: sd-driver_compatible_with_MAX32630FTHR
Fork of CircularBufferSDCardLib by
dataRecorder.cpp
- Committer:
- DVLevine
- Date:
- 2018-04-03
- Revision:
- 1:45627bbdeb69
- Parent:
- 0:ebe71c7e7854
- Child:
- 2:c2cfb0ebc3bd
File content as of revision 1:45627bbdeb69:
#include "dataRecorder.h" /* CONSTRUCTOR*/ DataRecorder::DataRecorder(){ //Initialize SDCard Reader Class m_saveBuddy = new SDCardReader(); //Initialize data quantity as 0 m_data_quantity = 0; }; /* PUBLIC METHODS */ int DataRecorder::getQuantityStored(){ return m_data_quantity; } uint16_t DataRecorder::popLastDataPoint(){ return m_buf_data.pop(); } uint32_t DataRecorder::popLastTimeStamp(){ return m_buf_timestamp.pop(); } void DataRecorder::logDistancePoint(uint16_t value){ m_buf_data.push(value); } void DataRecorder::logTimeStamp(uint32_t value){ m_buf_timestamp.push(value); } /** Save logged data to SD card **/ void DataRecorder::saveLoggedData(string filename){ //iterate over buffer and use the sd card commands } //saves buffer to sd card and clears it void DataRecorder::saveLoggedDataAndClearBuffer(string filename){ saveLoggedData(filename); // then eraseBuffers(); } /* PRIVATE METHODS */ //private buffer load in method void DataRecorder::pushEleToBuffer(uint16_t inputVal){ buf_distance.push(inputVal); // while (!buf.full()) { // buf.push(inputVal); // } } uint8_t* DataRecorder::getDistanceBlock(){ return blockDistance; } int DataRecorder::getDistanceDataLength(){ return blockDistance_Index; }; //writes input value to buffer void DataRecorder::LogDistancePoint(uint16_t value){ buf_distance.push(value); savePoint(value); } void DataRecorder::savePoint(uint16_t value){ string yo = SSTR(value); int n = yo.length(); // declaring character array char char_array[n+1]; // copying the contents of the // string to char array strcpy(char_array, yo.c_str()); int counter = 0; for (int i=blockDistance_Index; i<blockDistance_Index+n; i++){ blockDistance[i] = char_array[counter]; //printf("%i\n",i); //printf("%c\n",blockDistance[i]); counter++; } blockDistance_Index = blockDistance_Index+n; //add separator blockDistance[blockDistance_Index] = ' '; blockDistance_Index++; //buf.push(char_array[i]); //buf_distance } void DataRecorder::savePoint(uint16_t value); void DataRecorder::pushEleToBuffer(uint16_t);