예제 #1
0
int main (void){
			
		ADC_Initialize          ();           // Initialize A/D Converter      
    GLCD_Initialize         ();           // Initialize Graphical LCD           
    Joystick_Initialize     ();           // Initialize joystick                

    GLCD_SetBackgroundColor (BackgroundColor);
    GLCD_SetForegroundColor (ForegroundColor);
    GLCD_SetFont            (&GLCD_Font_16x24);
		GLCD_ClearScreen();		
		
		// Select P0.16 as output 
		LPC_GPIO0->FIODIR |= 0x00010000;
			
		menuChoice = InitMenu;
		while (1)
			{
					switch(menuChoice)
					{
						case InitMenu:
							InitializeAppMenu();
							menuChoice = Menu;
							break;
						case Menu:
							AppMenu();
							break;
						case InitPong:
							initDMA();
							InitializeAppPong();
							menuChoice = Pong;
							break;
						case Pong:
							AppPong();
							break;
						case InitShooter:
							InitializeAppShooter();
							menuChoice = Shooter;
							break;
						case Shooter:
							AppShooter();
							menuChoice = InitMenu;
							break;
					}	
			

			}			
}
예제 #2
0
int main()
{
    SysTick_Config(SystemCoreClock/100);
	magazyn = malloc(sizeof(Element)*1200);
    Timer3Conf();
	Joystick_Initialize();
	Buttons_Initialize();
	initDisplay();
	lcdClean();
	Timer3Disable();
    Timer1Conf();

	lcdMenu();
    while(1)
    {
		while(tickCounter<10);
		tickCounter=0;
		switch(Buttons_GetState())
		{
			case BUTTON_INT0:
            //lcdClean();
            initSnake();
            game = 1;
            while(game == 1)
            {
                //while(tickCounter<10);
                //tickCounter=0;
                inputControl = 0;
                switch(Joystick_GetState())
                {
                    case JOYSTICK_UP:
                        inputControl = 1;
                        break;
                    case JOYSTICK_LEFT:
                        inputControl = 2;
                        break;
                    case JOYSTICK_DOWN:
                        inputControl = 4;
                        break;
                    case JOYSTICK_RIGHT:
                        inputControl = 8;
                                break;
                            default:
                                inputControl = oldControl;
                        }
                        if(inputControl == forbidden)
                            inputControl = oldControl;

                        if(reactCount > 0) {
                            game = react(inputControl);
                            --reactCount;
                        }
                    }
                    lcdString(250, 150, "Koniec gry");
                    while(1);
			break;
			case BUTTON_KEY1:
				lcdString(250, 150, "Opcja 2");
                while(1);
			break;
			case BUTTON_KEY2:
			    lcdString(250, 150, "Opcja 3");
			    while(1);
			break;
		}

	}
	return 0;
}