Plymouth ELEC351 Group T
/
ELEC351_Group_T
FINAL PROJECT isn't it
Fork of ELEC351 by
LED.cpp@52:99915f5240b2, 2018-01-09 (annotated)
- Committer:
- thomasmorris
- Date:
- Tue Jan 09 22:27:49 2018 +0000
- Revision:
- 52:99915f5240b2
- Parent:
- 51:47f5db68500b
ITS THE FINAL COMMIT MESSAGE DO DO DO DO DO
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
thomasmorris | 5:2594b953f111 | 1 | #include "LED.hpp" |
thomasmorris | 5:2594b953f111 | 2 | |
thomasmorris | 5:2594b953f111 | 3 | |
thomasmorris | 5:2594b953f111 | 4 | LED::LED(PinName pinName):pin(pinName)//Constuctor |
thomasmorris | 5:2594b953f111 | 5 | //Constuctor runs whenever a new instave of the class is created |
thomasmorris | 5:2594b953f111 | 6 | //The constructor has the same name as the class |
thomasmorris | 5:2594b953f111 | 7 | //The constructor does not have a return type |
thomasmorris | 5:2594b953f111 | 8 | //When called it needs to be given parameters Led redLed(D7); |
thomasmorris | 5:2594b953f111 | 9 | { |
thomasmorris | 5:2594b953f111 | 10 | |
thomasmorris | 5:2594b953f111 | 11 | } |
thomasmorris | 5:2594b953f111 | 12 | |
thomasmorris | 5:2594b953f111 | 13 | void LED::switchOn() //type void class is Led function is switchon |
thomasmorris | 5:2594b953f111 | 14 | { |
thomasmorris | 5:2594b953f111 | 15 | 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 | 16 | } |
thomasmorris | 5:2594b953f111 | 17 | |
thomasmorris | 51:47f5db68500b | 18 | void LED::switchOff()//Turns off the LED |
thomasmorris | 5:2594b953f111 | 19 | { |
thomasmorris | 5:2594b953f111 | 20 | this->pin =0; |
thomasmorris | 5:2594b953f111 | 21 | } |
thomasmorris | 51:47f5db68500b | 22 | void LED::flash(float time)//Flashes the LED for the time passed in |
thomasmorris | 5:2594b953f111 | 23 | { |
thomasmorris | 5:2594b953f111 | 24 | this->pin = 1; |
thomasmorris | 52:99915f5240b2 | 25 | Thread::wait(time); |
thomasmorris | 5:2594b953f111 | 26 | this->pin = 0; |
thomasmorris | 5:2594b953f111 | 27 | } |
thomasmorris | 51:47f5db68500b | 28 | void LED::Toggle()//Toggles the current state of the LED |
thomasmorris | 5:2594b953f111 | 29 | { |
thomasmorris | 5:2594b953f111 | 30 | this->pin= !this->pin; |
thomasmorris | 5:2594b953f111 | 31 | } |