fuck this

Dependencies:   BMP280

Committer:
Swaggie
Date:
Tue Jan 09 11:53:11 2018 +0000
Revision:
20:25939e03b803
Parent:
12:03589f1d5c30
Child:
21:6e733076f49c
Inputted Logging in main function and in LCD function.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Swaggie 2:5a38ae8459d5 1 #ifndef __LCD__
Swaggie 2:5a38ae8459d5 2 #define __LCD__
Swaggie 2:5a38ae8459d5 3
mwthewsey 11:b538e73841ae 4 #include "mbed.h"
mwthewsey 11:b538e73841ae 5 #include "TextLCD.h"
mwthewsey 11:b538e73841ae 6 #include "rtos.h"
mwthewsey 11:b538e73841ae 7 #include "TimeInterface.h"
Swaggie 20:25939e03b803 8 #include "Logging.h"
mwthewsey 11:b538e73841ae 9 #include <string>
mwthewsey 11:b538e73841ae 10 /*
mwthewsey 11:b538e73841ae 11 *The ENVDISPLAY class enhances the abilities of the TextLCD class to be
mwthewsey 11:b538e73841ae 12 *relevant for an ENVIRONMENTAL sensor.
mwthewsey 11:b538e73841ae 13 *Temperature, pressure, LDR and time readings are passed into the object using
mwthewsey 11:b538e73841ae 14 *the UpdateData function. A custom message can also be displayed using
mwthewsey 11:b538e73841ae 15 *SendMessage, with the option of returning to enviromental data.
mwthewsey 11:b538e73841ae 16 *
mwthewsey 11:b538e73841ae 17 *Two buttons are required for time setting functions. Pressing button 1 enters
mwthewsey 11:b538e73841ae 18 *the lcd into a set_time state.
mwthewsey 11:b538e73841ae 19 *
mwthewsey 11:b538e73841ae 20 *Device initialised with: ENVDISPLAY lcd(D9, D8, D7, D6, D4, D2,PE_12, PE_14);
mwthewsey 11:b538e73841ae 21 *lcd.Start() must be run to begin operation.
mwthewsey 11:b538e73841ae 22 */
mwthewsey 11:b538e73841ae 23
mwthewsey 12:03589f1d5c30 24 #define SCREENDELAY_MS 2707
mwthewsey 11:b538e73841ae 25
mwthewsey 11:b538e73841ae 26 class ENVDISPLAY : TextLCD
mwthewsey 11:b538e73841ae 27 {
mwthewsey 11:b538e73841ae 28 private:
mwthewsey 11:b538e73841ae 29 char _message[32]; //32 characters on display
mwthewsey 11:b538e73841ae 30 bool _AutoQuit; //After a message, should the LCD return to enviromental?
mwthewsey 11:b538e73841ae 31 float _latestTemp;
mwthewsey 11:b538e73841ae 32 float _latestPres;
mwthewsey 11:b538e73841ae 33 float _latestLDR;
mwthewsey 11:b538e73841ae 34 time_t _latestTime;
mwthewsey 11:b538e73841ae 35
mwthewsey 11:b538e73841ae 36 enum ThreadState{MESSAGE,SCROLLREADINGS,ADJUSTTIME};
mwthewsey 11:b538e73841ae 37
mwthewsey 11:b538e73841ae 38 ThreadState _currentState;
mwthewsey 11:b538e73841ae 39
mwthewsey 11:b538e73841ae 40 InterruptIn Button1;
mwthewsey 11:b538e73841ae 41 DigitalIn Button2;
mwthewsey 11:b538e73841ae 42 Thread LCDThread;
mwthewsey 11:b538e73841ae 43
mwthewsey 11:b538e73841ae 44 void Button1ISR(void);
mwthewsey 11:b538e73841ae 45 //Called when button 1 is pressed.
mwthewsey 11:b538e73841ae 46 void StateMachine(void);
mwthewsey 11:b538e73841ae 47 //Gets attached to LCDThread
mwthewsey 11:b538e73841ae 48
mwthewsey 11:b538e73841ae 49 public:
mwthewsey 11:b538e73841ae 50 ENVDISPLAY(PinName rsPin, PinName rePin, PinName d4Pin, PinName d5Pin, PinName d6Pin, PinName d7Pin, PinName Button1Pin, PinName Button2Pin);
mwthewsey 11:b538e73841ae 51 //constructor
mwthewsey 11:b538e73841ae 52 void SendMessage(char sentText[], bool returnToReadings);
mwthewsey 11:b538e73841ae 53 //Display a custom message on the display with option to resume displaying readings
mwthewsey 11:b538e73841ae 54 void Start(void);
mwthewsey 11:b538e73841ae 55 //Inititates LCD activity
mwthewsey 11:b538e73841ae 56 void UpdateData(float temp, float pres, float LDR, time_t sampleTime);
mwthewsey 11:b538e73841ae 57 //Pass in new enviromental data
mwthewsey 11:b538e73841ae 58
mwthewsey 11:b538e73841ae 59 };
mwthewsey 12:03589f1d5c30 60 extern ENVDISPLAY lcd;
Swaggie 2:5a38ae8459d5 61
Swaggie 2:5a38ae8459d5 62 #endif