![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Version 8, working version with Alix, sams and ollies code. Displays time, date and sensor info onto terminal, LCD and networking, and saves onto SD card.
Dependencies: BMP280 ELEC350-Practicals-FZ429 TextLCD BME280 ntp-client
Sampler.hpp@12:4c7eaac8ceef, 2018-12-31 (annotated)
- Committer:
- Alix955
- Date:
- Mon Dec 31 19:20:22 2018 +0000
- Revision:
- 12:4c7eaac8ceef
- Parent:
- 8:7d218affea71
Version 8, integration of Alix & Sams work with older(?) version of ollies. Displays time, date and all sensor information onto LCD, Terminal and Networking, and saves sensor info to SD card.
Who changed what in which revision?
User | Revision | Line number | New 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" |
Alix955 | 12:4c7eaac8ceef | 7 | #include "SDcard.hpp" |
O_Thom | 0:f9a18207d99c | 8 | #define Activate_Flag 1 |
O_Thom | 0:f9a18207d99c | 9 | |
O_Thom | 0:f9a18207d99c | 10 | class Sampler |
O_Thom | 0:f9a18207d99c | 11 | { |
O_Thom | 0:f9a18207d99c | 12 | private: |
O_Thom | 6:b7f6e0c0f646 | 13 | |
O_Thom | 2:38d31b2e0956 | 14 | public: |
O_Thom | 6:b7f6e0c0f646 | 15 | EventQueue SAMP_Queue; //Initialise the EventQueue |
O_Thom | 6:b7f6e0c0f646 | 16 | |
O_Thom | 3:82612f4ae4c5 | 17 | void publishSample() |
O_Thom | 3:82612f4ae4c5 | 18 | { |
O_Thom | 6:b7f6e0c0f646 | 19 | sample_message message = getData(); |
Alix955 | 12:4c7eaac8ceef | 20 | 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 |
Alix955 | 12:4c7eaac8ceef | 21 | 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 |
Alix955 | 12:4c7eaac8ceef | 22 | 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 |
Alix955 | 12:4c7eaac8ceef | 23 | 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 |
O_Thom | 3:82612f4ae4c5 | 24 | } |
O_Thom | 6:b7f6e0c0f646 | 25 | |
O_Thom | 6:b7f6e0c0f646 | 26 | sample_message getData() |
O_Thom | 6:b7f6e0c0f646 | 27 | { |
O_Thom | 5:f87129ac8bf3 | 28 | float temp = sensor.getTemperature(); |
O_Thom | 5:f87129ac8bf3 | 29 | float pressure = sensor.getPressure(); |
O_Thom | 7:8664a45f5ce1 | 30 | float LDR = adcIn.read()*4095; |
O_Thom | 5:f87129ac8bf3 | 31 | #ifdef BME |
O_Thom | 5:f87129ac8bf3 | 32 | float humidity = sensor.getHumidity(); |
O_Thom | 5:f87129ac8bf3 | 33 | #endif |
O_Thom | 6:b7f6e0c0f646 | 34 | sample_message msg; // Define instance of message structure |
O_Thom | 6:b7f6e0c0f646 | 35 | msg.temp = temp; |
O_Thom | 6:b7f6e0c0f646 | 36 | msg.pressure = pressure; |
O_Thom | 6:b7f6e0c0f646 | 37 | msg.ldr = LDR; |
O_Thom | 6:b7f6e0c0f646 | 38 | return msg; |
O_Thom | 0:f9a18207d99c | 39 | } |
O_Thom | 6:b7f6e0c0f646 | 40 | |
O_Thom | 6:b7f6e0c0f646 | 41 | void updateTimeData(); |
O_Thom | 6:b7f6e0c0f646 | 42 | |
O_Thom | 5:f87129ac8bf3 | 43 | Sampler() //Constructor |
O_Thom | 6:b7f6e0c0f646 | 44 | { |
O_Thom | 4:740cba3f2716 | 45 | } |
O_Thom | 5:f87129ac8bf3 | 46 | ~Sampler() //Destructor - should the instance go out of scope, this is called |
O_Thom | 0:f9a18207d99c | 47 | { |
O_Thom | 0:f9a18207d99c | 48 | } |
O_Thom | 5:f87129ac8bf3 | 49 | }; |
O_Thom | 5:f87129ac8bf3 | 50 | #endif |