Repo. for the ELEC351 Coursework - Oliver Thompson
Dependencies: BMP280 ELEC350-Practicals-FZ429- TextLCD watchdog_RTOS BME280 ntp-client
LCD.hpp
- Committer:
- O_Thom
- Date:
- 2018-12-04
- Revision:
- 11:b8e8630c7e3b
- Parent:
- 10:08c366434f2b
- Child:
- 19:c3b396b65f2a
File content as of revision 11:b8e8630c7e3b:
#ifndef _LCD_ #define _LCD_ #include "mbed.h" #include "messageStruct.hpp" #include "sample_hardware.hpp" #include <vector> class LCD_Data { private: //private variables can only be changed via functions in this function float temp; //current temperature of sensor, updated every 15 seconds float pressure; //current pressure of sensor, updated every 15 seconds float fLDR; //current light level from LDR, updated every 15 seconds int flip; void update_temp(double t) //use this function to update the current temperature value { temp = t; } void update_pressure(double p) //use this function to update the current pressure value { pressure = p; } void update_LDR(double L) { fLDR = L; } public: EventQueue LCD_Queue; //create an event queue for main LCD_Data(){ //constructor, initializes the FLIP variable for use in toggling the bottom line of the LCD flip = 1; temp = 0; pressure = 0; fLDR = 0; } 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 { update_temp(msg.temp); // Include message class passing of data update_pressure(msg.pressure); update_LDR(msg.ldr); } void display_LCD() //updates the current LCD display with the new sensor information { lcd.cls(); //clear current LCD display lcd.printf("%4.2fC", temp); //print temperature to the top line of LCD, 2dp celcius switch(flip){ case 1: lcd.printf("\n%4.2f mbar", pressure); //print pressure to bottom line of LCD, 2dp mbar flip = 2; break; case 2: lcd.printf("\n%4.2f Lux", fLDR); //print pressure to bottom line of LCD, 2dp mbar flip = 1; break; default: printf("Error in LCD flip function"); break; } } }; #endif