![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Code for measuring the signal with a specified length and sampling rate, and saving it on a SD card.
sdcard.cpp
- Committer:
- msamadani
- Date:
- 2017-10-05
- Revision:
- 2:8c5b6522139f
- Parent:
- 0:c05b00be2229
File content as of revision 2:8c5b6522139f:
#include "sdcard.h" #include "MCIFileSystem.h" #include "mbed.h" #include <string> void saveToSD(float signal[],int sig_length,char const *filename) { printf("Saving to SD card...\n"); string str_name(filename); std::string fullname="/mci/"+str_name+".txt"; MCIFileSystem mcifs("mci", NC); FILE* File = fopen(fullname.c_str(),"w"); // open file for (int i = 0; i < sig_length; i++) { //fprintf(File,"%f %f %f %f\r\n",acc_signal_f[i],xfilt[i],xAnalytic[i],xEnv[i]); fprintf(File,"%f \r\n",signal[i]); } fclose(File); printf("Saved to SD card.\n\n"); }