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@1:09a835e6d063, 2020-06-02 (annotated)
- Committer:
- Psy1990
- Date:
- Tue Jun 02 21:33:00 2020 +0000
- Revision:
- 1:09a835e6d063
- Parent:
- 0:7423345f87c5
- Child:
- 2:c6772c5ab69d
For some reason my original project wasn't working so had to make a new one. Even though all the files were exactly the same (I coppied and pasted several times) the first project wouldn't do anything :( This project works for now
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Psy1990 | 1:09a835e6d063 | 1 | /* |
Psy1990 | 1:09a835e6d063 | 2 | ELEC2645 Embedded Systems Project |
Psy1990 | 1:09a835e6d063 | 3 | School of Electronic & Electrical Engineering |
Psy1990 | 1:09a835e6d063 | 4 | University of Leeds |
Psy1990 | 1:09a835e6d063 | 5 | 2019/20 |
Psy1990 | 1:09a835e6d063 | 6 | |
Psy1990 | 1:09a835e6d063 | 7 | Name: Simon Thackray Atkinson |
Psy1990 | 1:09a835e6d063 | 8 | Username: el18s2a |
Psy1990 | 1:09a835e6d063 | 9 | Student ID Number: 201255483 |
Psy1990 | 1:09a835e6d063 | 10 | Date: 05/03/2020 |
Psy1990 | 1:09a835e6d063 | 11 | */ |
Psy1990 | 1:09a835e6d063 | 12 | |
eencae | 0:7423345f87c5 | 13 | ///////// pre-processor directives //////// |
eencae | 0:7423345f87c5 | 14 | #include "mbed.h" |
eencae | 0:7423345f87c5 | 15 | #include "Gamepad.h" |
eencae | 0:7423345f87c5 | 16 | #include "N5110.h" |
eencae | 0:7423345f87c5 | 17 | |
eencae | 0:7423345f87c5 | 18 | |
eencae | 0:7423345f87c5 | 19 | |
eencae | 0:7423345f87c5 | 20 | /////////////// structs ///////////////// |
eencae | 0:7423345f87c5 | 21 | struct UserInput { |
eencae | 0:7423345f87c5 | 22 | Direction d; |
eencae | 0:7423345f87c5 | 23 | float mag; |
eencae | 0:7423345f87c5 | 24 | }; |
eencae | 0:7423345f87c5 | 25 | /////////////// objects /////////////// |
eencae | 0:7423345f87c5 | 26 | N5110 lcd; |
eencae | 0:7423345f87c5 | 27 | Gamepad pad; |
Psy1990 | 1:09a835e6d063 | 28 | |
eencae | 0:7423345f87c5 | 29 | |
Psy1990 | 1:09a835e6d063 | 30 | |
eencae | 0:7423345f87c5 | 31 | void welcome(); |
eencae | 0:7423345f87c5 | 32 | |
eencae | 0:7423345f87c5 | 33 | ///////////// functions //////////////// |
Psy1990 | 1:09a835e6d063 | 34 | |
eencae | 0:7423345f87c5 | 35 | int main() |
eencae | 0:7423345f87c5 | 36 | { |
Psy1990 | 1:09a835e6d063 | 37 | // first need to initialise display |
Psy1990 | 1:09a835e6d063 | 38 | lcd.init(); |
eencae | 0:7423345f87c5 | 39 | |
Psy1990 | 1:09a835e6d063 | 40 | while(1) { |
Psy1990 | 1:09a835e6d063 | 41 | // Splash Screen Info |
Psy1990 | 1:09a835e6d063 | 42 | lcd.clear(); // we need to clear the screen first |
Psy1990 | 1:09a835e6d063 | 43 | lcd.printString(" Author ",0,1); |
Psy1990 | 1:09a835e6d063 | 44 | lcd.printString("Simon Atkinson",0,2); |
Psy1990 | 1:09a835e6d063 | 45 | lcd.printString(" 201255483 ",0,3); |
Psy1990 | 1:09a835e6d063 | 46 | lcd.printString(" Uni of Leeds ",0,4); |
Psy1990 | 1:09a835e6d063 | 47 | lcd.refresh(); // need to refresh display after setting pixels or writing strings |
Psy1990 | 1:09a835e6d063 | 48 | wait(1.0); // we don't want this screen on long! |
Psy1990 | 1:09a835e6d063 | 49 | |
Psy1990 | 1:09a835e6d063 | 50 | // main menu screen no interaction yet pressing start won't do anything but its a start if you pardon the pun! |
Psy1990 | 1:09a835e6d063 | 51 | lcd.clear(); |
Psy1990 | 1:09a835e6d063 | 52 | lcd.printString(" Welcome to ",0,1); |
Psy1990 | 1:09a835e6d063 | 53 | lcd.printString(" Snake! ",0,2); |
eencae | 0:7423345f87c5 | 54 | lcd.printString(" Press Start ",0,4); |
eencae | 0:7423345f87c5 | 55 | lcd.refresh(); |
Psy1990 | 1:09a835e6d063 | 56 | wait(45.0); |
Psy1990 | 1:09a835e6d063 | 57 | lcd.clear(); |
Psy1990 | 1:09a835e6d063 | 58 | |
Psy1990 | 1:09a835e6d063 | 59 | // Easter Egg time! |
Psy1990 | 1:09a835e6d063 | 60 | lcd.printString(" Do you need ",0,1); |
Psy1990 | 1:09a835e6d063 | 61 | lcd.printString(" more time? ",0,2); |
Psy1990 | 1:09a835e6d063 | 62 | lcd.printString(" Grandpa! ",0,3); |
Psy1990 | 1:09a835e6d063 | 63 | lcd.refresh(); |
Psy1990 | 1:09a835e6d063 | 64 | wait(5.0); |
Psy1990 | 1:09a835e6d063 | 65 | |
Psy1990 | 1:09a835e6d063 | 66 | //returns back to normal welcome screen |
Psy1990 | 1:09a835e6d063 | 67 | lcd.clear(); |
Psy1990 | 1:09a835e6d063 | 68 | lcd.printString(" Welcome to ",0,1); |
Psy1990 | 1:09a835e6d063 | 69 | lcd.printString(" Snake! ",0,2); |
Psy1990 | 1:09a835e6d063 | 70 | lcd.printString(" Press Start ",0,4); |
Psy1990 | 1:09a835e6d063 | 71 | lcd.refresh(); |
Psy1990 | 1:09a835e6d063 | 72 | break; //stops the loop |
Psy1990 | 1:09a835e6d063 | 73 | |
Psy1990 | 1:09a835e6d063 | 74 | } |
Psy1990 | 1:09a835e6d063 | 75 | } |