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.
button.cpp
- Committer:
- Oschofield
- Date:
- 2015-11-12
- Revision:
- 15:4127ef0f7038
- Parent:
- 14:6427883f5900
File content as of revision 15:4127ef0f7038:
#include "button.h" //header file included
Button::Button(string s){
if (s == "user"){
pin = new DigitalIn(PA_0);
}
}
bool Button::ifPressed(){
return *pin;
}
float Button::getPulse(float timeout)
{
Timer timer;
timer.start();
while(this->ifPressed()== false){
if (timeout != -1.0f && timer.read() > timeout){
return -1.0f;
}
}
timer.reset();
while(this->ifPressed() == true){
}
timer.stop();
return timer.read();
}