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@7:9e9424f5ec4b, 2019-05-04 (annotated)
- Committer:
- batJoro
- Date:
- Sat May 04 00:11:14 2019 +0000
- Revision:
- 7:9e9424f5ec4b
- Parent:
- 6:4c55dd4b6d42
- Child:
- 8:b3738229ba85
engine2
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| batJoro | 1:3183193cf44e | 1 | |
| batJoro | 0:a0dedca5e89f | 2 | |
| batJoro | 0:a0dedca5e89f | 3 | /* |
| batJoro | 0:a0dedca5e89f | 4 | ELEC2645 Embedded Systems Project |
| batJoro | 0:a0dedca5e89f | 5 | School of Electronic & Electrical Engineering University of Leeds |
| batJoro | 0:a0dedca5e89f | 6 | |
| batJoro | 0:a0dedca5e89f | 7 | Name: Dobri Tsvetkov |
| batJoro | 0:a0dedca5e89f | 8 | Username: el17dtt |
| batJoro | 0:a0dedca5e89f | 9 | Student ID Number: 201154059 |
| batJoro | 0:a0dedca5e89f | 10 | Date: 12.03.2019 |
| batJoro | 0:a0dedca5e89f | 11 | */ |
| batJoro | 0:a0dedca5e89f | 12 | |
| batJoro | 3:f686f6d7bdff | 13 | |
| batJoro | 5:5e92567d0a44 | 14 | #include "mbed.h" |
| batJoro | 5:5e92567d0a44 | 15 | #include "Gamepad.h" |
| batJoro | 5:5e92567d0a44 | 16 | #include "N5110.h" |
| batJoro | 5:5e92567d0a44 | 17 | #include "menu.h" |
| batJoro | 6:4c55dd4b6d42 | 18 | #include "engine.h" |
| batJoro | 6:4c55dd4b6d42 | 19 | |
| batJoro | 6:4c55dd4b6d42 | 20 | |
| batJoro | 5:5e92567d0a44 | 21 | |
| batJoro | 3:f686f6d7bdff | 22 | /////////////// structs ///////////////// |
| batJoro | 3:f686f6d7bdff | 23 | |
| batJoro | 3:f686f6d7bdff | 24 | |
| batJoro | 3:f686f6d7bdff | 25 | /////////////// objects /////////////// |
| batJoro | 3:f686f6d7bdff | 26 | N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); |
| batJoro | 1:3183193cf44e | 27 | Gamepad gamepad; |
| batJoro | 1:3183193cf44e | 28 | |
| batJoro | 3:f686f6d7bdff | 29 | ///////////// prototypes /////////////// |
| batJoro | 4:2deeeeb6c1e1 | 30 | void init(); |
| batJoro | 4:2deeeeb6c1e1 | 31 | void welcome(); |
| batJoro | 6:4c55dd4b6d42 | 32 | void render(); |
| batJoro | 3:f686f6d7bdff | 33 | |
| batJoro | 3:f686f6d7bdff | 34 | ///////////// functions //////////////// |
| batJoro | 0:a0dedca5e89f | 35 | int main() { |
| batJoro | 0:a0dedca5e89f | 36 | |
| batJoro | 4:2deeeeb6c1e1 | 37 | init(); |
| batJoro | 1:3183193cf44e | 38 | |
| batJoro | 6:4c55dd4b6d42 | 39 | welcome(); |
| batJoro | 6:4c55dd4b6d42 | 40 | |
| batJoro | 6:4c55dd4b6d42 | 41 | // game loop - read input, update the game state and render the display |
| batJoro | 6:4c55dd4b6d42 | 42 | while(1) { |
| batJoro | 6:4c55dd4b6d42 | 43 | render(); |
| batJoro | 4:2deeeeb6c1e1 | 44 | } |
| batJoro | 4:2deeeeb6c1e1 | 45 | } |
| batJoro | 3:f686f6d7bdff | 46 | |
| batJoro | 4:2deeeeb6c1e1 | 47 | // initialies all classes and libraries |
| batJoro | 4:2deeeeb6c1e1 | 48 | void init() |
| batJoro | 4:2deeeeb6c1e1 | 49 | { |
| batJoro | 6:4c55dd4b6d42 | 50 | |
| batJoro | 4:2deeeeb6c1e1 | 51 | // need to initialise LCD and Gamepad |
| batJoro | 4:2deeeeb6c1e1 | 52 | lcd.init(); |
| batJoro | 4:2deeeeb6c1e1 | 53 | gamepad.init(); |
| batJoro | 4:2deeeeb6c1e1 | 54 | |
| batJoro | 4:2deeeeb6c1e1 | 55 | gamepad.leds_on(); |
| batJoro | 4:2deeeeb6c1e1 | 56 | lcd.setContrast(0.4); |
| batJoro | 4:2deeeeb6c1e1 | 57 | } |
| batJoro | 6:4c55dd4b6d42 | 58 | // function to call the intro method of the menu class |
| batJoro | 4:2deeeeb6c1e1 | 59 | void welcome() { |
| batJoro | 4:2deeeeb6c1e1 | 60 | |
| batJoro | 4:2deeeeb6c1e1 | 61 | Menu menu; |
| batJoro | 6:4c55dd4b6d42 | 62 | menu.intro(lcd, gamepad); |
| batJoro | 7:9e9424f5ec4b | 63 | menu.startMainMenu(lcd, gamepad); |
| batJoro | 6:4c55dd4b6d42 | 64 | } |
| batJoro | 6:4c55dd4b6d42 | 65 | // this function draws each frame on the LCD |
| batJoro | 6:4c55dd4b6d42 | 66 | void render() { |
| batJoro | 6:4c55dd4b6d42 | 67 | |
| batJoro | 6:4c55dd4b6d42 | 68 | lcd.clear(); |
| batJoro | 6:4c55dd4b6d42 | 69 | lcd.refresh(); |
| batJoro | 0:a0dedca5e89f | 70 | } |