ELEC350 Coursework Repository
Dependencies: TextLCD mbed-rtos mbed
Revision 0:8f564feffdd8, committed 2017-11-25
- Comitter:
- thomasmorris
- Date:
- Sat Nov 25 15:39:56 2017 +0000
- Commit message:
- Version_1.0; Working LCD
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Led.cpp Sat Nov 25 15:39:56 2017 +0000 @@ -0,0 +1,32 @@ +#include "mbed.h" +#include "Led.h" + + +Led::Led(PinName pinName):pin(pinName)//Constuctor +//Constuctor runs whenever a new instave of the class is created +//The constructor has the same name as the class +//The constructor does not have a return type +//When called it needs to be given parameters Led redLed(D7); +{ + +} + +void Led::switchOn() //type void class is Led function is switchon +{ + this->pin =1; //You access the attributes of the class by using the this command and then the name of the attribute +} + +void Led::switchOff() +{ + this->pin =0; +} +void Led::flash(float time) +{ + this->pin = 1; + wait(time); + this->pin = 0; +} +void Led::Toggle() +{ + this->pin= !this->pin; +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Led.h Sat Nov 25 15:39:56 2017 +0000 @@ -0,0 +1,21 @@ +#ifndef _LED_H_ //Known as header guards +#define _LED_H_ + +class Led //This creates a class called Led +{ + +//Below are methods of the class these are the opperations the class will support +public: //The public: word enables the methods to be accessed outside of the class itself + + Led(PinName pinName); + void switchOn(); //Void is the return type as no values will be output the return type is void + void switchOff(); //SwitchOff is the name of the method/function + void flash(float time); //float time is the parameter of the function in this case it creates a floating poi t variable known as time and this is then passed o the function when called. + void Toggle(); + +private: //This is used here to make digitalout pin only useable from inside class Led + DigitalOut pin; //DigitalOut is the Class and the object is called pin the object pin is now an attribute of led this is also known as a member variable or field +}; + + +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextLCD.lib Sat Nov 25 15:39:56 2017 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/simon/code/TextLCD/#308d188a2d3a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Nov 25 15:39:56 2017 +0000 @@ -0,0 +1,25 @@ +#include "mbed.h" +#include "Led.h" +#include "rtos.h" +#include "TextLCD.h" + +Led GreenLed(D5); +TextLCD lcd(A0, A1, A2, A3, A4, A5,TextLCD::LCD16x2); // rs, e, d4-d7 Sets up LCD +float TimeBase = 0.5; +Thread LCD; +float LDR = 1.5; +void LCD_Thread() +{ + lcd.printf("LDR Value is %1.1f \n",LDR); +} +int main() +{ + + LCD.start(LCD_Thread); + GreenLed.switchOff(); + while(1) + { + GreenLed.Toggle(); + wait(TimeBase); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-rtos.lib Sat Nov 25 15:39:56 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed-rtos/#5713cbbdb706
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Nov 25 15:39:56 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/675da3299148 \ No newline at end of file