Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BMP280
Revision 16:1b3488fb67f5, committed 2018-01-07
- Comitter:
- Swaggie
- Date:
- Sun Jan 07 00:02:29 2018 +0000
- Parent:
- 15:e61297f9bae9
- Child:
- 17:95b0b1ec0f90
- Commit message:
- Made good progress on LCD functions. Now constructs correctly.
Changed in this revision
| LCD.cpp | Show annotated file Show diff for this revision Revisions of this file |
| LCD.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/LCD.cpp Sat Jan 06 22:54:42 2018 +0000
+++ b/LCD.cpp Sun Jan 07 00:02:29 2018 +0000
@@ -3,7 +3,7 @@
#include "TextLCD.h"
#include "rtos.h"
-EnviromLCDDisplay::EnviromLCDDisplay(PinName rs,PinName e, PinName d4, PinName d5, PinName d6, PinName d7, PinName Button1Pin, PinName Button2/*, Thread& LCDThread, Ticker& DisplayScroll*/) : TextLCD(rs, e, d4, d5, d7, d7), _DisplayScroll(), _LCDThread(), _Button2(Button2)
+EnviromLCDDisplay::EnviromLCDDisplay(PinName rs, PinName e, PinName d4, PinName d5, PinName d6, PinName d7, PinName Button1Pin, PinName Button2) : TextLCD(rs, e, d4, d5, d7, d7), _DisplayScroll(), _LCDThread(), _Button2(Button2)
{
//Initialise all variables
_TState = MESSAGE;
@@ -21,19 +21,62 @@
bool EnviromLCDDisplay::POST(void)
{
- printf("Testing \nPress Btn"); //Print to LCD
- return true;
+ printf("Push Button 1"); //Print to LCD
+ while (!_Button2) {} //Wait until button is pushed
+ return true; //The test has passed
}
void EnviromLCDDisplay::Start(void)
{
DispMessage("Starting", true); //Set the LCD to display message on start
- //_LCDThread->start(this, &EnviromLCDDisplay::LCDThread);
+ _LCDThread.start(this, &EnviromLCDDisplay::LCDThreadFn); //Start the thread runnig
}
void EnviromLCDDisplay::DispMessage(string message, bool returnToReadings)
{
- _message = message;
- _TState = MESSAGE;
- _AutoQuit = returnToReadings;
+ _message = message; //Set internal variable from input
+ _TState = MESSAGE; //Move State machine to message
+ _AutoQuit = returnToReadings; //Set internal variable from input
+}
+
+void EnviromLCDDisplay::LCDThreadFn(void)
+{
+ while (1)
+ {
+ //Setup button 1 as Interrupt In
+ switch (_TState) {
+ case MESSAGE :
+ //display a message on the screen
+
+ cls(); //Clear the screen
+ printf("%s", _message); //Put the message on the screen
+ Thread::wait(3000); //Wait 3 secs before doing anything else
+ if (_AutoQuit && (_TState == MESSAGE)) //Therefore button 1 interrupt won't be overwritten
+ {
+ _TState = SCROLLREADINGS; //Return to showing data
+ _SState = PRESTEMP; //Go to screen 1
+ }
+ break;
+ case SCROLLREADINGS :
+ //Show enviromental readings
+ cls();
+ printf("Pres: xxxx.xmBar\n");
+ printf("Temp: xx.x C");
+ Thread::wait(2000); //Screen hold
+ cls();
+ printf("LDR: xx.x, Taken");
+ printf("HH:mm, DD/MM");
+ Thread::wait(2000);
+ break;
+ case ADJUSTTIME :
+ //Adjust time with userbuttons
+ //delete button 1 as interupt in.
+
+
+ //create button 1 as digital in.
+ break;
+ default :
+ //Error code
+ }
+ }
}
\ No newline at end of file
--- a/LCD.h Sat Jan 06 22:54:42 2018 +0000
+++ b/LCD.h Sun Jan 07 00:02:29 2018 +0000
@@ -35,17 +35,19 @@
bool _AutoQuit; //After message is displayed, should LCD return to SCROLLREADINGS?
//private functions
-
+ void LCDThreadFn(void); //This needs to be attached to a thread
+ void TimeButtonISR(void); //Run when Button 1 is set as an interrupt in
+ void DisplayScrollISR(void);//Run by ticker
public:
//public functions
- EnviromLCDDisplay(PinName rs,PinName e, PinName d4, PinName d5, PinName d6, PinName d7, PinName Button1Pin, PinName Button2/*, Thread& LCDThread, Ticker& DisplayScroll*/); //Constructor
+ EnviromLCDDisplay(PinName rs, PinName e, PinName d4, PinName d5, PinName d6, PinName d7, PinName Button1Pin, PinName Button2); //Constructor
//~EnviromLCDDisplay(); //Destructor
bool POST(void); //Power On Self Test. Returns true if pass
void Start(void); //Starts thread
void DispMessage(string message, bool returnToReadings); //Display given message on screen
- void LCDThread(void); //This needs to be attached to a thread
+
};