ELEC2645 (2018/19) / Mbed 2 deprecated el17szs

Dependencies:   mbed

main.cpp

Committer:
shahidsajid
Date:
2019-04-30
Revision:
22:69d7fe739872
Parent:
20:9d21599fe350

File content as of revision 22:69d7fe739872:

/*
ELEC2645 Embedded Systems Project
School of Electronic & Electrical Engineering
University of Leeds
Name: Shahid Zubin Sajid
Username: el17szs   
Student ID Number: 201197609
Date: 21/03/2019
*/

#include "mbed.h"
#include "Gamepad.h"
#include "N5110.h"
#include "Ball.h"
#include "Bat.h"
#include "Cricket.h"


N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
Gamepad mainpad;
Cricket cricket;



void init();

void welcome();
void draw();
void ball_test();

int main(){
    int fps=14;
    init();
    cricket.intro(lcd);
     //welcome();
    //draw();
    while(1){
       
        cricket.game(lcd,mainpad);
        draw();
        wait(1.0f/fps);                
    }
    
}
void init(){
    lcd.init();
    mainpad.init();
    //ball1.init(2,4);
    cricket.init();
    //bat1.init();
    lcd.setContrast(0.4);
    lcd.normalMode();      // normal colour mode
    lcd.setBrightness(0.5);
    lcd.clear();
    
}
void welcome() {
    lcd.printString("     CRICKET GAME    ",0,1);  
    lcd.printString(" SHAHID SAJID",0,2); 
    lcd.printString("     el17szs    ",0,3);
    lcd.printString("  Press Start ",0,4);
    lcd.refresh();
    // wait flashing LEDs until start button is pressed 
    while ( mainpad.check_event(Gamepad::START_PRESSED) == false) {
        printf("Waiting");
        mainpad.leds_on();
        wait(0.1);
        mainpad.leds_off();
        wait(0.1);
    }
    printf("Out of loop");
    lcd.clear();
    lcd.printString("     CRICKET GAME    ",0,1);  
    lcd.refresh();
    wait(10.0);
 
}
void draw(){
    lcd.clear();
    cricket.draw(lcd);
    //ball1.draw(lcd);
    //bat1.draw(lcd);
    lcd.refresh();
}