Version 5
Dependencies: BMP280 TextLCD BME280
Diff: LCD.hpp
- Revision:
- 6:b7f6e0c0f646
- Parent:
- 5:f87129ac8bf3
- Child:
- 9:f5eae5211225
diff -r f87129ac8bf3 -r b7f6e0c0f646 LCD.hpp --- a/LCD.hpp Thu Nov 29 16:08:28 2018 +0000 +++ b/LCD.hpp Thu Nov 29 18:41:57 2018 +0000 @@ -1,35 +1,42 @@ - #ifndef _LCD_ - #define _LCD_ - #include "mbed.h" - #include "message.hpp" - - class LCD_Data +#ifndef _LCD_ +#define _LCD_ +#include "mbed.h" +#include "messageStruct.hpp" +#include "sample_hardware.hpp" +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 temp) //use this function to update the current temperature value - { - temp = sensor.getTemperature(); - } - void update_pressure(double pressure) //use this function to update the current pressure value - { - pressure = sensor.getPressure(); - } + 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 = sensor.getTemperature(); - pressure = sensor.getPressure(); + temp = 0; + pressure = 0; + fLDR = 0; } - void update_sensor_info() //updates all current sensor information, this is called by a ticker every 5 seconds to read from the mailbox + 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(0); // Include message class passing of data - update_pressure(0); + 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 { @@ -38,15 +45,18 @@ switch(flip){ case 1: lcd.printf("\n%4.2f mbar", pressure); //print pressure to bottom line of LCD, 2dp mbar - break; - - default: + 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; } } - }; //end of class LCD_Data -// Define Objects for the LCD_Data Class + }; +// Define the member object for the LCD LCD_Data m_oDisplay; - - #endif \ No newline at end of file +#endif \ No newline at end of file