Alix Germany / Mbed OS Coursework_Version_8

Dependencies:   BMP280 ELEC350-Practicals-FZ429 TextLCD BME280 ntp-client

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Sampler.hpp Source File

Sampler.hpp

00001 #ifndef _SAMPLER_
00002 #define _SAMPLER_
00003 #include "mbed.h"
00004 #include "LCD.hpp"
00005 #include "SerialComms.hpp"
00006 #include "sample_hardware.hpp"
00007 #include "SDcard.hpp"
00008 #define Activate_Flag 1
00009 
00010 class Sampler
00011 {
00012 private:
00013     
00014 public: 
00015     EventQueue SAMP_Queue;                  //Initialise the EventQueue
00016 
00017     void publishSample()
00018     {
00019         sample_message message = getData();
00020         m_oDisplay.LCD_Queue.call(&m_oDisplay, &LCD_Data::update_sensor_info, message); //Send sensor information to LCD via putting update_sensor_info function onto LCD queue with structure as input
00021         m_oSerial.SERIAL_Queue.call(&m_oSerial, &Serialcomms::setsampledata, message);  //Send sensor information to Serial via putting setsampledata function onto Serial queue with structure as input
00022         m_oNet.Network_Queue.call(&m_oNet, &Network::update_sensor_info, message);  //Send sensor information to Network via putting update_sensor_info function onto Network queue with structure as input
00023         m_oSD.SDcard_Queue.call(&m_oSD, &SDcard::update_sensor_info, message);  //Send sensor information to SD card via putting update_sensor_info function onto SD card queue with structure as input
00024     }
00025     
00026     sample_message getData()
00027     {       
00028         float temp = sensor.getTemperature();
00029         float pressure = sensor.getPressure();
00030         float LDR = adcIn.read()*4095;
00031         #ifdef BME
00032         float humidity = sensor.getHumidity();
00033         #endif
00034         sample_message msg; // Define instance of message structure
00035         msg.temp = temp;
00036         msg.pressure = pressure;
00037         msg.ldr = LDR;
00038         return msg;
00039     }
00040     
00041     void updateTimeData();
00042 
00043     Sampler()   //Constructor 
00044     {
00045     }
00046     ~Sampler() //Destructor - should the instance go out of scope, this is called
00047     {
00048     }
00049 };
00050 #endif