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@11:444afcb2f59f, 2015-11-12 (annotated)
- Committer:
- Oschofield
- Date:
- Thu Nov 12 11:45:22 2015 +0000
- Revision:
- 11:444afcb2f59f
- Parent:
- 10:8a6ecbf764fa
- Child:
- 12:08a1971c9441
see prev.
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 | 11:444afcb2f59f | 14 | float Button::getPulse(float timeout) |
| Oschofield | 9:a018d7c05dc7 | 15 | { |
| Oschofield | 9:a018d7c05dc7 | 16 | while(this->ifPressed()== false){ |
| Oschofield | 8:ad8e2dd314a2 | 17 | //DO NADA |
| Oschofield | 8:ad8e2dd314a2 | 18 | } |
| Oschofield | 8:ad8e2dd314a2 | 19 | |
| Oschofield | 8:ad8e2dd314a2 | 20 | Timer timer; |
| Oschofield | 8:ad8e2dd314a2 | 21 | timer.start(); |
| Oschofield | 8:ad8e2dd314a2 | 22 | |
| Oschofield | 10:8a6ecbf764fa | 23 | while(this->ifPressed()== false){ |
| Oschofield | 10:8a6ecbf764fa | 24 | if (timeout != -1.0f && timer.read() > timeout){ |
| Oschofield | 10:8a6ecbf764fa | 25 | return -1.0f; |
| Oschofield | 8:ad8e2dd314a2 | 26 | } |
| Oschofield | 10:8a6ecbf764fa | 27 | |
| Oschofield | 8:ad8e2dd314a2 | 28 | timer.stop(); |
| Oschofield | 8:ad8e2dd314a2 | 29 | return timer.read(); |
| Oschofield | 7:1e9cd1481e80 | 30 | } |