program for final combination of working pieces

Dependencies:   SDFileSystem TMP102 mbed ISL29125

Fork of TEMP_Test by Thomas Dale

SDSave.cpp

Committer:
tdale19
Date:
2016-04-18
Revision:
13:906a647d7bd1
Parent:
10:478e0eb37b0d

File content as of revision 13:906a647d7bd1:

#include "SDFileSystem.h"
#include "mbed.h"
extern Serial pc;
FILE *fp;
SDFileSystem fs(PTE3,PTE1,PTE2,PTE4,"fs");//SDFileSystem object

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 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");
}

void writeData( float time, float outside, float inside, float Solar, float UV, uint16_t red, uint16_t green, uint16_t blue) {
    //output values for each
    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);
}

void closeDataFile() {
    fclose(fp);
    fs.unmount();
}

bool mountSDCard() {
    bool mountFailure;
    mountFailure = fs.mount();
    return mountFailure;
}