ELEC2645 (2017/18) / Mbed 2 deprecated fy15raf

Dependencies:   mbed

main.cpp

Committer:
RehamFaqehi
Date:
2018-04-18
Revision:
1:386790f5f9bf
Parent:
0:f3d96a1a3177
Child:
2:3fd0d3d69556

File content as of revision 1:386790f5f9bf:

/*
 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"

/////////////// objects ///////////////
N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
Gamepad g_pad;

///////////// prototypes ///////////////
void init();
//void render();
void welcome();
 
 ///////////// functions ////////////////
 int main()
{

    init();     // initialise 
    welcome();  // display welcome screen till the user press start to start the game
    
    
  /* // 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();
}

// 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);
    } 
}