program for final combination of working pieces

Dependencies:   SDFileSystem TMP102 mbed ISL29125

Fork of TEMP_Test by Thomas Dale

Committer:
tdale19
Date:
Mon Apr 18 16:41:40 2016 +0000
Revision:
13:906a647d7bd1
Parent:
10:478e0eb37b0d
Jeriah on Tom's mbed id, fixed the sd save horizontal problem

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jeriah 0:547856de255b 1 #include "SDFileSystem.h"
Jeriah 0:547856de255b 2 #include "mbed.h"
Jeriah 2:04c2f253ec87 3 extern Serial pc;
Jeriah 0:547856de255b 4 FILE *fp;
Jeriah 1:e0fc716e2394 5 SDFileSystem fs(PTE3,PTE1,PTE2,PTE4,"fs");//SDFileSystem object
Jeriah 0:547856de255b 6
Jeriah 0:547856de255b 7 void createDataFile() {
Jeriah 0:547856de255b 8 fp = fopen("/fs/dataLog.txt", "a");// open file and prepare to write
Jeriah 0:547856de255b 9 if (fp == NULL) {
Jeriah 0:547856de255b 10 pc.printf("Failed to open the file.\n\r");
Jeriah 0:547856de255b 11 }
tdale19 13:906a647d7bd1 12 fprintf(fp, "Time (s)\t temperature outside (c)\t inside (c) \t Voltage of Panels (V) \t UV (mW/cm2)\t red (mW/cm2)\t green (mW/cm2)\t blue (mW/cm2)\n\r");
Jeriah 0:547856de255b 13 }
Jeriah 0:547856de255b 14
tdale19 13:906a647d7bd1 15 void writeData( float time, float outside, float inside, float Solar, float UV, uint16_t red, uint16_t green, uint16_t blue) {
Jeriah 0:547856de255b 16 //output values for each
tdale19 13:906a647d7bd1 17 fprintf(fp, "%.2f \t %.2f \t %.2f \t %.4f \t %.4f \t %d \t %d \t %d\n\r", time, outside, inside, Solar, UV, red, green, blue);
tdale19 4:4b67d7667474 18 }
tdale19 4:4b67d7667474 19
tdale19 4:4b67d7667474 20 void closeDataFile() {
tdale19 4:4b67d7667474 21 fclose(fp);
tdale19 4:4b67d7667474 22 fs.unmount();
Jeriah 0:547856de255b 23 }
Jeriah 1:e0fc716e2394 24
Jeriah 2:04c2f253ec87 25 bool mountSDCard() {
Jeriah 2:04c2f253ec87 26 bool mountFailure;
Jeriah 2:04c2f253ec87 27 mountFailure = fs.mount();
Jeriah 2:04c2f253ec87 28 return mountFailure;
Jeriah 0:547856de255b 29 }
Jeriah 0:547856de255b 30