program for final combination of working pieces

Dependencies:   SDFileSystem TMP102 mbed ISL29125

Fork of TEMP_Test by Thomas Dale

main.cpp

Committer:
tdale19
Date:
2016-04-03
Revision:
9:9690da23e8d7
Parent:
8:28f8162d2929
Child:
10:478e0eb37b0d

File content as of revision 9:9690da23e8d7:

  //Authors: Tom, Nathan, Jeriah  
#include "mbed.h"
#include "TEMPSensor.h"
#include "SDFileSystem.h"
#include "SDSave.h"
#include "SolarPanel.h"
#include "UVSensor.h"
#include "RGBSensor.h"

Timer t;
DigitalOut ledBlue(LED_BLUE);
DigitalOut ledRed(LED_RED);
Serial pc(USBTX,USBRX);

int main() {//main function, calls other files to move temp,RGB,PV,UV all to one managable function
    float lastTime = 0;
    float interval = 0.5;
    ledRed = 0;
    ledBlue = 1;
    wait(0.5);
    t.start();
    pc.printf("The timer has started\n\r");
    if (mountSDCard()) {
        return -1; //end program with error status
    }
    pc.printf("The SD card is mounted\n\r");
    
    uint16_t rgb[3];
    ledRed = 1;
    createDataFile();
    while (t.read()<60) {
        if (t.read()>(lastTime+interval))  {
          lastTime=t.read();
          pc.printf("temp ouside = %.2f (c) \t inside = %.2f (c) \t on panel = %.2f (c) \t solar volage = %.2f (V) \t UV light =%.2f RGB Values:  red = %d \t green = %d\t blue = %d\r\n" ,get_outsideTemp(),get_insideTemp(),get_panelTemp(),get_solar(),get_UV(),rgb[0],rgb[1],rgb[2]);//prints titles and data of Temp readings
          writeData(lastTime,get_outsideTemp(),get_insideTemp(),get_panelTemp(),get_solar(),get_UV(),rgb[0],rgb[1],rgb[2]);//send data to writeData in SDsave.cpp
          
        }
    }
    closeDataFile();
    ledBlue = 0;
    while (true) {};
}