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
main.cpp@4:03d13a53308c, 2019-04-22 (annotated)
- Committer:
- el17cr
- Date:
- Mon Apr 22 16:14:49 2019 +0000
- Revision:
- 4:03d13a53308c
- Parent:
- 3:5edefa83f8f0
- Child:
- 5:1a9d84df7207
Function added to check for end goal. Line object created
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| el17cr | 0:adb2f501dd61 | 1 | /* |
| el17cr | 0:adb2f501dd61 | 2 | ELEC2645 Embedded Systems Project |
| el17cr | 0:adb2f501dd61 | 3 | School of Electronic & Electrical Engineering |
| el17cr | 0:adb2f501dd61 | 4 | University of Leeds |
| el17cr | 0:adb2f501dd61 | 5 | Name: |
| el17cr | 0:adb2f501dd61 | 6 | Username: |
| el17cr | 0:adb2f501dd61 | 7 | Student ID Number: |
| el17cr | 0:adb2f501dd61 | 8 | Date: |
| el17cr | 0:adb2f501dd61 | 9 | */ |
| el17cr | 2:7f91a86b4dc0 | 10 | |
| el17cr | 2:7f91a86b4dc0 | 11 | #include "mbed.h" |
| el17cr | 2:7f91a86b4dc0 | 12 | #include "Gamepad.h" |
| el17cr | 2:7f91a86b4dc0 | 13 | #include "N5110.h" |
| el17cr | 2:7f91a86b4dc0 | 14 | #include "Falldown.h" |
| el17cr | 2:7f91a86b4dc0 | 15 | |
| el17cr | 3:5edefa83f8f0 | 16 | //#define GROUND_WIDTH 70 |
| el17cr | 2:7f91a86b4dc0 | 17 | #define GROUND_HEIGHT 2 |
| el17cr | 3:5edefa83f8f0 | 18 | #define BALL_SIZE 3 |
| el17cr | 3:5edefa83f8f0 | 19 | |
| el17cr | 2:7f91a86b4dc0 | 20 | |
| el17cr | 2:7f91a86b4dc0 | 21 | |
| el17cr | 2:7f91a86b4dc0 | 22 | |
| el17cr | 2:7f91a86b4dc0 | 23 | struct UserInput { |
| el17cr | 2:7f91a86b4dc0 | 24 | Direction d; |
| el17cr | 2:7f91a86b4dc0 | 25 | float mag; |
| el17cr | 2:7f91a86b4dc0 | 26 | }; |
| el17cr | 2:7f91a86b4dc0 | 27 | |
| el17cr | 2:7f91a86b4dc0 | 28 | N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); // K64F - pwr from 3V3 |
| el17cr | 2:7f91a86b4dc0 | 29 | Gamepad pad; |
| el17cr | 2:7f91a86b4dc0 | 30 | Falldown falldown; |
| el17cr | 2:7f91a86b4dc0 | 31 | |
| el17cr | 2:7f91a86b4dc0 | 32 | void init(); |
| el17cr | 2:7f91a86b4dc0 | 33 | void update_game(UserInput input); |
| el17cr | 2:7f91a86b4dc0 | 34 | void render(); |
| el17cr | 2:7f91a86b4dc0 | 35 | |
| el17cr | 2:7f91a86b4dc0 | 36 | int main() |
| el17cr | 2:7f91a86b4dc0 | 37 | { |
| el17cr | 2:7f91a86b4dc0 | 38 | init(); |
| el17cr | 2:7f91a86b4dc0 | 39 | render(); |
| el17cr | 2:7f91a86b4dc0 | 40 | wait(0.1); |
| el17cr | 2:7f91a86b4dc0 | 41 | while (1) { |
| el17cr | 2:7f91a86b4dc0 | 42 | falldown.read_input(pad); |
| el17cr | 2:7f91a86b4dc0 | 43 | falldown.update(pad); |
| el17cr | 2:7f91a86b4dc0 | 44 | render(); |
| el17cr | 2:7f91a86b4dc0 | 45 | wait(0.1); |
| el17cr | 2:7f91a86b4dc0 | 46 | } |
| el17cr | 2:7f91a86b4dc0 | 47 | } |
| el17cr | 2:7f91a86b4dc0 | 48 | |
| el17cr | 2:7f91a86b4dc0 | 49 | void init() |
| el17cr | 2:7f91a86b4dc0 | 50 | { |
| el17cr | 2:7f91a86b4dc0 | 51 | lcd.init(); |
| el17cr | 2:7f91a86b4dc0 | 52 | pad.init(); |
| el17cr | 2:7f91a86b4dc0 | 53 | |
| el17cr | 3:5edefa83f8f0 | 54 | falldown.init(GROUND_HEIGHT,BALL_SIZE); |
| el17cr | 2:7f91a86b4dc0 | 55 | } |
| el17cr | 2:7f91a86b4dc0 | 56 | |
| el17cr | 2:7f91a86b4dc0 | 57 | void render() |
| el17cr | 2:7f91a86b4dc0 | 58 | { |
| el17cr | 2:7f91a86b4dc0 | 59 | |
| el17cr | 4:03d13a53308c | 60 | lcd.clear(); |
| el17cr | 2:7f91a86b4dc0 | 61 | falldown.draw(lcd); |
| el17cr | 2:7f91a86b4dc0 | 62 | lcd.refresh(); |
| el17cr | 2:7f91a86b4dc0 | 63 | |
| el17cr | 4:03d13a53308c | 64 | } |