Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: sd-driver_compatible_with_MAX32630FTHR
Fork of CircularBufferSDCardLib by
Diff: dataRecorder.cpp
- Revision:
- 3:df8fb1b5d868
- Parent:
- 2:c2cfb0ebc3bd
- Child:
- 5:0a4ff027086c
--- a/dataRecorder.cpp Wed Apr 04 16:17:34 2018 -0400
+++ b/dataRecorder.cpp Wed Apr 04 17:15:36 2018 -0400
@@ -1,14 +1,15 @@
#include "dataRecorder.h"
/* CONSTRUCTOR*/
+DataRecorder::DataRecorder(){
-DataRecorder::DataRecorder(){
+ DataRecorder();
//Initialize SDCard Reader Class
m_saveBuddy = new SDCardReader();
//Initialize data quantity as 0
m_data_quantity = 0;
-};
+}
/* PUBLIC METHODS */
@@ -27,8 +28,10 @@
if (m_data_quantity<0){
m_data_quantity=0;
}
+ uint16_t poppedData;
if(!m_buf_data.empty()){
- return m_buf_data.pop();
+ m_buf_data.pop(poppedData);
+ return poppedData;
}else{
return (uint16_t)0;
}
@@ -41,8 +44,10 @@
m_time_quantity=0;
}
- if(!m_buf_time.empty()){
- return m_buf_time.pop();
+ uint32_t poppedData;
+ if(!m_buf_timestamp.empty()){
+ m_buf_timestamp.pop(poppedData);
+ return poppedData;
}else{
return (uint16_t)0;
}
@@ -68,15 +73,17 @@
/** Save logged data to SD card **/
void DataRecorder::saveLoggedData(string filename){
//iterate over buffer and use the sd card commands
+ int numPoints = m_data_quantity; //add check for timestamps
+
int indexArr[m_data_quantity];
- for (int i = indexArr.size-1; i >=0 ; i--){
+ for (int i = m_data_quantity; i >=0 ; i--){
indexArr[i] = i;
}
uint32_t timeArr[m_time_quantity];
uint16_t* allDataArr[m_data_quantity];
- for (int i = 0; i < allDataArr.size; i++){
+ for (int i = 0; i < numPoints; i++){
uint16_t dataEntry[1];
dataEntry[1] = popLastDataPoint();
allDataArr[i] = dataEntry;
