program for final combination of working pieces

Dependencies:   SDFileSystem TMP102 mbed ISL29125

Fork of TEMP_Test by Thomas Dale

Files at this revision

API Documentation at this revision

Comitter:
Jeriah
Date:
Sat Mar 12 00:01:03 2016 +0000
Parent:
0:547856de255b
Child:
2:04c2f253ec87
Commit message:
Final edition of RGB_test program

Changed in this revision

RGBSensor.cpp Show annotated file Show diff for this revision Revisions of this file
RGBSensor.h Show annotated file Show diff for this revision Revisions of this file
SDSave.cpp Show annotated file Show diff for this revision Revisions of this file
SDSave.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/RGBSensor.cpp	Fri Mar 11 23:43:27 2016 +0000
+++ b/RGBSensor.cpp	Sat Mar 12 00:01:03 2016 +0000
@@ -11,5 +11,5 @@
     RGB_sensor.Resolution(ISL29125_16BIT);
 }
 void get_rgb(uint16_t rgb[]){
-    RGB_sensor.read(ISL29125_RGB, rgb);
+    RGB_sensor.Read(ISL29125_RGB, rgb);
 }
--- a/RGBSensor.h	Fri Mar 11 23:43:27 2016 +0000
+++ b/RGBSensor.h	Sat Mar 12 00:01:03 2016 +0000
@@ -1,8 +1,10 @@
-#ifndef RGB
-#define RGB
-#include "RGBSensor.cpp"
+#include "mbed.h"
 
-extern ISL29125 RGB_sensor;
+#ifndef RGBSensor   
+#define RGBSensor
+
+
 void RGB_init();
 void get_rgb(uint16_t rgb[]);
 
+#endif
--- a/SDSave.cpp	Fri Mar 11 23:43:27 2016 +0000
+++ b/SDSave.cpp	Sat Mar 12 00:01:03 2016 +0000
@@ -3,6 +3,7 @@
 #include "mbed.h"
 Serial pc(USBTX, USBRX);
 FILE *fp;
+SDFileSystem fs(PTE3,PTE1,PTE2,PTE4,"fs");//SDFileSystem object
 
 void createDataFile() {
     fp = fopen("/fs/dataLog.txt", "a");// open file and prepare to write
@@ -17,33 +18,27 @@
     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)");
+    fprintf(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)
+void writeData(float time, float temp, float 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);
+    fprintf(fp, "%.2f \t %.2f \t %.2f \t %d \t %d \t %d\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);
+    fprintf(fp, "%.2f \t %d \t %d \t %d\n\r", time, 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
+    if (fs.mount() !=0)
+        return false;//if mount has been accomplished return false
+    else
+        return true;
 }
 
 void closeDataFile() {
     fclose(fp);
-    sd.unmount();
+    fs.unmount();
 }
\ No newline at end of file
--- a/SDSave.h	Fri Mar 11 23:43:27 2016 +0000
+++ b/SDSave.h	Sat Mar 12 00:01:03 2016 +0000
@@ -6,5 +6,6 @@
 void writeData(uint16_t time, uint16_t temp, uint16_t uv, uint16_t red, uint16_t green, uint16_t blue);
 void writeData_testRGB(float time, uint16_t red, uint16_t green, uint16_t blue);
 void closeDataFile();
+bool mountFailure();
 
 #endif
--- a/main.cpp	Fri Mar 11 23:43:27 2016 +0000
+++ b/main.cpp	Sat Mar 12 00:01:03 2016 +0000
@@ -4,7 +4,7 @@
 #include "SDFileSystem.h"
 #include "SDSave.h"
 
-SDFileSystem fs(PTE3,PTE1,PTE2,PTE4,"fs");//SDFileSystem object
+
 Timer t;
 
 int main() {//main function, calls other files to move temp,RGB,PV,UV all to one managable function
@@ -19,7 +19,7 @@
       if (t.read()>lastTime+interval)  {
           lastTime=t.read();
           get_rgb(rgb);
-          writeDate_testRGB(lastTime,rgb[0],rgb[1],rgb[2]);//send data to writeData in SDsave.cpp
+          writeData_testRGB(lastTime,rgb[0],rgb[1],rgb[2]);//send data to writeData in SDsave.cpp
           //we will get all rgb readings through an array, with the corresponding integers going in order red, green, blue
         }
     }