Josh Davy / Mbed OS Flip_OS_5

Dependencies:   el17jd

main.cpp

Committer:
joshdavy
Date:
2019-03-25
Revision:
1:37802772843e
Parent:
0:4916a63a6cbf
Child:
2:b62e8be35a5d

File content as of revision 1:37802772843e:

/*
ELEC2645 Embedded Systems Project
School of Electronic & Electrical Engineering
University of Leeds
Name: Joshua Davy
Username: el17jd
Student ID Number: 201148379
Date: 12/03/2019
*/
const int fps = 15;


///////// pre-processor directives ////////
#include "mbed.h"
#include "Gamepad.h"
#include "N5110.h"
#include "Sprite.h"
#include "Game.h"


/////////////// objects ///////////////
N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
Gamepad pad;
Game game;


///////////// prototypes ///////////////
void init();
void welcome();

// initialies all classes and libraries
void init()
{
    // need to initialise LCD and Gamepad 
    lcd.init();
    pad.init();
     
    

}
// simple splash screen displayed on start-up
void welcome() {
    
    lcd.printString("     WOoo   ",0,1);  
    lcd.printString("  Press Start ",0,4);
    lcd.refresh();
     
    // wait flashing LEDs until start button is pressed 
    while ( pad.check_event(Gamepad::START_PRESSED) == false) {
        pad.leds_on();
        wait(0.1);
        pad.leds_off();
        wait(0.1);
    }
 
}

int main()
{
    init();     // initialise and then display welcome screen...
    welcome();  // waiting for the user to start
    
    // first draw the initial frame 
    wait(1.0f/fps);  // and wait for one frame period


    // game loop - read input, update the game state and render the display
    while (1) {
        game.read_input(pad);
        game.update(pad);
        game.draw(lcd);

        wait(1.0f/fps);
    }
}