program for final combination of working pieces

Dependencies:   SDFileSystem TMP102 mbed ISL29125

Fork of TEMP_Test by Thomas Dale

main.cpp

Committer:
Jeriah
Date:
2016-03-12
Revision:
3:8ace1992bc93
Parent:
2:04c2f253ec87
Child:
4:4b67d7667474

File content as of revision 3:8ace1992bc93:

  //Authors: Tom, Nathan, Jeriah 
#include "mbed.h"
#include "RGBSensor.h"
#include "SDFileSystem.h"
#include "SDSave.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);
    RGB_init();
    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");
    createDataFile_testRGB();
    uint16_t rgb[3];
    ledRed = 1;
    while (t.read()<60) {
        if (t.read()>(lastTime+interval))  {
          lastTime=t.read();
          get_rgb(rgb);
          pc.printf("t = %.2f \t red = %d \t green = %d\t blue = %d\r\n",lastTime,rgb[0],rgb[1]);
          writeData_testRGB(lastTime,rgb[0],rgb[1],rgb[2]);//send data to writeData in SDsave.cpp
          //we will get all rgb readings through an array, with the corresponding integers going in order red, green, blue
        }
    }
    closeDataFile();
    ledBlue = 0;
    while (true) {};
}