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

Committer:
Alix955
Date:
Mon Dec 31 19:20:22 2018 +0000
Revision:
12:4c7eaac8ceef
Parent:
10:eea19f8e6122
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?

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"
Alix955 12:4c7eaac8ceef 6 #include "SDcard.hpp"
O_Thom 6:b7f6e0c0f646 7
O_Thom 6:b7f6e0c0f646 8 void LCD_Thread(void);
O_Thom 6:b7f6e0c0f646 9 void SAMP_Thread(void);
O_Thom 6:b7f6e0c0f646 10 void SERIAL_Thread(void);
Alix955 10:eea19f8e6122 11 void Network_Thread(void);
Alix955 12:4c7eaac8ceef 12 void SD_Thread(void);
Alix955 12:4c7eaac8ceef 13
O_Thom 6:b7f6e0c0f646 14
Alix955 10:eea19f8e6122 15 Thread tLCD, tSAMP, tSERIAL, tSD, tNET;
O_Thom 5:f87129ac8bf3 16
O_Thom 6:b7f6e0c0f646 17 // Define member object
O_Thom 7:8664a45f5ce1 18 Sampler m_oSample;
O_Thom 5:f87129ac8bf3 19
O_Thom 6:b7f6e0c0f646 20 int main()
O_Thom 6:b7f6e0c0f646 21 {
Alix955 12:4c7eaac8ceef 22 tLCD.start(LCD_Thread); //start the LCD thread
Alix955 12:4c7eaac8ceef 23 tSAMP.start(SAMP_Thread); //start the sampling thread
Alix955 12:4c7eaac8ceef 24 tSERIAL.start(SERIAL_Thread); //start the serial communications thread
Alix955 12:4c7eaac8ceef 25 tNET.start(Network_Thread); //start the networking thread
Alix955 12:4c7eaac8ceef 26 tSD.start(SD_Thread); //start the SD card thread
O_Thom 6:b7f6e0c0f646 27 Thread::wait(osWaitForever);
O_Thom 6:b7f6e0c0f646 28 }
O_Thom 0:f9a18207d99c 29
O_Thom 0:f9a18207d99c 30
O_Thom 6:b7f6e0c0f646 31 void LCD_Thread()
O_Thom 6:b7f6e0c0f646 32 {
O_Thom 6:b7f6e0c0f646 33 while(1)
O_Thom 6:b7f6e0c0f646 34 {
Alix955 10:eea19f8e6122 35 //m_oDisplay.LCD_Queue.call(&m_oDisplay, &LCD_Data::update_time_date);
Alix955 10:eea19f8e6122 36 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 37 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 38 while(true)
O_Thom 6:b7f6e0c0f646 39 {
O_Thom 6:b7f6e0c0f646 40 redLED = 1;
O_Thom 6:b7f6e0c0f646 41 wait(0.5);
O_Thom 6:b7f6e0c0f646 42 redLED = 0;
O_Thom 6:b7f6e0c0f646 43 wait(0.1);
O_Thom 6:b7f6e0c0f646 44 }
O_Thom 6:b7f6e0c0f646 45 }
O_Thom 6:b7f6e0c0f646 46 }
O_Thom 0:f9a18207d99c 47
O_Thom 6:b7f6e0c0f646 48 void SAMP_Thread()
O_Thom 6:b7f6e0c0f646 49 {
O_Thom 6:b7f6e0c0f646 50 while(1)
O_Thom 6:b7f6e0c0f646 51 {
O_Thom 7:8664a45f5ce1 52 m_oSample.SAMP_Queue.call_every(500, &m_oSample, &Sampler::publishSample); // Publish sample
O_Thom 7:8664a45f5ce1 53 m_oSample.SAMP_Queue.dispatch();
O_Thom 6:b7f6e0c0f646 54 while(true)
O_Thom 6:b7f6e0c0f646 55 { // Flash if the event queue is exited.
O_Thom 6:b7f6e0c0f646 56 yellowLED = 1;
O_Thom 6:b7f6e0c0f646 57 wait(0.5);
O_Thom 6:b7f6e0c0f646 58 yellowLED = 0;
O_Thom 6:b7f6e0c0f646 59 wait(0.1);
O_Thom 6:b7f6e0c0f646 60 }
O_Thom 6:b7f6e0c0f646 61 }
O_Thom 6:b7f6e0c0f646 62 }
O_Thom 6:b7f6e0c0f646 63
O_Thom 6:b7f6e0c0f646 64 void SERIAL_Thread()
O_Thom 0:f9a18207d99c 65 {
O_Thom 6:b7f6e0c0f646 66 while(1)
O_Thom 6:b7f6e0c0f646 67 {
O_Thom 7:8664a45f5ce1 68 m_oSerial.SERIAL_Queue.call_every(1000, &m_oSerial, &Serialcomms::updateTerminal); // Publish sample
O_Thom 7:8664a45f5ce1 69 m_oSerial.SERIAL_Queue.dispatch();
O_Thom 6:b7f6e0c0f646 70 while(true)
O_Thom 6:b7f6e0c0f646 71 { // Flash if the event queue is exited.
O_Thom 6:b7f6e0c0f646 72 yellowLED = 1;
O_Thom 6:b7f6e0c0f646 73 wait(0.5);
O_Thom 6:b7f6e0c0f646 74 yellowLED = 0;
O_Thom 6:b7f6e0c0f646 75 wait(0.1);
O_Thom 6:b7f6e0c0f646 76 }
O_Thom 6:b7f6e0c0f646 77 }
O_Thom 0:f9a18207d99c 78 }
O_Thom 6:b7f6e0c0f646 79
Alix955 10:eea19f8e6122 80
Alix955 12:4c7eaac8ceef 81 void SD_Thread()
Alix955 12:4c7eaac8ceef 82 {
Alix955 12:4c7eaac8ceef 83 while(1)
Alix955 12:4c7eaac8ceef 84 {
Alix955 12:4c7eaac8ceef 85 m_oSD.SDcard_Queue.call_every(5000, &m_oSD, &SDcard::Save_Data);
Alix955 12:4c7eaac8ceef 86 m_oSD.SDcard_Queue.dispatch();
Alix955 12:4c7eaac8ceef 87 while(true)
Alix955 12:4c7eaac8ceef 88 { // Flash if the event queue is exited.
Alix955 12:4c7eaac8ceef 89 greenLED = 1;
Alix955 12:4c7eaac8ceef 90 wait(0.5);
Alix955 12:4c7eaac8ceef 91 greenLED = 0;
Alix955 12:4c7eaac8ceef 92 wait(0.1);
Alix955 12:4c7eaac8ceef 93 }
Alix955 12:4c7eaac8ceef 94 }
Alix955 12:4c7eaac8ceef 95 }
Alix955 12:4c7eaac8ceef 96
Alix955 12:4c7eaac8ceef 97
Alix955 12:4c7eaac8ceef 98
Alix955 10:eea19f8e6122 99
Alix955 10:eea19f8e6122 100 void Network_Thread()
Alix955 10:eea19f8e6122 101 {
Alix955 10:eea19f8e6122 102 while(1)
Alix955 10:eea19f8e6122 103 {
Alix955 12:4c7eaac8ceef 104 m_oNet.Network_Queue.call_every(5000, &m_oNet, &Network::NetPush);
Alix955 10:eea19f8e6122 105 m_oNet.Network_Queue.dispatch();
Alix955 10:eea19f8e6122 106
Alix955 10:eea19f8e6122 107 while(true)
Alix955 10:eea19f8e6122 108 { // Flash if the event queue is exited.
Alix955 10:eea19f8e6122 109 greenLED = 1;
Alix955 10:eea19f8e6122 110 wait(0.5);
Alix955 10:eea19f8e6122 111 greenLED = 0;
Alix955 10:eea19f8e6122 112 wait(0.1);
Alix955 10:eea19f8e6122 113
Alix955 10:eea19f8e6122 114 }
Alix955 10:eea19f8e6122 115 }
Alix955 10:eea19f8e6122 116 }
Alix955 10:eea19f8e6122 117
Alix955 10:eea19f8e6122 118