fuck this

Dependencies:   BMP280

Committer:
mwthewsey
Date:
Wed Jan 10 03:57:59 2018 +0000
Revision:
25:a2aedb498b27
Parent:
24:7bf408dc491a
Final Submission

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 23:a6bb5298346c 5 #include "DriverLCD.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 21:6e733076f49c 24 #define SCREENDELAY_MS 2707 //Delay for screen update
mwthewsey 11:b538e73841ae 25
mwthewsey 23:a6bb5298346c 26 class ENVDISPLAY : DriverLCD //Class inherits TextLCD
mwthewsey 11:b538e73841ae 27 {
mwthewsey 11:b538e73841ae 28 private:
mwthewsey 11:b538e73841ae 29 char _message[32]; //32 characters on display
mwthewsey 21:6e733076f49c 30 bool _AutoQuit; //After a message, should the LCD return to enviromental?
mwthewsey 21:6e733076f49c 31 float _latestTemp; //Latest sample data
mwthewsey 11:b538e73841ae 32 float _latestPres;
mwthewsey 11:b538e73841ae 33 float _latestLDR;
mwthewsey 11:b538e73841ae 34 time_t _latestTime;
mwthewsey 22:617bf92b481f 35
mwthewsey 22:617bf92b481f 36 enum ThreadState {MESSAGE,SCROLLREADINGS,ADJUSTTIME};
mwthewsey 22:617bf92b481f 37
mwthewsey 21:6e733076f49c 38 ThreadState _currentState; //State machine state
mwthewsey 22:617bf92b481f 39
mwthewsey 21:6e733076f49c 40 //Hardware
mwthewsey 21:6e733076f49c 41 InterruptIn Button1; //Buttons used for setting time
mwthewsey 22:617bf92b481f 42 InterruptIn Button2;
mwthewsey 22:617bf92b481f 43 Timeout But1Debouncer;//Button debouncers
mwthewsey 22:617bf92b481f 44 Timeout But2Debouncer;
mwthewsey 21:6e733076f49c 45 Thread LCDThread; //Thread which LCD runs in
mwthewsey 22:617bf92b481f 46
mwthewsey 11:b538e73841ae 47 void Button1ISR(void);
mwthewsey 22:617bf92b481f 48 //Called when button 1 is pressed.
mwthewsey 22:617bf92b481f 49 void But1DebouncerISR(void);
mwthewsey 22:617bf92b481f 50 //insures that only 1 button press signal is sent to thread
mwthewsey 22:617bf92b481f 51 void Button2ISR(void);
mwthewsey 22:617bf92b481f 52 //Called when button 2 is pressed. Sets _but2Pressed and thread flag
mwthewsey 22:617bf92b481f 53 void But2DebouncerISR(void);
mwthewsey 22:617bf92b481f 54 //insures that only 1 button press signal is sent to thread
mwthewsey 11:b538e73841ae 55 void StateMachine(void);
mwthewsey 11:b538e73841ae 56 //Gets attached to LCDThread
mwthewsey 22:617bf92b481f 57 int TimeEditor(int changingVal, int upperLimit, int lowerLimit);
mwthewsey 22:617bf92b481f 58 //Handles the cycle and user input to modify changingVal and return the updated number
mwthewsey 22:617bf92b481f 59
mwthewsey 22:617bf92b481f 60 //Used for time editing
mwthewsey 22:617bf92b481f 61 bool _but1Pressed; //Signals that button 1 has been pressed
mwthewsey 22:617bf92b481f 62 bool _but2Pressed; //Signals that button 2 has been pressed
mwthewsey 22:617bf92b481f 63 tm _EditTime; //used to hold time structure whilst editing
mwthewsey 22:617bf92b481f 64 char _editingInTime[10];//hold the string of what variable is to be edited
mwthewsey 22:617bf92b481f 65
mwthewsey 22:617bf92b481f 66
mwthewsey 11:b538e73841ae 67 public:
mwthewsey 11:b538e73841ae 68 ENVDISPLAY(PinName rsPin, PinName rePin, PinName d4Pin, PinName d5Pin, PinName d6Pin, PinName d7Pin, PinName Button1Pin, PinName Button2Pin);
mwthewsey 11:b538e73841ae 69 //constructor
mwthewsey 11:b538e73841ae 70 void SendMessage(char sentText[], bool returnToReadings);
mwthewsey 11:b538e73841ae 71 //Display a custom message on the display with option to resume displaying readings
mwthewsey 11:b538e73841ae 72 void Start(void);
mwthewsey 11:b538e73841ae 73 //Inititates LCD activity
mwthewsey 24:7bf408dc491a 74 void POST(void);
mwthewsey 24:7bf408dc491a 75 //Self Test
mwthewsey 11:b538e73841ae 76 void UpdateData(float temp, float pres, float LDR, time_t sampleTime);
mwthewsey 11:b538e73841ae 77 //Pass in new enviromental data
mwthewsey 22:617bf92b481f 78
mwthewsey 11:b538e73841ae 79 };
mwthewsey 12:03589f1d5c30 80 extern ENVDISPLAY lcd;
Swaggie 2:5a38ae8459d5 81
Swaggie 2:5a38ae8459d5 82 #endif