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.
main.cpp@6:952ac12c7f00, 2019-04-07 (annotated)
- Committer:
- JamesCummins
- Date:
- Sun Apr 07 10:36:53 2019 +0000
- Revision:
- 6:952ac12c7f00
- Parent:
- 5:7e8f5fad7b6b
- Child:
- 7:6eb9cade57ab
Button advance working
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JamesCummins | 0:7c96d84b673e | 1 | /* |
JamesCummins | 0:7c96d84b673e | 2 | ELEC2645 Embedded Systems Project |
JamesCummins | 0:7c96d84b673e | 3 | School of Electronic & Electrical Engineering |
JamesCummins | 0:7c96d84b673e | 4 | University of Leeds |
JamesCummins | 0:7c96d84b673e | 5 | Name: James Nathan Cummins |
JamesCummins | 0:7c96d84b673e | 6 | Username: el17jnc |
JamesCummins | 0:7c96d84b673e | 7 | Student ID Number: 201096364 |
JamesCummins | 0:7c96d84b673e | 8 | Date: 22/03/19 |
JamesCummins | 0:7c96d84b673e | 9 | */ |
JamesCummins | 0:7c96d84b673e | 10 | |
JamesCummins | 0:7c96d84b673e | 11 | #include "Gamepad.h" |
JamesCummins | 0:7c96d84b673e | 12 | #include "mbed.h" |
JamesCummins | 1:99d524f81566 | 13 | #include "N5110.h" |
JamesCummins | 0:7c96d84b673e | 14 | |
JamesCummins | 6:952ac12c7f00 | 15 | Gamepad gamepad; |
JamesCummins | 0:7c96d84b673e | 16 | N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); |
JamesCummins | 6:952ac12c7f00 | 17 | bool startmenu(); |
JamesCummins | 0:7c96d84b673e | 18 | |
JamesCummins | 0:7c96d84b673e | 19 | int main(){ |
JamesCummins | 6:952ac12c7f00 | 20 | gamepad.init(); |
JamesCummins | 0:7c96d84b673e | 21 | lcd.init(); |
JamesCummins | 4:2f01b85e57f9 | 22 | wait(1); |
JamesCummins | 6:952ac12c7f00 | 23 | bool cont = startmenu(); |
JamesCummins | 6:952ac12c7f00 | 24 | |
JamesCummins | 0:7c96d84b673e | 25 | } |
JamesCummins | 0:7c96d84b673e | 26 | |
JamesCummins | 6:952ac12c7f00 | 27 | bool startmenu() { |
JamesCummins | 1:99d524f81566 | 28 | lcd.clear(); |
JamesCummins | 5:7e8f5fad7b6b | 29 | char gamename[] = {'L', 'A', 'B', 'Y', 'R', 'I', 'N', 'T', 'H', ' ', ' ', '\0'}; |
JamesCummins | 3:f2e5ffd2b94c | 30 | int i = 0; |
JamesCummins | 5:7e8f5fad7b6b | 31 | for(int a = 0; a < 35; a++){ |
JamesCummins | 4:2f01b85e57f9 | 32 | lcd.clear(); |
JamesCummins | 4:2f01b85e57f9 | 33 | lcd.drawCircle(24+2*a, 21, 3, FILL_BLACK); |
JamesCummins | 4:2f01b85e57f9 | 34 | for (i = 0; i < a/3; i++) { |
JamesCummins | 4:2f01b85e57f9 | 35 | lcd.printChar(gamename[i], 15+i*6, 2); |
JamesCummins | 4:2f01b85e57f9 | 36 | lcd.refresh(); |
JamesCummins | 4:2f01b85e57f9 | 37 | } |
JamesCummins | 4:2f01b85e57f9 | 38 | wait(0.05); |
JamesCummins | 4:2f01b85e57f9 | 39 | } |
JamesCummins | 5:7e8f5fad7b6b | 40 | lcd.printString("Press start", 9, 4); |
JamesCummins | 5:7e8f5fad7b6b | 41 | lcd.printString("to play >", 15, 5); |
JamesCummins | 6:952ac12c7f00 | 42 | lcd.refresh(); |
JamesCummins | 6:952ac12c7f00 | 43 | bool advance = false; |
JamesCummins | 6:952ac12c7f00 | 44 | while (!advance){ |
JamesCummins | 6:952ac12c7f00 | 45 | if (gamepad.check_event(gamepad.START_PRESSED)){ |
JamesCummins | 6:952ac12c7f00 | 46 | lcd.clear(); |
JamesCummins | 6:952ac12c7f00 | 47 | lcd.refresh(); |
JamesCummins | 6:952ac12c7f00 | 48 | advance = true; |
JamesCummins | 6:952ac12c7f00 | 49 | } |
JamesCummins | 6:952ac12c7f00 | 50 | else { advance = false; } |
JamesCummins | 6:952ac12c7f00 | 51 | } |
JamesCummins | 6:952ac12c7f00 | 52 | return advance; |
JamesCummins | 0:7c96d84b673e | 53 | } |