int main(void){
  TExaS_Init(SSI0_Real_Nokia5110_Scope);  // set system clock to 80 MHz
  Random_Init(1);
  Nokia5110_Init();
  Nokia5110_ClearBuffer();
	Nokia5110_DisplayBuffer();      // draw buffer

  Nokia5110_PrintBMP(32, 47, PlayerShip0, 0); // player ship middle bottom
  Nokia5110_PrintBMP(33, 47 - PLAYERH, Bunker0, 0);

  Nokia5110_PrintBMP(0, ENEMY10H - 1, SmallEnemy10PointA, 0);
  Nokia5110_PrintBMP(16, ENEMY10H - 1, SmallEnemy20PointA, 0);
  Nokia5110_PrintBMP(32, ENEMY10H - 1, SmallEnemy20PointA, 0);
  Nokia5110_PrintBMP(48, ENEMY10H - 1, SmallEnemy30PointA, 0);
  Nokia5110_PrintBMP(64, ENEMY10H - 1, SmallEnemy30PointA, 0);
  Nokia5110_DisplayBuffer();     // draw buffer

  Delay100ms(50);              // delay 5 sec at 50 MHz


  Nokia5110_Clear();
  Nokia5110_SetCursor(1, 1);
  Nokia5110_OutString("GAME OVER");
  Nokia5110_SetCursor(1, 2);
  Nokia5110_OutString("Nice try,");
  Nokia5110_SetCursor(1, 3);
  Nokia5110_OutString("Earthling!");
  Nokia5110_SetCursor(2, 4);
  Nokia5110_OutUDec(1234);
  while(1){
  }

}
int main(void){ int AnyLife = 1; int i;
  TExaS_Init(NoLCD_NoScope);  // set system clock to 80 MHz
  // you cannot use both the Scope and the virtual Nokia (both need UART0)
  Random_Init(1);
  Nokia5110_Init();
  EnableInterrupts(); // virtual Nokia uses UART0 interrupts
  
  Nokia5110_ClearBuffer();
	Nokia5110_DisplayBuffer();      // draw buffer

  Nokia5110_PrintBMP(32, 47, PlayerShip0, 0); // player ship middle bottom
  Nokia5110_PrintBMP(33, 47 - PLAYERH, Bunker0, 0);

  Nokia5110_PrintBMP(0, ENEMY10H - 1, SmallEnemy10PointA, 0);
  Nokia5110_PrintBMP(16, ENEMY10H - 1, SmallEnemy20PointA, 0);
  Nokia5110_PrintBMP(32, ENEMY10H - 1, SmallEnemy20PointA, 0);
  Nokia5110_PrintBMP(48, ENEMY10H - 1, SmallEnemy30PointA, 0);
  Nokia5110_PrintBMP(64, ENEMY10H - 1, SmallEnemy30PointA, 0);
  Nokia5110_DisplayBuffer();   // draw buffer

  Delay100ms(50);              // delay 5 sec at 80 MHz

  Init();
  Timer2_Init(80000000/30);  // 30 Hz
  while(AnyLife){
    while(Semaphore == 0){};
    Semaphore = 0; // runs at 30 Hz
    AnyLife = 0;
    for(i=0; i<4 ; i++){
      AnyLife |= Enemy[i].life;
    }
    Draw();
  }
  Nokia5110_Clear();
  Nokia5110_SetCursor(1, 1);
  Nokia5110_OutString("GAME OVER");
  Nokia5110_SetCursor(1, 2);
  Nokia5110_OutString("Nice try,");
  Nokia5110_SetCursor(1, 3);
  Nokia5110_OutString("Earthling!");
  Nokia5110_SetCursor(2, 4);
  Nokia5110_OutUDec(1234);
  Nokia5110_SetCursor(0, 0); // renders screen
  while(1){
  }

}
Beispiel #3
0
int main(void){
  unsigned short count = 0;
  PLL_Init();                           // set system clock to 50 MHz
  Nokia5110_Init();
  for(count=0; count<2; count=count+1){
    Nokia5110_DrawFullImage(Longhorn);
    Delay(1066666);                    // delay ~1 sec at 50 MHz
    Nokia5110_DrawFullImage(Longhorn2);
    Delay(1066666);                    // delay ~1 sec at 50 MHz
  }
  count = 0;
  Nokia5110_Clear();
  Nokia5110_OutString("************ THRILLDO ********** presents  *   *** The ***   MaStUrBm8 ********************** ");
	///("************* THRILLDO *************Letter: Num:------- ---- ");
  Nokia5110_OutChar(127);               //
  while(1){
    Nokia5110_SetCursor(5, 5);          // five leading spaces, bottom row
    Nokia5110_OutChar((count%26)+'A');
    Nokia5110_OutChar(' ');
    Nokia5110_OutUDec(count);
    Delay(8333333);                     // delay ~0.5 sec at 50 MHz
    count = count + 1;
  }
}
Beispiel #4
0
int main(void) {
	
	int  delay;
	float fTemperature, fPressure, fAltitude, fK_Altitude, fAltitude_sum,fK_Altitude_sum;
	int count,i;
//	static float f_meas[VAR_COUNT], fAlt_Mean, fAlt_Var;
	unsigned short sw1_count, sw2_count;
	unsigned char sw1_was_cleared = 0, sw2_was_cleared = 0;


	// Set the clocking to run directly from the external crystal/oscillator.
	MAP_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
			WRFL_XTAL);


	//init ports and peripherals
	PlatformInit();
	Nokia5110_Init();
	Nokia5110_Clear();


    Nokia5110_DrawFullImage(gears_logo);
    for(delay=0; delay<1000000; delay=delay+1);

    Nokia5110_Clear();
    Nokia5110_SetCursor(3, 1);
    Nokia5110_OutString("WRFL");
    Nokia5110_SetCursor(1, 2);
    Nokia5110_OutString("Prototype");
    Nokia5110_SetCursor(2, 4);
    Nokia5110_OutString("VER 0.1");
    Nokia5110_SetCursor(0, 5);
    Nokia5110_OutString("NightMecanic");
    for(delay=0; delay<1000000; delay=delay+1);
    Nokia5110_Clear();
    //
   // Enable interrupts to the processor.
   //
   MAP_IntMasterEnable();

   //
   // Initialize I2C1 peripheral.
   //
   I2CMInit(&g_sI2CInst, BMP180_I2C_BASE, BMP180_I2C_INT, 0xff, 0xff,
			MAP_SysCtlClockGet());

   //
   // Initialize the BMP180
   //
   BMP180Init(&g_sBMP180Inst, &g_sI2CInst, BMP180_I2C_ADDRESS,
			  BMP180AppCallback, &g_sBMP180Inst);


   //
   // Wait for initialization callback to indicate reset request is complete.
   //
   while(g_vui8DataFlag == 0)
   {
	   //
	   // Wait for I2C Transactions to complete.
	   //
   }

   //
   // Reset the data ready flag
   //
   g_vui8DataFlag = 0;

   //set oversampling to 8x
   g_sBMP180Inst.ui8Mode = 0xC0;

   //Initialize the Kalman filter
   Kalman_Init(&Alt_KState, 0.0f, 1.0f, ALT_KALMAN_R, ALT_KALMAN_Q);

   //
   // Enable the system ticks at 10 hz.
   //
   MAP_SysTickPeriodSet(MAP_SysCtlClockGet() / (40 * 3));
   MAP_SysTickIntEnable();
   MAP_SysTickEnable();


   Nokia5110_SetCursor(0, 0);
   Nokia5110_OutString("SW1:");

   Nokia5110_SetCursor(0, 2);
   Nokia5110_OutString("SW2:");

  //config done
   count = 0;
   //
   // Begin the data collection and printing.  Loop Forever.
   //
   while(1)
   {

	   // SW1
	   if (sw_state & SW1){
		   if (sw1_was_cleared){
			   sw1_was_cleared = 0;
			   sw1_count++;
		   	   Nokia5110_SetCursor(5, 0);
		   	   Nokia5110_OutUDec(sw1_count);
		   }
	   }else
		   sw1_was_cleared = 1;

	   //SW2
	   if (sw_state & SW2){
	   		   if (sw2_was_cleared){
	   			   sw2_was_cleared = 0;
	   			   sw2_count++;
	   		   	   Nokia5110_SetCursor(5, 2);
	   		   	   Nokia5110_OutUDec(sw2_count);
	   		   }
	   	   }else
	   		   sw2_was_cleared = 1;

	   // handle BMP180 data (display average every 50 samples)
	   if (g_vui8DataFlag ){
		   //
		   // Reset the data ready flag.
		   //
		   g_vui8DataFlag = 0;

		   //
		   // Get a local copy of the latest temperature data in float format.
		   //
		   BMP180DataTemperatureGetFloat(&g_sBMP180Inst, &fTemperature);

		   //
		   // Print temperature with three digits of decimal precision.
		   //

		   //Nokia5110_SetCursor(0, 0);
		   //Nokia5110_OutString("Temp:");
		   //Nokia5110_OutFloatp3(fTemperature);

		   //
		   // Get a local copy of the latest air pressure data in float format.
		   //
		   BMP180DataPressureGetFloat(&g_sBMP180Inst, &fPressure);

	   	   //
	   	   // Print Pressure with three digits of decimal precision.
	   	   //

	   	   //Nokia5110_SetCursor(0, 1);
	   	   // Nokia5110_OutString("Pres:");
	   	   //Nokia5110_SetCursor(0, 2);

	   	   //display in hPa
	   	   //Nokia5110_OutFloatp3((fPressure / 100.0f));

	   	   //
	   	   // Calculate the altitude.
	   	   //
	   	   //fAltitude = 44330.0f * (1.0f - powf(fPressure / 101325.0f,
	   	   //									   1.0f / 5.255f));
	   	   //corrected:
	   	   fAltitude = 44330.0f * (1.0f - powf(fPressure / LOC_ALT_P0,
	   										   1.0f / 5.255f));
	   	   // Kalman filtered altitude

	  	   Kalman_Update (&Alt_KState, fAltitude);
	  	   fK_Altitude = Alt_KState.X;


	  	   fAltitude_sum += fAltitude;
	  	   fK_Altitude_sum += fK_Altitude;
	  	   count++;

	  	   if (count>=50){
	  		 Nokia5110_SetCursor(0, 3);
	  		 Nokia5110_OutString("Alt:");
	  		 Nokia5110_OutFloatp3(fAltitude_sum/50.0);

	  		 Nokia5110_SetCursor(0, 5);
	  		 Nokia5110_OutString("KAlt:");
	  		 Nokia5110_OutFloatp3(fK_Altitude_sum/50.0);

	  		fAltitude_sum = 0;
	  		fK_Altitude_sum = 0;
	  		count = 0;
	  	   }


/*
	  	 //calculate variance
	  	 f_meas[count]=fK_Altitude;
	  	 count++;

	  	 if (count>=VAR_COUNT){
	  		 fAlt_Mean = 0.0f;
	  		 fAlt_Var = 0.0f;
	  		 // calculate mean
	  		 for(i=0; i<VAR_COUNT; i++){
	  			 fAlt_Mean = fAlt_Mean +f_meas[i];
	  		 }
	  		 fAlt_Mean = fAlt_Mean/((float) VAR_COUNT);

	  		 // Calculate Var
	  		 for(i=0; i<VAR_COUNT; i++){
	  			 fAlt_Var = fAlt_Var + powf((f_meas[i] - fAlt_Mean),2.0f);
	  		 }
	  		 fAlt_Var = fAlt_Var/((float) VAR_COUNT);



	  		 //
	  		 // Print altitude with three digits of decimal precision.
	  		 //

	  		 Nokia5110_SetCursor(0, 4);
	  		 Nokia5110_OutString("Var:");

	  		 Nokia5110_OutFloatp3(fAlt_Var);

	  		 count = 0;

	  	 }
*/
	   //
	   // Delay to keep printing speed reasonable. About 100msec.
	   //
	   //MAP_SysCtlDelay(MAP_SysCtlClockGet() / (10 * 3));

	   }
   }//while end
}
Beispiel #5
0
 void Timer2A_Handler(void){ 
	ST enemy;
  TIMER2_ICR_R = 0x00000001;   // acknowledge timer2A timeout
  q++;
	 d=(Random())%4;
	 k=(Random())%4;
	 s=(d+k)%4;
	 if(q<10){
	 enemy.x=Enemy[s].x;
	 enemy.y=Enemy[s].y;
	 enemy.life=1;
		 enemy.b=0;
	 enemy.image[0]=Black;
	 enemy.image[1]=Dead;
	 }
	 else 
	 {
	 enemy.x=Enemy[s].x;
	 enemy.y=Enemy[s].y;
	 enemy.life=1;
	 enemy.image[0]=bomp;
	 enemy.image[1]=bomp;
	 enemy.b=1;
	 q=0;
	 }
	 for(i=0;i<30;i++)
	 {
		 if(vector[i].fl==0)
		 {
			 vector[i]=enemy;
			 vector[i].fl=1;
			 vector[i].life=1;
			 o++;
		 break;
		 }
	 }
	 Nokia5110_ClearBuffer();
	Nokia5110_PrintBMP(LFish.x, LFish.y, LFish.image[0], 0);
	
    for(p=0;p<30;p++){
			if(vector[p].fl==1 && vector[p].life==1){
	 if(vector[p].x >0){
      vector[p].x -= 10;
      if(((((LFish.y-16)<vector[p].y) && (vector[p].y<=(LFish.y)))||((vector[p].y-16)<LFish.y && (vector[p].y-16)<LFish.y))&& (vector[p].x<=17) && (vector[p].b==0 ))
			{				
				Score+=10;
				vector[p].life=0;
				Nokia5110_PrintBMP(vector[p].x, vector[p].y,vector[p].image[1], 0);
				o--;
			}
			else if((((LFish.y-16)<vector[p].y)&& (vector[p].y<=(LFish.y+4))) &&(vector[p].x<=17) && vector[p].b==1){
	 Nokia5110_ClearBuffer();
		Nokia5110_DisplayBuffer(); 
			 Nokia5110_SetCursor(1, 1);
  Nokia5110_OutString("GAME OVER");
  Nokia5110_SetCursor(1, 2);
  Nokia5110_OutString("Nice try,");
			Nokia5110_SetCursor(1, 4);
			Nokia5110_OutString("Score: ");
		 Nokia5110_SetCursor(6, 4);
  Nokia5110_OutUDec(Score);
		 Delay100ms(50);   
exit(0);			
	 }
			else
				Nokia5110_PrintBMP(vector[p].x, vector[p].y,vector[p].image[0], 0);
			
		}
		else if (vector[p].x==0){
			vector[p].fl=0;
			vector[p].life=0;
	    o--;
		}
	}
		if(p>=o)break;
		}
 Nokia5110_DisplayBuffer();
}