fuck this
Dependencies: BMP280
LCD.h@16:1b3488fb67f5, 2018-01-07 (annotated)
- Committer:
- Swaggie
- Date:
- Sun Jan 07 00:02:29 2018 +0000
- Revision:
- 16:1b3488fb67f5
- Parent:
- 15:e61297f9bae9
- Child:
- 17:95b0b1ec0f90
Made good progress on LCD functions. Now constructs correctly.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Swaggie | 2:5a38ae8459d5 | 1 | #ifndef __LCD__ |
Swaggie | 2:5a38ae8459d5 | 2 | #define __LCD__ |
Swaggie | 14:1fb1354ac27c | 3 | /* |
Swaggie | 14:1fb1354ac27c | 4 | *This class inherits the TextLCD class to add functionality to display enviromental readings, |
Swaggie | 15:e61297f9bae9 | 5 | *with a scrolling display, or to display a specific message, which times out back |
Swaggie | 15:e61297f9bae9 | 6 | *to scrolling, and to set the time using two push buttons. |
Swaggie | 14:1fb1354ac27c | 7 | */ |
Swaggie | 14:1fb1354ac27c | 8 | #include "mbed.h" |
Swaggie | 14:1fb1354ac27c | 9 | #include "TextLCD.h" |
Swaggie | 15:e61297f9bae9 | 10 | #include "rtos.h" |
Swaggie | 14:1fb1354ac27c | 11 | #include <string> |
Swaggie | 2:5a38ae8459d5 | 12 | //These functions manage writing to the LCD |
Swaggie | 2:5a38ae8459d5 | 13 | |
Swaggie | 15:e61297f9bae9 | 14 | class EnviromLCDDisplay : private TextLCD |
Swaggie | 14:1fb1354ac27c | 15 | { |
Swaggie | 14:1fb1354ac27c | 16 | private: |
Swaggie | 14:1fb1354ac27c | 17 | //private variables |
Swaggie | 14:1fb1354ac27c | 18 | enum ThreadState{MESSAGE,SCROLLREADINGS,ADJUSTTIME}; |
Swaggie | 14:1fb1354ac27c | 19 | enum ScrollState{PRESTEMP,LDRTIME}; |
Swaggie | 14:1fb1354ac27c | 20 | |
Swaggie | 14:1fb1354ac27c | 21 | ThreadState _TState; //This determines what function the LCD is doing |
Swaggie | 14:1fb1354ac27c | 22 | ScrollState _SState; //This determines what screen on the LCD is shown |
Swaggie | 14:1fb1354ac27c | 23 | |
Swaggie | 15:e61297f9bae9 | 24 | //Values to display |
Swaggie | 15:e61297f9bae9 | 25 | float _temperature; |
Swaggie | 15:e61297f9bae9 | 26 | float _pressure; |
Swaggie | 15:e61297f9bae9 | 27 | float _ldr; |
Swaggie | 15:e61297f9bae9 | 28 | string _message; |
Swaggie | 15:e61297f9bae9 | 29 | |
Swaggie | 15:e61297f9bae9 | 30 | //Objects to be used |
Swaggie | 15:e61297f9bae9 | 31 | Ticker _DisplayScroll; //pointer to an external ticker that will be used for changing the display |
Swaggie | 15:e61297f9bae9 | 32 | Thread _LCDThread; //Pointer to the therad that will be used for the LCD |
Swaggie | 15:e61297f9bae9 | 33 | PinName _Button1Pin; //Button will change between InterruptIn and DigitalIn. Used to enter time edit mode |
Swaggie | 15:e61297f9bae9 | 34 | DigitalIn _Button2; //Button2 |
Swaggie | 15:e61297f9bae9 | 35 | bool _AutoQuit; //After message is displayed, should LCD return to SCROLLREADINGS? |
Swaggie | 15:e61297f9bae9 | 36 | |
Swaggie | 14:1fb1354ac27c | 37 | //private functions |
Swaggie | 16:1b3488fb67f5 | 38 | void LCDThreadFn(void); //This needs to be attached to a thread |
Swaggie | 16:1b3488fb67f5 | 39 | void TimeButtonISR(void); //Run when Button 1 is set as an interrupt in |
Swaggie | 16:1b3488fb67f5 | 40 | void DisplayScrollISR(void);//Run by ticker |
Swaggie | 14:1fb1354ac27c | 41 | public: |
Swaggie | 14:1fb1354ac27c | 42 | //public functions |
Swaggie | 16:1b3488fb67f5 | 43 | EnviromLCDDisplay(PinName rs, PinName e, PinName d4, PinName d5, PinName d6, PinName d7, PinName Button1Pin, PinName Button2); //Constructor |
Swaggie | 15:e61297f9bae9 | 44 | //~EnviromLCDDisplay(); //Destructor |
Swaggie | 14:1fb1354ac27c | 45 | |
Swaggie | 15:e61297f9bae9 | 46 | bool POST(void); //Power On Self Test. Returns true if pass |
Swaggie | 15:e61297f9bae9 | 47 | void Start(void); //Starts thread |
Swaggie | 15:e61297f9bae9 | 48 | |
Swaggie | 15:e61297f9bae9 | 49 | void DispMessage(string message, bool returnToReadings); //Display given message on screen |
Swaggie | 16:1b3488fb67f5 | 50 | |
Swaggie | 15:e61297f9bae9 | 51 | |
Swaggie | 14:1fb1354ac27c | 52 | }; |
Swaggie | 14:1fb1354ac27c | 53 | |
Swaggie | 14:1fb1354ac27c | 54 | |
Swaggie | 2:5a38ae8459d5 | 55 | #endif |