fuck this
Dependencies: BMP280
LCD.h@18:dff5292d62a9, 2018-01-08 (annotated)
- Committer:
- Swaggie
- Date:
- Mon Jan 08 00:51:09 2018 +0000
- Revision:
- 18:dff5292d62a9
- Parent:
- 17:95b0b1ec0f90
A working class structure with two buttons.
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 | 18:dff5292d62a9 | 14 | #define SCREENDELAY_MS 20000 |
Swaggie | 18:dff5292d62a9 | 15 | |
Swaggie | 18:dff5292d62a9 | 16 | class EnviromLCDDisplay : public TextLCD |
Swaggie | 14:1fb1354ac27c | 17 | { |
Swaggie | 14:1fb1354ac27c | 18 | private: |
Swaggie | 14:1fb1354ac27c | 19 | //private variables |
Swaggie | 14:1fb1354ac27c | 20 | enum ThreadState{MESSAGE,SCROLLREADINGS,ADJUSTTIME}; |
Swaggie | 14:1fb1354ac27c | 21 | |
Swaggie | 14:1fb1354ac27c | 22 | ThreadState _TState; //This determines what function the LCD is doing |
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 | Thread _LCDThread; //Pointer to the therad that will be used for the LCD |
Swaggie | 15:e61297f9bae9 | 32 | PinName _Button1Pin; //Button will change between InterruptIn and DigitalIn. Used to enter time edit mode |
Swaggie | 15:e61297f9bae9 | 33 | DigitalIn _Button2; //Button2 |
Swaggie | 15:e61297f9bae9 | 34 | bool _AutoQuit; //After message is displayed, should LCD return to SCROLLREADINGS? |
Swaggie | 15:e61297f9bae9 | 35 | |
Swaggie | 14:1fb1354ac27c | 36 | //private functions |
Swaggie | 16:1b3488fb67f5 | 37 | void LCDThreadFn(void); //This needs to be attached to a thread |
Swaggie | 16:1b3488fb67f5 | 38 | void TimeButtonISR(void); //Run when Button 1 is set as an interrupt in |
Swaggie | 14:1fb1354ac27c | 39 | public: |
Swaggie | 14:1fb1354ac27c | 40 | //public functions |
Swaggie | 16:1b3488fb67f5 | 41 | EnviromLCDDisplay(PinName rs, PinName e, PinName d4, PinName d5, PinName d6, PinName d7, PinName Button1Pin, PinName Button2); //Constructor |
Swaggie | 15:e61297f9bae9 | 42 | //~EnviromLCDDisplay(); //Destructor |
Swaggie | 14:1fb1354ac27c | 43 | |
Swaggie | 15:e61297f9bae9 | 44 | bool POST(void); //Power On Self Test. Returns true if pass |
Swaggie | 15:e61297f9bae9 | 45 | void Start(void); //Starts thread |
Swaggie | 15:e61297f9bae9 | 46 | |
Swaggie | 15:e61297f9bae9 | 47 | void DispMessage(string message, bool returnToReadings); //Display given message on screen |
Swaggie | 16:1b3488fb67f5 | 48 | |
Swaggie | 15:e61297f9bae9 | 49 | |
Swaggie | 14:1fb1354ac27c | 50 | }; |
Swaggie | 14:1fb1354ac27c | 51 | |
Swaggie | 14:1fb1354ac27c | 52 | |
Swaggie | 2:5a38ae8459d5 | 53 | #endif |