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-03
Revision:
9:9690da23e8d7
Parent:
8:28f8162d2929
Child:
10:478e0eb37b0d

File content as of revision 9:9690da23e8d7:

#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 on panel (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 panel, float Solar, float UV, uint16_t red, uint16_t green, uint16_t blue) {
    //output values for each
    fprintf(fp, "temp ouside = %.2f (c) \t inside = %.2f (c) \t on panel = %.2f (c) \t solar volage = %.2f (V) \t UV light =%.2f \n\r", time, outside, inside, panel, Solar, UV, red, green, blue);
}

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

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