Version 5

Dependencies:   BMP280 TextLCD BME280

Committer:
O_Thom
Date:
Thu Nov 29 18:41:57 2018 +0000
Revision:
6:b7f6e0c0f646
Parent:
5:f87129ac8bf3
Child:
7:8664a45f5ce1
Working threads. Tested LCD and Sampler. Serial Pending.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
O_Thom 5:f87129ac8bf3 1 #include "mbed.h"
O_Thom 0:f9a18207d99c 2 #include "sample_hardware.hpp"
O_Thom 0:f9a18207d99c 3 #include "Sampler.hpp"
O_Thom 6:b7f6e0c0f646 4 #include "SerialComms.hpp"
O_Thom 6:b7f6e0c0f646 5
O_Thom 6:b7f6e0c0f646 6 void LCD_Thread(void);
O_Thom 6:b7f6e0c0f646 7 void SAMP_Thread(void);
O_Thom 6:b7f6e0c0f646 8 void SERIAL_Thread(void);
O_Thom 6:b7f6e0c0f646 9
O_Thom 6:b7f6e0c0f646 10 Thread tLCD, tSAMP, tSERIAL, tSD;
O_Thom 5:f87129ac8bf3 11
O_Thom 6:b7f6e0c0f646 12 // Define member object
O_Thom 6:b7f6e0c0f646 13 Sampler m_osample;
O_Thom 6:b7f6e0c0f646 14 Serialcomms m_oserial;
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 6:b7f6e0c0f646 45 m_osample.SAMP_Queue.call_every(1000, &m_osample, &Sampler::publishSample); // Publish sample
O_Thom 6:b7f6e0c0f646 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 6:b7f6e0c0f646 61 m_oserial.SERIAL_Queue.call_every(1000, &m_oserial, &Serialcomms::updateTerminal); // Publish sample
O_Thom 6:b7f6e0c0f646 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