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:
Fri Mar 11 23:43:27 2016 +0000
Child:
1:e0fc716e2394
Commit message:
wrote the RGBSensor.h file for RGB_test

Changed in this revision

ISL29125.lib Show annotated file Show diff for this revision Revisions of this file
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
SDFileSystem.lib 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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ISL29125.lib	Fri Mar 11 23:43:27 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/frankvnk/code/ISL29125/#ae36914adb6d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGBSensor.cpp	Fri Mar 11 23:43:27 2016 +0000
@@ -0,0 +1,15 @@
+#include "RGBSensor.h"
+#include "ISL29125.h"
+
+// The location of the sensor on the FRDM-K64F//
+
+ISL29125 RGB_sensor(I2C_SDA,I2C_SCL);
+
+void RGB_init() {
+    RGB_sensor.RGBmode(ISL29125_RGB);
+    RGB_sensor.Range(ISL29125_10KLX);
+    RGB_sensor.Resolution(ISL29125_16BIT);
+}
+void get_rgb(uint16_t rgb[]){
+    RGB_sensor.read(ISL29125_RGB, rgb);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RGBSensor.h	Fri Mar 11 23:43:27 2016 +0000
@@ -0,0 +1,8 @@
+#ifndef RGB
+#define RGB
+#include "RGBSensor.cpp"
+
+extern ISL29125 RGB_sensor;
+void RGB_init();
+void get_rgb(uint16_t rgb[]);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem.lib	Fri Mar 11 23:43:27 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/neilt6/code/SDFileSystem/#3fa5eaf48e81
--- /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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDSave.h	Fri Mar 11 23:43:27 2016 +0000
@@ -0,0 +1,10 @@
+#ifndef SAVE
+#define SAVE
+
+void createDataFile();
+void createDataFile_testRGB();
+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();
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Mar 11 23:43:27 2016 +0000
@@ -0,0 +1,28 @@
+  //Authors: Tom, Nathan, Jeriah 
+#include "mbed.h"
+#include "RGBSensor.h"
+#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
+    float lastTime = 0;
+    float interval = 0.5;
+    t.start();
+    if (mountFailure()) {
+        return -1; //end program with error status
+    }
+    uint16_t rgb[3];
+    while (t.read()>60) {
+      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
+          //we will get all rgb readings through an array, with the corresponding integers going in order red, green, blue
+        }
+    }
+    closeDataFile();
+} 
+      
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Mar 11 23:43:27 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/252557024ec3
\ No newline at end of file