el15mh 200929957

Dependencies:   mbed

main.cpp

Committer:
el15mh
Date:
2017-04-04
Revision:
4:66ab008f7b06
Parent:
3:02653cb1c8f8
Child:
5:55eee1d71c1d

File content as of revision 4:66ab008f7b06:

#include "mbed.h"
#include "N5110.h"
#include "Gamepad.h"
#include "Menu.h"
#include "Maze.h"
#include "Ball.h"

// CREATE OBJECTS //
N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
Gamepad pad;
Menu menu;
Maze maze;
Ball ball;

// FUNCTION PROTOTYPES //
void init();
void intro();

int main()
{
    init(); // initialise devices
    
    printf("Devices initialised \n");
    
    while(1) {
        
        intro();
        
        // menu.main(lcd, pad);
        // maze.drawBox(lcd);
        // lcd.drawCircle(15, 15, 3, FILL_BLACK);
        // ball.draw(lcd, 20, 20, 10);
    }
}


void init()
{
    lcd.init();
    pad.init();
}

void intro()
{
    
    // printf("intro started \n");
    
    while (1){
        
        // animation sequence
        // lcd.drawCircle(x, y, radius, type);
        for (int i = 0; i < 61; i++){
            
            lcd.clear();
            lcd.printString("  Welcome to  ", 0, 1);
            lcd.printString("  Roller Maze ", 0, 2);
            // printf("loop \n");
            lcd.drawLine(56, 40, 68, 40, FILL_BLACK);
            lcd.drawLine(56, 41, 68, 41, FILL_BLACK);
            lcd.refresh();
            
            if (i < 57){
                lcd.drawCircle(i, 36, 4, FILL_BLACK);
                lcd.refresh();
                wait_ms(50);
                
            }
            else if (i == 57){
                
                lcd.drawCircle(i, 37, 4, FILL_BLACK);
                lcd.refresh();
                wait_ms(50);
                
                for (int c = 55; c < 68; c++){
                    
                    lcd.clearPixel(c, 42);
                    lcd.clearPixel(c, 43);
                    lcd.clearPixel(c, 44);
                    lcd.clearPixel(c, 45);
                    lcd.clearPixel(c, 46);
                    lcd.refresh();
                }
            }
            else if (i == 58){
                
                lcd.drawCircle(i, 38, 4, FILL_BLACK);
                lcd.refresh();
                wait_ms(50);
                
                for (int c = 55; c < 68; c++){
                    
                    lcd.clearPixel(c, 42);
                    lcd.clearPixel(c, 43);
                    lcd.clearPixel(c, 44);
                    lcd.clearPixel(c, 45);
                    lcd.clearPixel(c, 46);
                    lcd.refresh();
                }
            }
            else if (i == 59){
                
                lcd.drawCircle(i, 39, 4, FILL_BLACK);
                lcd.refresh();
                wait_ms(50);
                
                for (int c = 55; c < 68; c++){
                    
                    lcd.clearPixel(c, 42);
                    lcd.clearPixel(c, 43);
                    lcd.clearPixel(c, 44);
                    lcd.clearPixel(c, 45);
                    lcd.clearPixel(c, 46);
                    lcd.refresh();
                }
            }
            else{
                
                for (int j = 40, j < 45; j++){
                    
                    lcd.drawCirle(i, j, 4, FILL_BLACK);
                    lcd.refresh();
                    wait_ms(50);
                    
                    for (int c = 55; c < 68; c++){
                        
                        lcd.clearPixel(c, 42);
                        lcd.clearPixel(c, 43);
                        lcd.clearPixel(c, 44);
                        lcd.clearPixel(c, 45);
                        lcd.clearPixel(c, 46);
                        lcd.refresh();
                    }
                }
            }
            
            // printf("%i \n", i);
        }
    }
    
    
}