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@8:ad8e2dd314a2, 2015-11-10 (annotated)
- Committer:
- Oschofield
- Date:
- Tue Nov 10 12:46:47 2015 +0000
- Revision:
- 8:ad8e2dd314a2
- Parent:
- 7:1e9cd1481e80
- Child:
- 9:a018d7c05dc7
Altered the getPulse to work ;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Oschofield | 1:16b0f2898739 | 1 | #include "button.h" //header file included |
Oschofield | 7:1e9cd1481e80 | 2 | |
Oschofield | 1:16b0f2898739 | 3 | |
Oschofield | 1:16b0f2898739 | 4 | Button::Button(string s){ |
Oschofield | 1:16b0f2898739 | 5 | if (s == "user"){ |
Oschofield | 1:16b0f2898739 | 6 | pin = new DigitalIn(PA_0); |
Oschofield | 1:16b0f2898739 | 7 | } |
Oschofield | 1:16b0f2898739 | 8 | } |
Oschofield | 1:16b0f2898739 | 9 | |
Oschofield | 2:e3cd1e0c3b78 | 10 | bool Button::ifPressed(){ |
Oschofield | 2:e3cd1e0c3b78 | 11 | return *pin; |
Oschofield | 8:ad8e2dd314a2 | 12 | } |
Oschofield | 8:ad8e2dd314a2 | 13 | |
Oschofield | 8:ad8e2dd314a2 | 14 | float getPulse(){ |
Oschofield | 8:ad8e2dd314a2 | 15 | while(button.isPressed()== false{ |
Oschofield | 8:ad8e2dd314a2 | 16 | //DO NADA |
Oschofield | 8:ad8e2dd314a2 | 17 | } |
Oschofield | 8:ad8e2dd314a2 | 18 | |
Oschofield | 8:ad8e2dd314a2 | 19 | Timer timer; |
Oschofield | 8:ad8e2dd314a2 | 20 | timer.start(); |
Oschofield | 8:ad8e2dd314a2 | 21 | |
Oschofield | 8:ad8e2dd314a2 | 22 | while(button.isPressed()== true{ |
Oschofield | 8:ad8e2dd314a2 | 23 | wait(0.01f); |
Oschofield | 8:ad8e2dd314a2 | 24 | } |
Oschofield | 8:ad8e2dd314a2 | 25 | timer.stop(); |
Oschofield | 8:ad8e2dd314a2 | 26 | return timer.read(); |
Oschofield | 7:1e9cd1481e80 | 27 | } |