Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
7148_Labs_2223/Session2/Solution_Classes/src/flasher.cpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
38 lines (30 sloc)
753 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* cpp file to go with the header. | |
In here we define all the program logic, | |
matching the function signatures in the header file. | |
NOTE: We just include functionality here. | |
Class variables etc come from the header file. | |
*/ | |
#include "flasher.h" | |
#include "mbed.h" | |
// Define our constructor | |
Flasher::Flasher(PinName thePin, int startState) : theLed(thePin){ | |
state = startState; | |
} | |
// Define Flash Functionality. | |
void Flasher::flash(){ | |
if (state == 0){ | |
theLed = 1; | |
thread_sleep_for(1000); | |
theLed = 0; | |
thread_sleep_for(1000); | |
} | |
else { | |
theLed = 1; | |
thread_sleep_for(5000); | |
theLed = 0; | |
thread_sleep_for(5000); | |
} | |
} | |
void Flasher::set_state(int the_state){ | |
state = the_state; | |
} | |