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 18:41:57 2018 +0000
Revision:
6:b7f6e0c0f646
Parent:
5:f87129ac8bf3
Child:
9:f5eae5211225
Working threads. Tested LCD and Sampler. Serial Pending.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
O_Thom 6:b7f6e0c0f646 1 #ifndef _LCD_
O_Thom 6:b7f6e0c0f646 2 #define _LCD_
O_Thom 6:b7f6e0c0f646 3 #include "mbed.h"
O_Thom 6:b7f6e0c0f646 4 #include "messageStruct.hpp"
O_Thom 6:b7f6e0c0f646 5 #include "sample_hardware.hpp"
O_Thom 6:b7f6e0c0f646 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 6:b7f6e0c0f646 9 float temp; //current temperature of sensor, updated every 15 seconds
O_Thom 6:b7f6e0c0f646 10 float pressure; //current pressure of sensor, updated every 15 seconds
O_Thom 6:b7f6e0c0f646 11 float fLDR; //current light level from LDR, updated every 15 seconds
O_Thom 6:b7f6e0c0f646 12 int flip;
O_Thom 6:b7f6e0c0f646 13
O_Thom 6:b7f6e0c0f646 14 void update_temp(double t) //use this function to update the current temperature value
O_Thom 6:b7f6e0c0f646 15 {
O_Thom 6:b7f6e0c0f646 16 temp = t;
O_Thom 6:b7f6e0c0f646 17 }
O_Thom 6:b7f6e0c0f646 18 void update_pressure(double p) //use this function to update the current pressure value
O_Thom 6:b7f6e0c0f646 19 {
O_Thom 6:b7f6e0c0f646 20 pressure = p;
O_Thom 6:b7f6e0c0f646 21 }
O_Thom 6:b7f6e0c0f646 22 void update_LDR(double L)
O_Thom 6:b7f6e0c0f646 23 {
O_Thom 6:b7f6e0c0f646 24 fLDR = L;
O_Thom 6:b7f6e0c0f646 25 }
O_Thom 6:b7f6e0c0f646 26
O_Thom 5:f87129ac8bf3 27 public:
O_Thom 5:f87129ac8bf3 28 EventQueue LCD_Queue; //create an event queue for main
O_Thom 5:f87129ac8bf3 29 LCD_Data(){ //constructor, initializes the FLIP variable for use in toggling the bottom line of the LCD
O_Thom 5:f87129ac8bf3 30 flip = 1;
O_Thom 6:b7f6e0c0f646 31 temp = 0;
O_Thom 6:b7f6e0c0f646 32 pressure = 0;
O_Thom 6:b7f6e0c0f646 33 fLDR = 0;
O_Thom 5:f87129ac8bf3 34 }
O_Thom 6:b7f6e0c0f646 35 void update_sensor_info(sample_message msg) //updates all current sensor information, this is called by a ticker every 5 seconds to read from the mailbox
O_Thom 5:f87129ac8bf3 36 {
O_Thom 6:b7f6e0c0f646 37 update_temp(msg.temp); // Include message class passing of data
O_Thom 6:b7f6e0c0f646 38 update_pressure(msg.pressure);
O_Thom 6:b7f6e0c0f646 39 update_LDR(msg.ldr);
O_Thom 5:f87129ac8bf3 40 }
O_Thom 5:f87129ac8bf3 41 void display_LCD() //updates the current LCD display with the new sensor information
O_Thom 5:f87129ac8bf3 42 {
O_Thom 5:f87129ac8bf3 43 lcd.cls(); //clear current LCD display
O_Thom 5:f87129ac8bf3 44 lcd.printf("%4.2fC", temp); //print temperature to the top line of LCD, 2dp celcius
O_Thom 5:f87129ac8bf3 45 switch(flip){
O_Thom 5:f87129ac8bf3 46 case 1:
O_Thom 5:f87129ac8bf3 47 lcd.printf("\n%4.2f mbar", pressure); //print pressure to bottom line of LCD, 2dp mbar
O_Thom 6:b7f6e0c0f646 48 flip = 2;
O_Thom 6:b7f6e0c0f646 49 break;
O_Thom 6:b7f6e0c0f646 50 case 2:
O_Thom 6:b7f6e0c0f646 51 lcd.printf("\n%4.2f Lux", fLDR); //print pressure to bottom line of LCD, 2dp mbar
O_Thom 6:b7f6e0c0f646 52 flip = 1;
O_Thom 6:b7f6e0c0f646 53 break;
O_Thom 6:b7f6e0c0f646 54 default:
O_Thom 5:f87129ac8bf3 55 printf("Error in LCD flip function");
O_Thom 5:f87129ac8bf3 56 break;
O_Thom 5:f87129ac8bf3 57 }
O_Thom 5:f87129ac8bf3 58 }
O_Thom 6:b7f6e0c0f646 59 };
O_Thom 6:b7f6e0c0f646 60 // Define the member object for the LCD
O_Thom 5:f87129ac8bf3 61 LCD_Data m_oDisplay;
O_Thom 6:b7f6e0c0f646 62 #endif