Version 5

Dependencies:   BMP280 TextLCD BME280

Committer:
O_Thom
Date:
Thu Nov 29 19:08:17 2018 +0000
Revision:
7:8664a45f5ce1
Parent:
6:b7f6e0c0f646
Child:
8:7d218affea71
Simple serial tested -> Working Correctly.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
O_Thom 5:f87129ac8bf3 1 #ifndef _SAMPLER_
O_Thom 5:f87129ac8bf3 2 #define _SAMPLER_
O_Thom 0:f9a18207d99c 3 #include "mbed.h"
O_Thom 5:f87129ac8bf3 4 #include "LCD.hpp"
O_Thom 7:8664a45f5ce1 5 #include "SerialComms.hpp"
O_Thom 6:b7f6e0c0f646 6 #include "sample_hardware.hpp"
O_Thom 0:f9a18207d99c 7 #define Activate_Flag 1
O_Thom 0:f9a18207d99c 8
O_Thom 0:f9a18207d99c 9 class Sampler
O_Thom 0:f9a18207d99c 10 {
O_Thom 0:f9a18207d99c 11 private:
O_Thom 6:b7f6e0c0f646 12
O_Thom 2:38d31b2e0956 13 public:
O_Thom 6:b7f6e0c0f646 14 EventQueue SAMP_Queue; //Initialise the EventQueue
O_Thom 6:b7f6e0c0f646 15
O_Thom 3:82612f4ae4c5 16 void publishSample()
O_Thom 3:82612f4ae4c5 17 {
O_Thom 6:b7f6e0c0f646 18 sample_message message = getData();
O_Thom 6:b7f6e0c0f646 19 m_oDisplay.LCD_Queue.call(&m_oDisplay, &LCD_Data::update_sensor_info, message);
O_Thom 5:f87129ac8bf3 20 //SD_Queue.call(&m_oSD_data, &SD_Queue::update_sensor_info, sample_data, sample_data);
O_Thom 7:8664a45f5ce1 21 m_oSerial.SERIAL_Queue.call(&m_oSerial, &Serialcomms::setsampledata, message);
O_Thom 3:82612f4ae4c5 22 }
O_Thom 6:b7f6e0c0f646 23
O_Thom 6:b7f6e0c0f646 24 sample_message getData()
O_Thom 6:b7f6e0c0f646 25 {
O_Thom 5:f87129ac8bf3 26 float temp = sensor.getTemperature();
O_Thom 5:f87129ac8bf3 27 float pressure = sensor.getPressure();
O_Thom 7:8664a45f5ce1 28 float LDR = adcIn.read()*4095;
O_Thom 5:f87129ac8bf3 29 #ifdef BME
O_Thom 5:f87129ac8bf3 30 float humidity = sensor.getHumidity();
O_Thom 5:f87129ac8bf3 31 #endif
O_Thom 6:b7f6e0c0f646 32 sample_message msg; // Define instance of message structure
O_Thom 6:b7f6e0c0f646 33 msg.temp = temp;
O_Thom 6:b7f6e0c0f646 34 msg.pressure = pressure;
O_Thom 6:b7f6e0c0f646 35 msg.ldr = LDR;
O_Thom 6:b7f6e0c0f646 36 return msg;
O_Thom 0:f9a18207d99c 37 }
O_Thom 6:b7f6e0c0f646 38
O_Thom 6:b7f6e0c0f646 39 void updateTimeData();
O_Thom 6:b7f6e0c0f646 40
O_Thom 5:f87129ac8bf3 41 Sampler() //Constructor
O_Thom 6:b7f6e0c0f646 42 {
O_Thom 4:740cba3f2716 43 }
O_Thom 5:f87129ac8bf3 44 ~Sampler() //Destructor - should the instance go out of scope, this is called
O_Thom 0:f9a18207d99c 45 {
O_Thom 0:f9a18207d99c 46 }
O_Thom 5:f87129ac8bf3 47 };
O_Thom 5:f87129ac8bf3 48 #endif