program for final combination of working pieces
Dependencies: SDFileSystem TMP102 mbed ISL29125
Fork of TEMP_Test by
SDSave.cpp@4:4b67d7667474, 2016-03-16 (annotated)
- Committer:
- tdale19
- Date:
- Wed Mar 16 21:56:06 2016 +0000
- Revision:
- 4:4b67d7667474
- Parent:
- 2:04c2f253ec87
- Child:
- 7:6becc29457ce
First test of Temp sensors
Who changed what in which revision?
User | Revision | Line number | New 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 | 4:4b67d7667474 | 23 | void writeData(uint16_t time, float temp, float uv, uint16_t red, uint16_t green, uint16_t blue) |
Jeriah | 0:547856de255b | 24 | { |
Jeriah | 1:e0fc716e2394 | 25 | fprintf(fp, "%.2f \t %.2f \t %.2f \t %d \t %d \t %d\n\r", time, temp, uv, red, green, blue); |
Jeriah | 0:547856de255b | 26 | } |
Jeriah | 0:547856de255b | 27 | |
tdale19 | 4:4b67d7667474 | 28 | void writeData_testTEMP(uint16_t time, float outside, float inside, float panel) { |
Jeriah | 0:547856de255b | 29 | //output values for each |
tdale19 | 4:4b67d7667474 | 30 | fprintf(fp, "%.2f \t %d \t %d \t %d\n\r", time, outside, inside, panel); |
tdale19 | 4:4b67d7667474 | 31 | } |
tdale19 | 4:4b67d7667474 | 32 | |
tdale19 | 4:4b67d7667474 | 33 | void closeDataFile() { |
tdale19 | 4:4b67d7667474 | 34 | fclose(fp); |
tdale19 | 4:4b67d7667474 | 35 | fs.unmount(); |
Jeriah | 0:547856de255b | 36 | } |
Jeriah | 1:e0fc716e2394 | 37 | |
Jeriah | 2:04c2f253ec87 | 38 | bool mountSDCard() { |
Jeriah | 2:04c2f253ec87 | 39 | bool mountFailure; |
Jeriah | 2:04c2f253ec87 | 40 | mountFailure = fs.mount(); |
Jeriah | 2:04c2f253ec87 | 41 | return mountFailure; |
Jeriah | 0:547856de255b | 42 | } |
Jeriah | 0:547856de255b | 43 |