Version 5

Dependencies:   BMP280 TextLCD BME280

Committer:
O_Thom
Date:
Thu Nov 29 16:08:28 2018 +0000
Revision:
5:f87129ac8bf3
Parent:
4:740cba3f2716
Child:
6:b7f6e0c0f646
Commit before change from sample message class to typedef struct

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 5:f87129ac8bf3 3 #include "message.hpp"
O_Thom 0:f9a18207d99c 4 #include "mbed.h"
O_Thom 5:f87129ac8bf3 5 #include "LCD.hpp"
O_Thom 0:f9a18207d99c 6 #define Activate_Flag 1
O_Thom 0:f9a18207d99c 7
O_Thom 5:f87129ac8bf3 8 EventQueue SAMP_Queue; //create an event queue for main
O_Thom 2:38d31b2e0956 9
O_Thom 0:f9a18207d99c 10 class Sampler
O_Thom 0:f9a18207d99c 11 {
O_Thom 0:f9a18207d99c 12 private:
O_Thom 5:f87129ac8bf3 13 EventQueue sampEQueue; //Initialise the EventQueue
O_Thom 2:38d31b2e0956 14 public:
O_Thom 3:82612f4ae4c5 15 void publishSample()
O_Thom 3:82612f4ae4c5 16 {
O_Thom 5:f87129ac8bf3 17 getData();
O_Thom 5:f87129ac8bf3 18 m_oDisplay.LCD_Queue.call(&m_oDisplay, &LCD_Data::update_sensor_info, sample);
O_Thom 5:f87129ac8bf3 19 //SD_Queue.call(&m_oSD_data, &SD_Queue::update_sensor_info, sample_data, sample_data);
O_Thom 5:f87129ac8bf3 20 //SERIAL_Queue.call(&m_oSERIAL_data, &SERIAL_Queue::update_sensor_info, sample_data, sample_data);
O_Thom 3:82612f4ae4c5 21 }
O_Thom 5:f87129ac8bf3 22 void getData()
O_Thom 1:f89c930c6491 23 {
O_Thom 5:f87129ac8bf3 24 int sw1State = SW1.read();
O_Thom 5:f87129ac8bf3 25 int sw2State = SW2.read();
O_Thom 5:f87129ac8bf3 26 float temp = sensor.getTemperature();
O_Thom 5:f87129ac8bf3 27 float pressure = sensor.getPressure();
O_Thom 5:f87129ac8bf3 28 #ifdef BME
O_Thom 5:f87129ac8bf3 29 float humidity = sensor.getHumidity();
O_Thom 5:f87129ac8bf3 30 #endif
O_Thom 5:f87129ac8bf3 31 sample.temp = temp;
O_Thom 5:f87129ac8bf3 32 sample.pressure = pressure;
O_Thom 5:f87129ac8bf3 33 sample.sw1State = sw1State;
O_Thom 5:f87129ac8bf3 34 sample.swState = sw1State;
O_Thom 0:f9a18207d99c 35 }
O_Thom 5:f87129ac8bf3 36 Sampler() //Constructor
O_Thom 5:f87129ac8bf3 37 {
O_Thom 4:740cba3f2716 38 }
O_Thom 5:f87129ac8bf3 39 ~Sampler() //Destructor - should the instance go out of scope, this is called
O_Thom 0:f9a18207d99c 40 {
O_Thom 0:f9a18207d99c 41 }
O_Thom 5:f87129ac8bf3 42 };
O_Thom 5:f87129ac8bf3 43 #endif