Alix & Sam's combined versions
Dependencies: BMP280 ELEC350-Practicals-FZ429 TextLCD BME280 ntp-client
SerialComms.hpp@8:7d218affea71, 2018-11-30 (annotated)
- Committer:
- O_Thom
- Date:
- Fri Nov 30 13:15:30 2018 +0000
- Revision:
- 8:7d218affea71
- Parent:
- 7:8664a45f5ce1
Updated. 30/11/2018;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
O_Thom | 6:b7f6e0c0f646 | 1 | #include "mbed.h" |
O_Thom | 6:b7f6e0c0f646 | 2 | |
O_Thom | 6:b7f6e0c0f646 | 3 | class Serialcomms |
O_Thom | 1:f89c930c6491 | 4 | { |
O_Thom | 1:f89c930c6491 | 5 | private: |
O_Thom | 8:7d218affea71 | 6 | float fTemp; //current temperature of sensor |
O_Thom | 8:7d218affea71 | 7 | float fPressure; //current pressure of sensor |
O_Thom | 8:7d218affea71 | 8 | float fLDR; //current light level from LDR |
O_Thom | 6:b7f6e0c0f646 | 9 | |
O_Thom | 1:f89c930c6491 | 10 | public: |
O_Thom | 6:b7f6e0c0f646 | 11 | EventQueue SERIAL_Queue; //Initialise the EventQueue |
O_Thom | 6:b7f6e0c0f646 | 12 | |
O_Thom | 6:b7f6e0c0f646 | 13 | void setsampledata(sample_message msg) // Update internal values |
O_Thom | 6:b7f6e0c0f646 | 14 | { |
O_Thom | 6:b7f6e0c0f646 | 15 | fTemp = msg.temp; |
O_Thom | 6:b7f6e0c0f646 | 16 | fPressure = msg.pressure; |
O_Thom | 6:b7f6e0c0f646 | 17 | fLDR = msg.ldr; |
O_Thom | 6:b7f6e0c0f646 | 18 | } |
O_Thom | 6:b7f6e0c0f646 | 19 | |
O_Thom | 6:b7f6e0c0f646 | 20 | sample_message getsampledata() // Retrieves the data |
O_Thom | 6:b7f6e0c0f646 | 21 | { |
O_Thom | 6:b7f6e0c0f646 | 22 | sample_message msg; |
O_Thom | 6:b7f6e0c0f646 | 23 | msg.temp = fTemp; |
O_Thom | 6:b7f6e0c0f646 | 24 | msg.pressure = fPressure; |
O_Thom | 6:b7f6e0c0f646 | 25 | msg.ldr = fLDR; |
O_Thom | 6:b7f6e0c0f646 | 26 | return msg; |
O_Thom | 6:b7f6e0c0f646 | 27 | } |
O_Thom | 6:b7f6e0c0f646 | 28 | |
O_Thom | 6:b7f6e0c0f646 | 29 | void updateTerminal() // Print internal values of sensors |
O_Thom | 7:8664a45f5ce1 | 30 | { |
O_Thom | 6:b7f6e0c0f646 | 31 | printf("======= Sensor Update ========\n"); |
O_Thom | 6:b7f6e0c0f646 | 32 | printf("Temperate: %5.2f\n", fTemp); |
O_Thom | 6:b7f6e0c0f646 | 33 | printf("Pressure: %5.2f\n", fPressure); |
O_Thom | 6:b7f6e0c0f646 | 34 | printf("Light Level: %5.2f\n", fLDR); |
O_Thom | 6:b7f6e0c0f646 | 35 | printf("==============================\n"); |
O_Thom | 6:b7f6e0c0f646 | 36 | } |
O_Thom | 1:f89c930c6491 | 37 | |
O_Thom | 6:b7f6e0c0f646 | 38 | void updateTimeDate() |
O_Thom | 6:b7f6e0c0f646 | 39 | { |
O_Thom | 6:b7f6e0c0f646 | 40 | } |
O_Thom | 6:b7f6e0c0f646 | 41 | |
O_Thom | 6:b7f6e0c0f646 | 42 | Serialcomms() |
O_Thom | 6:b7f6e0c0f646 | 43 | { |
O_Thom | 6:b7f6e0c0f646 | 44 | printf("Serial Comms Initialised\n"); |
O_Thom | 6:b7f6e0c0f646 | 45 | } |
O_Thom | 6:b7f6e0c0f646 | 46 | ~Serialcomms() |
O_Thom | 6:b7f6e0c0f646 | 47 | { |
O_Thom | 6:b7f6e0c0f646 | 48 | } |
O_Thom | 1:f89c930c6491 | 49 | }; |
O_Thom | 7:8664a45f5ce1 | 50 | |
O_Thom | 7:8664a45f5ce1 | 51 | Serialcomms m_oSerial; |
O_Thom | 7:8664a45f5ce1 | 52 |