ZIYI CHEN ml17z4c 201214999

Dependencies:   mbed

main.cpp

Committer:
ziyi11
Date:
2019-04-25
Revision:
5:f1a193bb84a2
Parent:
4:104a7dafcecd
Child:
6:13c43182a848

File content as of revision 5:f1a193bb84a2:

/*
ELEC2645 Embedded Systems Project
School of Electronic & Electrical Engineering
University of Leeds
Name:
Username: Ziyi Chen
Student ID Number:201214999
Date:3.17.2019
*/

#include "mbed.h"
#include "N5110.h"
#include "Snake_menu.h"

#include "Gamepad.h"




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


///////////// prototypes ///////////////
void init();
//void update_game(UserInput input);
void render();
void welcome();

///////////// functions ////////////////
int main()
{

    int fps = 8;  // frames per second

    init();     // initialise and then display welcome screen...
    welcome();  // waiting for the user to start
    
    render();  // first draw the initial frame 

}

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

// this function draws each frame on the LCD
void render()
{
    // clear screen, re-draw and refresh
    lcd.clear();  
    lcd.refresh();
}

// simple splash screen displayed on start-up
void welcome() {
    
    
    lcd.printString("    Snake Game!    ",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);
    }
 
}