Alix & Sam's combined versions

Dependencies:   BMP280 ELEC350-Practicals-FZ429 TextLCD BME280 ntp-client

Committer:
Alix955
Date:
Fri Dec 07 13:24:50 2018 +0000
Revision:
9:f5eae5211225
Parent:
7:8664a45f5ce1
Child:
10:eea19f8e6122
Version 5, mine & sams versions merged

Who changed what in which revision?

UserRevisionLine numberNew contents of line
O_Thom 5:f87129ac8bf3 1 #include "mbed.h"
Alix955 9:f5eae5211225 2 #include "ntp-client/NTPClient.h"
O_Thom 0:f9a18207d99c 3 #include "sample_hardware.hpp"
O_Thom 0:f9a18207d99c 4 #include "Sampler.hpp"
Alix955 9:f5eae5211225 5 #include "SwitchManager.hpp"
O_Thom 6:b7f6e0c0f646 6
O_Thom 6:b7f6e0c0f646 7 void LCD_Thread(void);
O_Thom 6:b7f6e0c0f646 8 void SAMP_Thread(void);
O_Thom 6:b7f6e0c0f646 9 void SERIAL_Thread(void);
O_Thom 6:b7f6e0c0f646 10
O_Thom 6:b7f6e0c0f646 11 Thread tLCD, tSAMP, tSERIAL, tSD;
O_Thom 5:f87129ac8bf3 12
O_Thom 6:b7f6e0c0f646 13 // Define member object
O_Thom 7:8664a45f5ce1 14 Sampler m_oSample;
O_Thom 5:f87129ac8bf3 15
O_Thom 6:b7f6e0c0f646 16 int main()
O_Thom 6:b7f6e0c0f646 17 {
O_Thom 6:b7f6e0c0f646 18 tLCD.start(LCD_Thread);
O_Thom 6:b7f6e0c0f646 19 tSAMP.start(SAMP_Thread);
O_Thom 6:b7f6e0c0f646 20 tSERIAL.start(SERIAL_Thread);
O_Thom 6:b7f6e0c0f646 21 Thread::wait(osWaitForever);
O_Thom 6:b7f6e0c0f646 22 }
O_Thom 0:f9a18207d99c 23
O_Thom 0:f9a18207d99c 24
O_Thom 6:b7f6e0c0f646 25 void LCD_Thread()
O_Thom 6:b7f6e0c0f646 26 {
O_Thom 6:b7f6e0c0f646 27 while(1)
O_Thom 6:b7f6e0c0f646 28 {
O_Thom 6:b7f6e0c0f646 29 m_oDisplay.LCD_Queue.call_every(1000, &m_oDisplay, &LCD_Data::display_LCD); //displays the current sensor information onto the LCD screen every x miliseconds
O_Thom 6:b7f6e0c0f646 30 m_oDisplay.LCD_Queue.dispatch(); //dispatches the above tasks to the queue, then blocks main forever unless ' break_dispatch () ' is used
O_Thom 6:b7f6e0c0f646 31 while(true)
O_Thom 6:b7f6e0c0f646 32 {
O_Thom 6:b7f6e0c0f646 33 redLED = 1;
O_Thom 6:b7f6e0c0f646 34 wait(0.5);
O_Thom 6:b7f6e0c0f646 35 redLED = 0;
O_Thom 6:b7f6e0c0f646 36 wait(0.1);
O_Thom 6:b7f6e0c0f646 37 }
O_Thom 6:b7f6e0c0f646 38 }
O_Thom 6:b7f6e0c0f646 39 }
O_Thom 0:f9a18207d99c 40
O_Thom 6:b7f6e0c0f646 41 void SAMP_Thread()
O_Thom 6:b7f6e0c0f646 42 {
O_Thom 6:b7f6e0c0f646 43 while(1)
O_Thom 6:b7f6e0c0f646 44 {
O_Thom 7:8664a45f5ce1 45 m_oSample.SAMP_Queue.call_every(500, &m_oSample, &Sampler::publishSample); // Publish sample
O_Thom 7:8664a45f5ce1 46 m_oSample.SAMP_Queue.dispatch();
O_Thom 6:b7f6e0c0f646 47 while(true)
O_Thom 6:b7f6e0c0f646 48 { // Flash if the event queue is exited.
O_Thom 6:b7f6e0c0f646 49 yellowLED = 1;
O_Thom 6:b7f6e0c0f646 50 wait(0.5);
O_Thom 6:b7f6e0c0f646 51 yellowLED = 0;
O_Thom 6:b7f6e0c0f646 52 wait(0.1);
O_Thom 6:b7f6e0c0f646 53 }
O_Thom 6:b7f6e0c0f646 54 }
O_Thom 6:b7f6e0c0f646 55 }
O_Thom 6:b7f6e0c0f646 56
O_Thom 6:b7f6e0c0f646 57 void SERIAL_Thread()
O_Thom 0:f9a18207d99c 58 {
O_Thom 6:b7f6e0c0f646 59 while(1)
O_Thom 6:b7f6e0c0f646 60 {
O_Thom 7:8664a45f5ce1 61 m_oSerial.SERIAL_Queue.call_every(1000, &m_oSerial, &Serialcomms::updateTerminal); // Publish sample
O_Thom 7:8664a45f5ce1 62 m_oSerial.SERIAL_Queue.dispatch();
O_Thom 6:b7f6e0c0f646 63 while(true)
O_Thom 6:b7f6e0c0f646 64 { // Flash if the event queue is exited.
O_Thom 6:b7f6e0c0f646 65 yellowLED = 1;
O_Thom 6:b7f6e0c0f646 66 wait(0.5);
O_Thom 6:b7f6e0c0f646 67 yellowLED = 0;
O_Thom 6:b7f6e0c0f646 68 wait(0.1);
O_Thom 6:b7f6e0c0f646 69 }
O_Thom 6:b7f6e0c0f646 70 }
O_Thom 0:f9a18207d99c 71 }
O_Thom 6:b7f6e0c0f646 72