SD card functionality
Dependents: ELEC350_Project2 SDcard
Diff: SDCard.cpp
- Revision:
- 7:393fa8184388
- Parent:
- 6:5646450f583b
- Child:
- 8:ee8f65745141
--- a/SDCard.cpp Sun Nov 18 15:19:36 2018 +0000 +++ b/SDCard.cpp Mon Dec 17 16:10:40 2018 +0000 @@ -1,10 +1,9 @@ #include "SDCard.hpp" - - +#include <string> void SDcard(void) { - + static time_t seconds; //REQUIRES IMPROVEMENTS, SEE ONENOTE @@ -21,20 +20,26 @@ fs = new FATFileSystem("sd", &sd); //Open to WRITE - fp = fopen("/sd/q.csv","a"); + + char fileDate[30]; + seconds = time(NULL); + timeData = localtime(&seconds); + set_time(mktime(timeData)); + strftime(fileDate, 30, "sd/sampledata/%d_%m_%y.csv", timeData); + + fp = fopen(fileDate,"a"); if (fp == NULL) { error("Could not open file for write\n"); lcd.cls(); lcd.printf("CANNOT OPEN FILE\n\n"); errorCode(FATAL); - } - + } fclose(fp); //Last message before sampling begins lcd.cls(); - lcd.printf("READY\n\n"); + lcd.printf("SYSTEM READY\n\n"); @@ -87,4 +92,5 @@ { //Signal that the SD thread is still alive //puts("SD THREAD ALIVE\n"); -} \ No newline at end of file +} +