Time: 17:33 Date: 10/12/2017 Description: Task 1,7,8 Currently Functioning

Dependencies:   BME280 BMP280 TextLCD

Working Repository

SAMPLE.cpp

Committer:
thomasmorris
Date:
2018-01-09
Revision:
50:3d61ca637399
Parent:
48:244d6d81bb52

File content as of revision 50:3d61ca637399:

#include "SAMPLE.hpp"


void Sampling_ISR()
{
    t1.signal_set(SamplingTime);
}
void Sample_Event()//Samples the hardware and prints the result to the LCD
{
    while(1) 
    {
        Thread::signal_wait(SamplingTime);      //Set the time between samples
        if(Log_Value == 3){pc.printf("Sample Being Taken\n");} 
        Data_Active.set_temperature(sensor.getTemperature());   //Read Temperature
        Data_Active.set_pressure(sensor.getPressure());         //Read Pressure
        Data_Active.set_light(adcIn.read());                    //Read Light
        if(Log_Value == 3){pc.printf("Temp Taken: %1.1f Pressure Taken: %1.1f Light Taken: %1.1f\n",sensor.getTemperature(),sensor.getPressure(),adcIn.read());} 
        Time_Lock_Main.lock();
        time_t buffer_time = time(NULL);        
        Time_Lock_Main.unlock();

        Data_Active.set_time(buffer_time);

        Red_led.flash(0.02);//ahh he saved everyone of us
        Write_Pointer = Write_Data(Data_Active,Write_Pointer);
        t1.signal_set(NotSamplingTime);
        if(Log_Value == 3){pc.printf("New Sample avaliable\n");} 
        t2.signal_set(SD_Data_Ready);
    }
}