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:
O_Thom
Date:
Thu Nov 29 16:08:28 2018 +0000
Revision:
5:f87129ac8bf3
Child:
6:b7f6e0c0f646
Commit before change from sample message class to typedef struct

Who changed what in which revision?

UserRevisionLine numberNew contents of line
O_Thom 5:f87129ac8bf3 1 #ifndef _LCD_
O_Thom 5:f87129ac8bf3 2 #define _LCD_
O_Thom 5:f87129ac8bf3 3 #include "mbed.h"
O_Thom 5:f87129ac8bf3 4 #include "message.hpp"
O_Thom 5:f87129ac8bf3 5
O_Thom 5:f87129ac8bf3 6 class LCD_Data
O_Thom 5:f87129ac8bf3 7 {
O_Thom 5:f87129ac8bf3 8 private: //private variables can only be changed via functions in this function
O_Thom 5:f87129ac8bf3 9 float temp; //current temperature of sensor, updated every 15 seconds
O_Thom 5:f87129ac8bf3 10 float pressure; //current pressure of sensor, updated every 15 seconds
O_Thom 5:f87129ac8bf3 11 float fLDR; //current light level from LDR, updated every 15 seconds
O_Thom 5:f87129ac8bf3 12 int flip;
O_Thom 5:f87129ac8bf3 13 void update_temp(double temp) //use this function to update the current temperature value
O_Thom 5:f87129ac8bf3 14 {
O_Thom 5:f87129ac8bf3 15 temp = sensor.getTemperature();
O_Thom 5:f87129ac8bf3 16 }
O_Thom 5:f87129ac8bf3 17 void update_pressure(double pressure) //use this function to update the current pressure value
O_Thom 5:f87129ac8bf3 18 {
O_Thom 5:f87129ac8bf3 19 pressure = sensor.getPressure();
O_Thom 5:f87129ac8bf3 20 }
O_Thom 5:f87129ac8bf3 21 public:
O_Thom 5:f87129ac8bf3 22 EventQueue LCD_Queue; //create an event queue for main
O_Thom 5:f87129ac8bf3 23
O_Thom 5:f87129ac8bf3 24 LCD_Data(){ //constructor, initializes the FLIP variable for use in toggling the bottom line of the LCD
O_Thom 5:f87129ac8bf3 25 flip = 1;
O_Thom 5:f87129ac8bf3 26 temp = sensor.getTemperature();
O_Thom 5:f87129ac8bf3 27 pressure = sensor.getPressure();
O_Thom 5:f87129ac8bf3 28 }
O_Thom 5:f87129ac8bf3 29 void update_sensor_info() //updates all current sensor information, this is called by a ticker every 5 seconds to read from the mailbox
O_Thom 5:f87129ac8bf3 30 {
O_Thom 5:f87129ac8bf3 31 update_temp(0); // Include message class passing of data
O_Thom 5:f87129ac8bf3 32 update_pressure(0);
O_Thom 5:f87129ac8bf3 33 }
O_Thom 5:f87129ac8bf3 34 void display_LCD() //updates the current LCD display with the new sensor information
O_Thom 5:f87129ac8bf3 35 {
O_Thom 5:f87129ac8bf3 36 lcd.cls(); //clear current LCD display
O_Thom 5:f87129ac8bf3 37 lcd.printf("%4.2fC", temp); //print temperature to the top line of LCD, 2dp celcius
O_Thom 5:f87129ac8bf3 38 switch(flip){
O_Thom 5:f87129ac8bf3 39 case 1:
O_Thom 5:f87129ac8bf3 40 lcd.printf("\n%4.2f mbar", pressure); //print pressure to bottom line of LCD, 2dp mbar
O_Thom 5:f87129ac8bf3 41 break;
O_Thom 5:f87129ac8bf3 42
O_Thom 5:f87129ac8bf3 43 default:
O_Thom 5:f87129ac8bf3 44 printf("Error in LCD flip function");
O_Thom 5:f87129ac8bf3 45 break;
O_Thom 5:f87129ac8bf3 46 }
O_Thom 5:f87129ac8bf3 47 }
O_Thom 5:f87129ac8bf3 48 }; //end of class LCD_Data
O_Thom 5:f87129ac8bf3 49 // Define Objects for the LCD_Data Class
O_Thom 5:f87129ac8bf3 50 LCD_Data m_oDisplay;
O_Thom 5:f87129ac8bf3 51
O_Thom 5:f87129ac8bf3 52 #endif