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 Daniel Levine

Revision:
11:c70e8305ddd7
Parent:
10:f5fdba83488a
Child:
12:c09a50d9469a
--- a/dataRecorder.cpp	Sat Apr 07 04:57:09 2018 +0000
+++ b/dataRecorder.cpp	Tue Apr 10 23:49:52 2018 -0400
@@ -7,6 +7,9 @@
 
   //Initialize data quantity as 0
   m_data_quantity = 0;
+
+  //initialize num fields
+  m_numDataFields = numDataFields;
 }
 
 
@@ -92,8 +95,10 @@
 
   printf("before logging, data quantity is %i\n",m_data_quantity);
   
-  int numPoints = m_data_quantity; //add check for timestamps
+  int numPoints = m_data_quantity/m_numDataFields; //add check for timestamps
 
+  printf("numPoints %i \n ",numPoints);
+  
   vector<int> indexArr(numPoints);
   //int indexArr[numPoints];
   
@@ -103,6 +108,7 @@
   }
 
   vector<uint32_t> timeArr(numPoints); 
+  vector<uint16_t> dataEntry(m_numDataFields); //created before loop to see if prevent data collision
   vector<vector <uint16_t> > allDataArr(numPoints); 
   
   //uint32_t timeArr[numPoints];
@@ -111,14 +117,15 @@
   for (int i = 0; i < numPoints; i++){
     //time aggregation
     timeArr[i] = popLastTimeStamp(); 
-    
+      
     //data aggregation
-    vector<uint16_t> dataEntry(m_numDataFields);
+    //  vector<uint16_t> dataEntry(m_numDataFields);
     for (int j=0;j<m_numDataFields;j++){
-        dataEntry[i] = popLastDataPoint(); 
+        dataEntry[j] = popLastDataPoint();
+	printf("%i\n",dataEntry[j]);
     }
     allDataArr[i] = dataEntry;
-    printf("%i\n",static_cast<int>(dataEntry[0]));
+    // printf("%i\n",static_cast<int>(dataEntry[0]));
   }
 
   printf("Before launch! size test %i \n",indexArr.size());