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 17:39:43 2018 +0000
Revision:
11:b8e8630c7e3b
Parent:
10:08c366434f2b
Child:
16:73af0e3ddcaa
Commit before moving Serial interrupt outside of class

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