Repo. for the ELEC351 Coursework - Oliver Thompson

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

Committer:
O_Thom
Date:
Tue Dec 04 15:26:46 2018 +0000
Revision:
10:08c366434f2b
Parent:
9:654e14de9d74
Child:
11:b8e8630c7e3b
Serial Callbacks Included. Changing classes to access each others member functions without the use of objects.

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