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
main.cpp
- Committer:
- Alix955
- Date:
- 2018-12-31
- Revision:
- 12:4c7eaac8ceef
- Parent:
- 10:eea19f8e6122
File content as of revision 12:4c7eaac8ceef:
#include "mbed.h" #include "ntp-client/NTPClient.h" #include "sample_hardware.hpp" #include "Sampler.hpp" #include "SwitchManager.hpp" #include "SDcard.hpp" void LCD_Thread(void); void SAMP_Thread(void); void SERIAL_Thread(void); void Network_Thread(void); void SD_Thread(void); Thread tLCD, tSAMP, tSERIAL, tSD, tNET; // Define member object Sampler m_oSample; int main() { tLCD.start(LCD_Thread); //start the LCD thread tSAMP.start(SAMP_Thread); //start the sampling thread tSERIAL.start(SERIAL_Thread); //start the serial communications thread tNET.start(Network_Thread); //start the networking thread tSD.start(SD_Thread); //start the SD card thread Thread::wait(osWaitForever); } void LCD_Thread() { while(1) { //m_oDisplay.LCD_Queue.call(&m_oDisplay, &LCD_Data::update_time_date); 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 m_oDisplay.LCD_Queue.dispatch(); //dispatches the above tasks to the queue, then blocks main forever unless ' break_dispatch () ' is used while(true) { redLED = 1; wait(0.5); redLED = 0; wait(0.1); } } } void SAMP_Thread() { while(1) { m_oSample.SAMP_Queue.call_every(500, &m_oSample, &Sampler::publishSample); // Publish sample m_oSample.SAMP_Queue.dispatch(); while(true) { // Flash if the event queue is exited. yellowLED = 1; wait(0.5); yellowLED = 0; wait(0.1); } } } void SERIAL_Thread() { while(1) { m_oSerial.SERIAL_Queue.call_every(1000, &m_oSerial, &Serialcomms::updateTerminal); // Publish sample m_oSerial.SERIAL_Queue.dispatch(); while(true) { // Flash if the event queue is exited. yellowLED = 1; wait(0.5); yellowLED = 0; wait(0.1); } } } void SD_Thread() { while(1) { m_oSD.SDcard_Queue.call_every(5000, &m_oSD, &SDcard::Save_Data); m_oSD.SDcard_Queue.dispatch(); while(true) { // Flash if the event queue is exited. greenLED = 1; wait(0.5); greenLED = 0; wait(0.1); } } } void Network_Thread() { while(1) { m_oNet.Network_Queue.call_every(5000, &m_oNet, &Network::NetPush); m_oNet.Network_Queue.dispatch(); while(true) { // Flash if the event queue is exited. greenLED = 1; wait(0.5); greenLED = 0; wait(0.1); } } }