Test temperature for the near space lab

Dependencies:   SDFileSystem mbed TEMP_Test

Dependents:   TEMP_Test

Fork of RGB_Test by Jeriah Bankson

Committer:
Jeriah
Date:
Sat Mar 12 01:40:42 2016 +0000
Revision:
2:04c2f253ec87
Parent:
1:e0fc716e2394
Child:
4:4b67d7667474
Actually working RGB_test program

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jeriah 0:547856de255b 1
Jeriah 0:547856de255b 2 #include "SDFileSystem.h"
Jeriah 0:547856de255b 3 #include "mbed.h"
Jeriah 2:04c2f253ec87 4 extern Serial pc;
Jeriah 0:547856de255b 5 FILE *fp;
Jeriah 1:e0fc716e2394 6 SDFileSystem fs(PTE3,PTE1,PTE2,PTE4,"fs");//SDFileSystem object
Jeriah 0:547856de255b 7
Jeriah 0:547856de255b 8 void createDataFile() {
Jeriah 0:547856de255b 9 fp = fopen("/fs/dataLog.txt", "a");// open file and prepare to write
Jeriah 0:547856de255b 10 if (fp == NULL) {
Jeriah 0:547856de255b 11 pc.printf("Failed to open the file.\n\r");
Jeriah 0:547856de255b 12 }
Jeriah 2:04c2f253ec87 13 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 14 }
Jeriah 0:547856de255b 15
Jeriah 0:547856de255b 16 void createDataFile_testRGB() {
Jeriah 0:547856de255b 17 fp = fopen("/fs/dataLog.txt", "a");// open file and prepare to write
Jeriah 0:547856de255b 18 if (fp == NULL) {
Jeriah 0:547856de255b 19 pc.printf("Failed to open the file.\n\r");
Jeriah 0:547856de255b 20 }
Jeriah 2:04c2f253ec87 21 fprintf(fp, "Time (s)\t red (mW/cm2)\t green (mW/cm2)\t blue (mW/cm2)\n\r");
Jeriah 0:547856de255b 22 }
Jeriah 2:04c2f253ec87 23
Jeriah 1:e0fc716e2394 24 void writeData(float time, float temp, float uv, uint16_t red, uint16_t green, uint16_t blue)
Jeriah 0:547856de255b 25 {
Jeriah 1:e0fc716e2394 26 fprintf(fp, "%.2f \t %.2f \t %.2f \t %d \t %d \t %d\n\r", time, temp, uv, red, green, blue);
Jeriah 0:547856de255b 27 }
Jeriah 0:547856de255b 28
Jeriah 0:547856de255b 29 void writeData_testRGB(float time, uint16_t red, uint16_t green, uint16_t blue) {
Jeriah 0:547856de255b 30 //output values for each
Jeriah 1:e0fc716e2394 31 fprintf(fp, "%.2f \t %d \t %d \t %d\n\r", time, red, green, blue);
Jeriah 0:547856de255b 32 }
Jeriah 1:e0fc716e2394 33
Jeriah 2:04c2f253ec87 34 bool mountSDCard() {
Jeriah 2:04c2f253ec87 35 bool mountFailure;
Jeriah 2:04c2f253ec87 36 mountFailure = fs.mount();
Jeriah 2:04c2f253ec87 37 return mountFailure;
Jeriah 0:547856de255b 38 }
Jeriah 0:547856de255b 39
Jeriah 0:547856de255b 40 void closeDataFile() {
Jeriah 0:547856de255b 41 fclose(fp);
Jeriah 1:e0fc716e2394 42 fs.unmount();
Jeriah 0:547856de255b 43 }