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@31:69fedaa9b171, 2019-04-13 (annotated)
- Committer:
- el17ajf
- Date:
- Sat Apr 13 09:53:39 2019 +0000
- Revision:
- 31:69fedaa9b171
- Parent:
- 25:bf47fe41883a
added seeding to rand()
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 | 31:69fedaa9b171 | 6 | SampledIn a_button(PTB9); |
| el17ajf | 31:69fedaa9b171 | 7 | SampledIn b_button(PTD0); |
| el17ajf | 31:69fedaa9b171 | 8 | SampledIn x_button(PTC17); |
| el17ajf | 31:69fedaa9b171 | 9 | SampledIn y_button(PTC12); |
| el17ajf | 31:69fedaa9b171 | 10 | SampledIn l_button(PTB18); |
| el17ajf | 31:69fedaa9b171 | 11 | SampledIn r_button(PTB3); |
| el17ajf | 31:69fedaa9b171 | 12 | SampledIn back_button(PTB19); |
| el17ajf | 31:69fedaa9b171 | 13 | SampledIn start_button(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 | 31:69fedaa9b171 | 18 | return a_button.hit_frame(); |
| el17ajf | 25:bf47fe41883a | 19 | case RIGHT: |
| el17ajf | 31:69fedaa9b171 | 20 | return y_button.hit_frame(); |
| el17ajf | 25:bf47fe41883a | 21 | case UP: |
| el17ajf | 31:69fedaa9b171 | 22 | return x_button.hit_frame(); |
| el17ajf | 25:bf47fe41883a | 23 | case DOWN: |
| el17ajf | 31:69fedaa9b171 | 24 | return b_button.hit_frame(); |
| el17ajf | 25:bf47fe41883a | 25 | case START: |
| el17ajf | 31:69fedaa9b171 | 26 | return start_button.hit_frame(); |
| el17ajf | 25:bf47fe41883a | 27 | default: |
| el17ajf | 25:bf47fe41883a | 28 | return false; |
| el17ajf | 9:3a7776a29a11 | 29 | } |
| el17ajf | 9:3a7776a29a11 | 30 | } |
| el17ajf | 31:69fedaa9b171 | 31 | |
| el17ajf | 31:69fedaa9b171 | 32 | int getSeed() { |
| el17ajf | 31:69fedaa9b171 | 33 | AnalogIn noise(PTB11); // get noise from joystick horizontal axis |
| el17ajf | 31:69fedaa9b171 | 34 | return noise.read_u16(); |
| el17ajf | 31:69fedaa9b171 | 35 | } |
| el17ajf | 25:bf47fe41883a | 36 | }; |
