Version 5
Dependencies: BMP280 TextLCD BME280
SerialComms.hpp@9:f5eae5211225, 2018-12-07 (annotated)
- Committer:
- Alix955
- Date:
- Fri Dec 07 13:24:50 2018 +0000
- Revision:
- 9:f5eae5211225
- Parent:
- 8:7d218affea71
Version 5, mine & sams versions merged
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 |