Plymouth ELEC351 Group T / Mbed OS ELEC351

Dependencies:   BME280 BMP280 TextLCD

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SAMPLE.cpp Source File

SAMPLE.cpp

00001 #include "SAMPLE.hpp"
00002 
00003 
00004 void Sampling_ISR()
00005 {
00006     t1.signal_set(SamplingTime);
00007 }
00008 void Sample_Event()//Samples the hardware and prints the result to the LCD
00009 {
00010     while(1) 
00011     {
00012         Thread::signal_wait(SamplingTime);      //Set the time between samples
00013         if(Log_Value == 3){pc.printf("Sample Being Taken\n");} 
00014         Data_Active.set_temperature(sensor.getTemperature());   //Read Temperature
00015         Data_Active.set_pressure(sensor.getPressure());         //Read Pressure
00016         Data_Active.set_light(adcIn.read());                    //Read Light
00017         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());} 
00018         Time_Lock_Main.lock();
00019         time_t buffer_time = time(NULL);        
00020         Time_Lock_Main.unlock();
00021 
00022         Data_Active.set_time(buffer_time);
00023 
00024         Red_led.flash(0.02);//ahh he saved everyone of us
00025         Write_Pointer = Write_Data(Data_Active,Write_Pointer);
00026         t1.signal_set(NotSamplingTime);
00027         if(Log_Value == 3){pc.printf("New Sample avaliable\n");} 
00028         t2.signal_set(SD_Data_Ready);
00029     }
00030 }