Test temperature for the near space lab

Dependencies:   SDFileSystem mbed TEMP_Test

Dependents:   TEMP_Test

Fork of RGB_Test by Jeriah Bankson

Revision:
0:547856de255b
Child:
1:e0fc716e2394
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDSave.cpp	Fri Mar 11 23:43:27 2016 +0000
@@ -0,0 +1,49 @@
+
+#include "SDFileSystem.h"
+#include "mbed.h"
+Serial pc(USBTX, USBRX);
+FILE *fp;
+
+void createDataFile() {
+    fp = fopen("/fs/dataLog.txt", "a");// open file and prepare to write
+    if (fp == NULL) {
+        pc.printf("Failed to open the file.\n\r");
+    }
+        fprintf(fp, "Time (s)\t temperature (c)\t UV (mW/cm2)\t red (mW/cm2)\t green (mW/cm2)\t blue (mW/cm2)");
+}
+
+void createDataFile_testRGB() {
+    fp = fopen("/fs/dataLog.txt", "a");// open file and prepare to write
+    if (fp == NULL) {
+        pc.printf("Failed to open the file.\n\r");
+    }
+    fprint(fp, "Time (s)\t red (mW/cm2)\t green (mW/cm2)\t blue (mW/cm2)");
+}
+void writeData(uint16_t time, uint16_t temp, uint16_t uv, uint16_t red, uint16_t green, uint16_t blue)
+{
+    fp = fopen("/fs/dataLog.txt", "w"); //open file and prepare to write
+    if (fp == NULL) {
+        pc.printf("Failed to open the file.\n\r");
+        }
+    if(time < .6) {//if it is the first time being called then output data title
+        fprint(fp, "Time (s)\t temperature (c)\t UV (mW/cm2)\t red (mW/cm2)\t green (mW/cm2)\t blue (mW/cm2)");
+        }
+    //output values for each
+    fprintf(fp, "%.2f \t %.2f\n\r", time, temp, uv, red, green, blue);
+}
+
+void writeData_testRGB(float time, uint16_t red, uint16_t green, uint16_t blue) {
+    
+    //output values for each
+    fprintf(fp, "%.2f \t %.2f\n\r", time, temp, uv, red, green, blue);
+}
+bool mountFailure(){
+    if (fs.mount !=0) return false;//if mount has been accomplished return false
+    //remember to change if statment's true to a correct mount failure input else return true;
+    //if mount has failed return true
+}
+
+void closeDataFile() {
+    fclose(fp);
+    sd.unmount();
+}
\ No newline at end of file