ELEC2645 (2018/19) / Mbed 2 deprecated el17dtt

Dependencies:   mbed

Committer:
batJoro
Date:
Sun May 05 23:31:07 2019 +0000
Revision:
9:dc13042b09f5
Parent:
8:b3738229ba85
Child:
10:b939edd9b87c
engine4;

Who changed what in which revision?

UserRevisionLine numberNew 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 8:b3738229ba85 28 Engine engine;
batJoro 1:3183193cf44e 29
batJoro 3:f686f6d7bdff 30 ///////////// prototypes ///////////////
batJoro 4:2deeeeb6c1e1 31 void init();
batJoro 4:2deeeeb6c1e1 32 void welcome();
batJoro 6:4c55dd4b6d42 33 void render();
batJoro 3:f686f6d7bdff 34
batJoro 3:f686f6d7bdff 35 ///////////// functions ////////////////
batJoro 0:a0dedca5e89f 36 int main() {
batJoro 0:a0dedca5e89f 37
batJoro 9:dc13042b09f5 38 int fps = 10; // frames per second
batJoro 8:b3738229ba85 39
batJoro 4:2deeeeb6c1e1 40 init();
batJoro 1:3183193cf44e 41
batJoro 6:4c55dd4b6d42 42 welcome();
batJoro 6:4c55dd4b6d42 43 // game loop - read input, update the game state and render the display
batJoro 6:4c55dd4b6d42 44 while(1) {
batJoro 8:b3738229ba85 45 // engine.read_input(gamepad);
batJoro 9:dc13042b09f5 46 engine.update(gamepad, lcd, 1.0f/fps);
batJoro 6:4c55dd4b6d42 47 render();
batJoro 8:b3738229ba85 48 wait(1.0f/fps);
batJoro 4:2deeeeb6c1e1 49 }
batJoro 4:2deeeeb6c1e1 50 }
batJoro 3:f686f6d7bdff 51
batJoro 8:b3738229ba85 52
batJoro 4:2deeeeb6c1e1 53 // initialies all classes and libraries
batJoro 4:2deeeeb6c1e1 54 void init()
batJoro 4:2deeeeb6c1e1 55 {
batJoro 6:4c55dd4b6d42 56
batJoro 8:b3738229ba85 57 // need to initialise LCD and Gamepad and Engine
batJoro 4:2deeeeb6c1e1 58 lcd.init();
batJoro 4:2deeeeb6c1e1 59 gamepad.init();
batJoro 8:b3738229ba85 60
batJoro 8:b3738229ba85 61 // init the engine and start the game at 0 speed
batJoro 8:b3738229ba85 62 engine.init(48 , 84, 0);
batJoro 8:b3738229ba85 63
batJoro 4:2deeeeb6c1e1 64 gamepad.leds_on();
batJoro 4:2deeeeb6c1e1 65 lcd.setContrast(0.4);
batJoro 4:2deeeeb6c1e1 66 }
batJoro 6:4c55dd4b6d42 67 // function to call the intro method of the menu class
batJoro 4:2deeeeb6c1e1 68 void welcome() {
batJoro 4:2deeeeb6c1e1 69
batJoro 4:2deeeeb6c1e1 70 Menu menu;
batJoro 8:b3738229ba85 71 //menu.intro(lcd, gamepad);
batJoro 8:b3738229ba85 72 while (menu.startMainMenu(lcd, gamepad) == 1) {
batJoro 8:b3738229ba85 73 //menu.displayControls(lcd, gamepad);
batJoro 8:b3738229ba85 74 };
batJoro 6:4c55dd4b6d42 75 }
batJoro 6:4c55dd4b6d42 76 // this function draws each frame on the LCD
batJoro 6:4c55dd4b6d42 77 void render() {
batJoro 6:4c55dd4b6d42 78
batJoro 9:dc13042b09f5 79 //lcd.clear();
batJoro 8:b3738229ba85 80 //engine.draw(lcd);
batJoro 9:dc13042b09f5 81 //lcd.refresh();
batJoro 0:a0dedca5e89f 82 }