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:
- RehamFaqehi
- Date:
- 2018-04-18
- Revision:
- 2:3fd0d3d69556
- Parent:
- 1:386790f5f9bf
- Child:
- 3:489437d4ebd7
File content as of revision 2:3fd0d3d69556:
/* ELEC2645 Embedded Systems Project School of Electronic & Electrical Engineering University of Leeds Name: Reham Faqehi Username: Fy15raf Student ID Number: 200982112 Date: 03/05/2018 */ ///////// pre-processor directives //////// #include "mbed.h" #include "Gamepad.h" #include "N5110.h" #include "GameEngine.h" /////////////// objects /////////////// N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); Gamepad g_pad; GameEngine game; ///////////// prototypes /////////////// void init(); void render(); void welcome(); ///////////// functions //////////////// int main() { int fps = 8; // frames per second init(); // initialise welcome(); // display welcome screen till the user press start to start the game render(); // drawing the initial frame wait(1.0f/fps); // wait for one frame period // game loop while (1) { render(); wait(1.0f/fps); } } // initialies all classes and libraries void init() { //initialise LCD and Gamepad first lcd.init(); lcd.setContrast(0.5); g_pad.init(); // initialise the game game.init(); } //function to draw the frames on the LCD void render() { // first clear screen, re-draw and then refresh the LCD lcd.clear(); game.draw(lcd); lcd.refresh(); } // simple welcoming screen before starting the game void welcome() { lcd.printString(" Rocket! ",0,1); lcd.printString(" Press Start ",0,4); lcd.refresh(); //flashing LEDs until start button is pressed while ( g_pad.check_event(Gamepad::START_PRESSED) == false) { g_pad.leds_on(); wait(0.1); g_pad.leds_off(); wait(0.1); } }