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 01:40:42 2016 +0000
Parent:
1:e0fc716e2394
Child:
3:8ace1992bc93
Commit message:
Actually working RGB_test program

Changed in this revision

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/SDSave.cpp	Sat Mar 12 00:01:03 2016 +0000
+++ b/SDSave.cpp	Sat Mar 12 01:40:42 2016 +0000
@@ -1,7 +1,7 @@
 
 #include "SDFileSystem.h"
 #include "mbed.h"
-Serial pc(USBTX, USBRX);
+extern Serial pc;
 FILE *fp;
 SDFileSystem fs(PTE3,PTE1,PTE2,PTE4,"fs");//SDFileSystem object
 
@@ -10,7 +10,7 @@
     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)");
+        fprintf(fp, "Time (s)\t temperature (c)\t UV (mW/cm2)\t red (mW/cm2)\t green (mW/cm2)\t blue (mW/cm2)\n\r");
 }
 
 void createDataFile_testRGB() {
@@ -18,24 +18,23 @@
     if (fp == NULL) {
         pc.printf("Failed to open the file.\n\r");
     }
-    fprintf(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)\n\r");
 }
+
 void writeData(float time, float temp, float uv, uint16_t red, uint16_t green, uint16_t 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 %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
-    else
-        return true;
+bool mountSDCard() {
+    bool mountFailure;
+    mountFailure = fs.mount();
+    return mountFailure;
 }
 
 void closeDataFile() {
--- a/SDSave.h	Sat Mar 12 00:01:03 2016 +0000
+++ b/SDSave.h	Sat Mar 12 01:40:42 2016 +0000
@@ -6,6 +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();
+bool mountSDCard();
 
 #endif
--- a/main.cpp	Sat Mar 12 00:01:03 2016 +0000
+++ b/main.cpp	Sat Mar 12 01:40:42 2016 +0000
@@ -6,23 +6,37 @@
 
 
 Timer t;
+DigitalOut ledBlue(LED_BLUE);
+DigitalOut ledRed(LED_RED);
+Serial pc(USBTX,USBRX);
 
 int main() {//main function, calls other files to move temp,RGB,PV,UV all to one managable function
     float lastTime = 0;
     float interval = 0.5;
+    ledRed = 0;
+    ledBlue = 1;
+    wait(0.5);
+    RGB_init();
     t.start();
-    if (mountFailure()) {
+    pc.printf("The timer has started\n\r");
+    if (mountSDCard()) {
         return -1; //end program with error status
     }
+    pc.printf("The SD card is mounted\n\r");
+    createDataFile_testRGB();
     uint16_t rgb[3];
-    while (t.read()>60) {
-      if (t.read()>lastTime+interval)  {
+    ledRed = 1;
+    while (t.read()<60) {
+        if (t.read()>(lastTime+interval))  {
           lastTime=t.read();
           get_rgb(rgb);
+          pc.printf("t = %.2f \t red = %d \t green = %d\r\n",lastTime,rgb[0],rgb[1]);
           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
         }
     }
     closeDataFile();
+    ledBlue = 0;
+    while (true) {};
 } 
       
\ No newline at end of file