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.
Dependencies: mbed
Fork of el17ajf by
Input/Input.cpp@25:bf47fe41883a, 2019-04-04 (annotated)
- Committer:
- el17ajf
- Date:
- Thu Apr 04 15:53:06 2019 +0000
- Revision:
- 25:bf47fe41883a
- Parent:
- 22:0a474f074553
- Child:
- 31:69fedaa9b171
Added debouncing with SampledIn class
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| el17ajf | 5:3efbdcb3efaf | 1 | #include "Input.h" |
| el17ajf | 25:bf47fe41883a | 2 | #include "SampledIn.h" |
| el17ajf | 25:bf47fe41883a | 3 | |
| el17ajf | 13:59e17cab320a | 4 | namespace Input { |
| el17ajf | 13:59e17cab320a | 5 | |
| el17ajf | 25:bf47fe41883a | 6 | SampledIn aButton(PTB9); |
| el17ajf | 25:bf47fe41883a | 7 | SampledIn bButton(PTD0); |
| el17ajf | 25:bf47fe41883a | 8 | SampledIn xButton(PTC17); |
| el17ajf | 25:bf47fe41883a | 9 | SampledIn yButton(PTC12); |
| el17ajf | 25:bf47fe41883a | 10 | SampledIn lButton(PTB18); |
| el17ajf | 25:bf47fe41883a | 11 | SampledIn rButton(PTB3); |
| el17ajf | 25:bf47fe41883a | 12 | SampledIn backButton(PTB19); |
| el17ajf | 25:bf47fe41883a | 13 | SampledIn startButton(PTC5); |
| el17ajf | 13:59e17cab320a | 14 | |
| el17ajf | 25:bf47fe41883a | 15 | bool buttonHit(Button button) { |
| el17ajf | 25:bf47fe41883a | 16 | switch (button) { |
| el17ajf | 25:bf47fe41883a | 17 | case LEFT: |
| el17ajf | 25:bf47fe41883a | 18 | return aButton.hit_frame(); |
| el17ajf | 25:bf47fe41883a | 19 | case RIGHT: |
| el17ajf | 25:bf47fe41883a | 20 | return yButton.hit_frame(); |
| el17ajf | 25:bf47fe41883a | 21 | case UP: |
| el17ajf | 25:bf47fe41883a | 22 | return xButton.hit_frame(); |
| el17ajf | 25:bf47fe41883a | 23 | case DOWN: |
| el17ajf | 25:bf47fe41883a | 24 | return bButton.hit_frame(); |
| el17ajf | 25:bf47fe41883a | 25 | case START: |
| el17ajf | 25:bf47fe41883a | 26 | return startButton.hit_frame(); |
| el17ajf | 25:bf47fe41883a | 27 | default: |
| el17ajf | 25:bf47fe41883a | 28 | return false; |
| el17ajf | 9:3a7776a29a11 | 29 | } |
| el17ajf | 9:3a7776a29a11 | 30 | } |
| el17ajf | 25:bf47fe41883a | 31 | }; |
