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
- Committer:
- Psy1990
- Date:
- 2020-06-04
- Revision:
- 3:bd4c7eccde17
- Parent:
- 2:c6772c5ab69d
- Child:
- 4:07aada4c8421
File content as of revision 3:bd4c7eccde17:
/* ELEC2645 Embedded Systems Project School of Electronic & Electrical Engineering University of Leeds 2019/20 Name: Simon Thackray Atkinson Username: el18s2a Student ID Number: 201255483 Date: 05/03/2020 */ ///////// pre-processor directives //////// #include "mbed.h" #include "Gamepad.h" #include "N5110.h" /////////////// structs ///////////////// struct UserInput { Direction d; float mag; }; /////////////// objects /////////////// N5110 lcd; Gamepad pad; void welcome(); bool gameOver; int borderW, borderH, appleX, appleY, score; enum eDirection {STOP = 0, LEFT, RIGHT, UP, DOWN}; eDirection dir; void setup() { gameOver = false; dir = STOP; borderW = WIDTH; //Fence width and height borderH = HEIGHT; appleX = rand() % borderW; appleY = rand() % borderH; score = 0; } void draw() { lcd.clear(); lcd.drawRect(0,0,borderW,borderH,FILL_TRANSPARENT); lcd.refresh(); } ///////////// functions //////////////// int main() { //initialise Display and gamepad lcd.init(); pad.leds_off(); setup(); while (!gameOver) { draw(); } /* Working on game will bring welcome screen back in // first need to initialise display lcd.init(); pad.leds_off(); while ( pad.start_pressed() == false) { pad.led(3,1); // Only Show Green LEDS pad.led(6,1); // // Splash Screen Info lcd.clear(); // we need to clear the screen first lcd.printString(" Author ",0,1); lcd.printString("Simon Atkinson",0,2); lcd.printString(" 201255483 ",0,3); lcd.printString(" Uni of Leeds ",0,4); lcd.refresh(); // need to refresh display after setting pixels or writing strings wait(1.0); // we don't want this screen on long! // main menu screen no interaction yet pressing start won't do anything but its a start if you pardon the pun! lcd.clear(); lcd.printString(" Welcome to ",0,1); lcd.printString(" Snake! ",0,2); lcd.printString(" Press Start ",0,4); lcd.refresh(); wait(45.0); lcd.clear(); // Easter Egg time! pad.led(3,0); // Turn Green LEDs Off pad.led(6,0); // pad.led(2,1); // Turn on Amber LEDs pad.led(5,1); // lcd.printString(" Do you need ",0,1); lcd.printString(" more time? ",0,2); lcd.printString(" Grandpa! ",0,3); lcd.refresh(); wait(5.0); //returns back to normal welcome screen lcd.clear(); pad.led(3,1); // Turn Green LEDs On pad.led(6,1); // pad.led(2,0); // Turn off Amber LEDs pad.led(5,0); // lcd.printString(" Welcome to ",0,1); lcd.printString(" Snake! ",0,2); lcd.printString(" Press Start ",0,4); lcd.refresh(); } while ( pad.start_pressed() == true) { pad.leds_off(); pad.led(0,1); // Only Show Red LEDS pad.led(3,1); // Splash Screen Info lcd.clear(); // we need to clear the screen first lcd.printString(" Placeholder ",0,1); lcd.printString(" Game Coming ",0,2); lcd.printString(" Soon ",0,3); lcd.printString(" :) ",0,4); lcd.refresh(); // need to refresh display after setting pixels or writing strings } */ }