Time: 17:33 Date: 10/12/2017 Description: Task 1,7,8 Currently Functioning
Dependencies: BME280 BMP280 TextLCD
Working Repository
LED.cpp@50:3d61ca637399, 2018-01-09 (annotated)
- Committer:
- thomasmorris
- Date:
- Tue Jan 09 12:19:12 2018 +0000
- Revision:
- 50:3d61ca637399
- Parent:
- 5:2594b953f111
Dynamic Dating Working
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
thomasmorris | 5:2594b953f111 | 1 | #include "mbed.h" |
thomasmorris | 5:2594b953f111 | 2 | #include "LED.hpp" |
thomasmorris | 5:2594b953f111 | 3 | |
thomasmorris | 5:2594b953f111 | 4 | |
thomasmorris | 5:2594b953f111 | 5 | LED::LED(PinName pinName):pin(pinName)//Constuctor |
thomasmorris | 5:2594b953f111 | 6 | //Constuctor runs whenever a new instave of the class is created |
thomasmorris | 5:2594b953f111 | 7 | //The constructor has the same name as the class |
thomasmorris | 5:2594b953f111 | 8 | //The constructor does not have a return type |
thomasmorris | 5:2594b953f111 | 9 | //When called it needs to be given parameters Led redLed(D7); |
thomasmorris | 5:2594b953f111 | 10 | { |
thomasmorris | 5:2594b953f111 | 11 | |
thomasmorris | 5:2594b953f111 | 12 | } |
thomasmorris | 5:2594b953f111 | 13 | |
thomasmorris | 5:2594b953f111 | 14 | void LED::switchOn() //type void class is Led function is switchon |
thomasmorris | 5:2594b953f111 | 15 | { |
thomasmorris | 5:2594b953f111 | 16 | this->pin =1; //You access the attributes of the class by using the this command and then the name of the attribute |
thomasmorris | 5:2594b953f111 | 17 | } |
thomasmorris | 5:2594b953f111 | 18 | |
thomasmorris | 5:2594b953f111 | 19 | void LED::switchOff() |
thomasmorris | 5:2594b953f111 | 20 | { |
thomasmorris | 5:2594b953f111 | 21 | this->pin =0; |
thomasmorris | 5:2594b953f111 | 22 | } |
thomasmorris | 5:2594b953f111 | 23 | void LED::flash(float time) |
thomasmorris | 5:2594b953f111 | 24 | { |
thomasmorris | 5:2594b953f111 | 25 | this->pin = 1; |
thomasmorris | 5:2594b953f111 | 26 | wait(time); |
thomasmorris | 5:2594b953f111 | 27 | this->pin = 0; |
thomasmorris | 5:2594b953f111 | 28 | } |
thomasmorris | 5:2594b953f111 | 29 | void LED::Toggle() |
thomasmorris | 5:2594b953f111 | 30 | { |
thomasmorris | 5:2594b953f111 | 31 | this->pin= !this->pin; |
thomasmorris | 5:2594b953f111 | 32 | } |