program for final combination of working pieces

Dependencies:   SDFileSystem TMP102 mbed ISL29125

Fork of TEMP_Test by Thomas Dale

Committer:
tdale19
Date:
Thu Mar 31 17:32:01 2016 +0000
Revision:
7:6becc29457ce
Parent:
4:4b67d7667474
Child:
8:28f8162d2929
Final Project. With working thermometers and working Solar Panels

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 }
Jeriah 2:04c2f253ec87 12 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");
Jeriah 0:547856de255b 13 }
Jeriah 0:547856de255b 14
tdale19 4:4b67d7667474 15 void createDataFile_testTEMP() {
Jeriah 0:547856de255b 16 fp = fopen("/fs/dataLog.txt", "a");// open file and prepare to write
Jeriah 0:547856de255b 17 if (fp == NULL) {
Jeriah 0:547856de255b 18 pc.printf("Failed to open the file.\n\r");
Jeriah 0:547856de255b 19 }
tdale19 4:4b67d7667474 20 fprintf(fp, "Time (s)\t outside (C)\t inside (C)\t On Panel (C)\n\r");
Jeriah 0:547856de255b 21 }
Jeriah 2:04c2f253ec87 22
tdale19 7:6becc29457ce 23 void writeData(uint16_t time, float outside, float inside, float panel, float Solar) {
Jeriah 0:547856de255b 24 //output values for each
tdale19 7:6becc29457ce 25 fprintf(fp, "temp ouside = %.2f (c) \t inside = %.2f (c) \t on panel = %.2f (c) \t solar volage = %.2f (V) \n\r", time, outside, inside, panel, Solar);
tdale19 4:4b67d7667474 26 }
tdale19 4:4b67d7667474 27
tdale19 4:4b67d7667474 28 void closeDataFile() {
tdale19 4:4b67d7667474 29 fclose(fp);
tdale19 4:4b67d7667474 30 fs.unmount();
Jeriah 0:547856de255b 31 }
Jeriah 1:e0fc716e2394 32
Jeriah 2:04c2f253ec87 33 bool mountSDCard() {
Jeriah 2:04c2f253ec87 34 bool mountFailure;
Jeriah 2:04c2f253ec87 35 mountFailure = fs.mount();
Jeriah 2:04c2f253ec87 36 return mountFailure;
Jeriah 0:547856de255b 37 }
Jeriah 0:547856de255b 38