Beispiel #1
0
void Init(struct Gamestate* state)
{
	EnableDebugOutput(DEBUG_USART);
	printf("Init\r\n");

	InitializeLEDs();

	SetLEDs(0x01);
	SetLEDs(0x07);

#ifdef ACCELEROMETER
/*	InitializeAccelerometer();
	printf("Init Accelerometer: %s\r\n", PingAccelerometer() > 0 ? "OKAY" : "FAILED");
	CalibrateAccelerometer();*/
#endif

	for(int i=0;i<NumberOfStars;i++)
	{
		stars[i].x=GetRandomInteger()%360;
		stars[i].y=(GetRandomInteger()%200);

		int z=sqrti((NumberOfStars-1-i)*NumberOfStars)*1000/NumberOfStars;
		stars[i].dy=1;//6000*1200/(z+200);

		stars[i].f=(6-(z*7)/1000)+(GetRandomInteger()%6)*7;
	}
}
Beispiel #2
0
	void inir(){
			InitializeTimer();
			InitializePWMChannel();
			InitializePWMChannel2();
			InitializeLEDs();

	}
Beispiel #3
0
int main()
{
	// Do some basic initialization tasks
	InitializeSystem();

	// Initialize pins for LEDs
	InitializeLEDs();

	// Enable printf via trace macrocell (get output with 'make trace')
	EnableDebugOutput(DEBUG_ITM);
	//printf("step\n %d");
	//Turn on all LEDs
	_Bool isOn = 0;
	int val = 1 | 2 | 4 | 8;
	while (1) {
		if (isOn == 0) {
			val = (val<<1) | (val<0);
			SetLEDs(val);
			isOn = 1;
		} else {
			SetLEDs(0 | 0 | 0 | 0);
			isOn = 0;
			iprintf("test\r\n");
		}
		Delay( 10 );
	}
}
Beispiel #4
0
int main()
{
	RCC_ClocksTypeDef RCC_Clocks;
	RCC_GetClocksFreq(&RCC_Clocks);

	SysTick_Config(RCC_Clocks.HCLK_Frequency / 100);
	
	InitializeLEDs();
	MyUSART_Init();

	setvbuf(stdout, 0, _IONBF, 0);
	printf("Hello!\r\n");

	float a = 0.0f;
	a += 0.1f;

	float b = 32.74538f;

	printf("a: %f, b: %f\r\n", a, b);

	while(1)
	{
		a += b;
		printf("Float: %f\r\n", a);
		
		SetLEDs(0x5);
		Delay(50);
		SetLEDs(0xA);
		Delay(50);
	}
}
Beispiel #5
0
int main()
{
    InitializeLEDs();
    InitializeTimer();
	EnableTimerInterrupt();

   while(1);
}
int main(void){

	InitializeLEDs();
	InitializeTimer();
	InitializePwm();

	TIM3->CCR1 = 750;

    while(1){

    }
}
       int main()
       {
           InitializeLEDs();
           InitializeTimer();
           for (;;)
           {
	           if (TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET)
        	   {
               		TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
			GPIOE->ODR ^= 1L <<9;
           	   }
           }
       }
Beispiel #8
0
int main()
{
	InitializeSystem();
	SysTick_Config(HCLKFrequency()/100);
	InitializeLEDs();
	InitializeAccelerometer();

	InitializeLEDFlow();

	while(1)
	{
		RunLEDFlow();
		Delay(5);
	}
}
Beispiel #9
0
int main()
{
    InitializeLEDs();
    SPI_initialize();

    uint8_t data = 0xaa;
    SPI_Write(0x20, 0xC4);

    while(1)
        {
        	data = SPI_Read(0x2d);
        }
    while(1)
    {
    }
}
Beispiel #10
0
 int main()
 {
     InitializeLEDs();
     InitializeTimer();
     for (;;)
     {
         int timerValue = TIM_GetCounter(TIM2);
         if (timerValue == 400) {
             GPIO_WriteBit(GPIOE, GPIO_Pin_8, Bit_SET);
             GPIO_WriteBit(GPIOE, GPIO_Pin_9, Bit_SET); 
         }
         else if (timerValue == 500) {
             GPIO_WriteBit(GPIOE, GPIO_Pin_8, Bit_RESET);
             GPIO_WriteBit(GPIOE, GPIO_Pin_9, Bit_RESET); 
         }
     }
 }
Beispiel #11
0
int main()
{
	RCC_ClocksTypeDef RCC_Clocks;
	RCC_GetClocksFreq(&RCC_Clocks);

	SysTick_Config(RCC_Clocks.HCLK_Frequency / 100);

	InitializeLEDs();
	MyUSART_Init();

	setvbuf(stdout, 0, _IONBF, 0);
	printf("Hello!\r\n");

	char c;
	while(1)
	{
		if(USART_ReceiveChar(&c))
			USART_SendChar(c);

		SetLEDs(c);
	}
}
Beispiel #12
0
int main()
{
	InitializeSystem();
	SysTick_Config(HCLKFrequency()/100);
	InitializeLEDs();

	InitializeAccelerometer();
	InitializeAnglephone();

	InitializeAudio(Audio22050HzSettings);
	SetAudioVolume(0x60);

	PlayAudioWithCallback(AudioCallback, 0);

	while(1)
	{
		SetLEDs(0x5);
		Delay(100);
		SetLEDs(0xA);
		Delay(100);
	}
}
Beispiel #13
0
int main()
{
	RCC_ClocksTypeDef RCC_Clocks;
	RCC_GetClocksFreq(&RCC_Clocks);

	SysTick_Config(RCC_Clocks.HCLK_Frequency / 100);

	InitializeLEDs();
	MyUSART_Init();

	setvbuf(stdout, 0, _IONBF, 0);
	printf("Hello!\r\n");

	InitializeSnesController();

	while(1)
	{
		snes_button_state_t btn = GetControllerState();
		printf("SNES: %02X\r\n", btn.raw);
		printf(
			"%s %s %s %s %s %s %s %s %s %s %s %s\r\n",
			btn.buttons.A ? "A" : "",
			btn.buttons.B ? "B" : "",
			btn.buttons.X ? "X" : "",
			btn.buttons.Y ? "Y" : "",
			btn.buttons.L ? "L" : "",
			btn.buttons.R ? "R" : "",
			btn.buttons.Start ? "Start" : "",
			btn.buttons.Select ? "Select" : "",
			btn.buttons.Left ? "Left" : "",
			btn.buttons.Up ? "Up" : "",
			btn.buttons.Down ? "Down" : "",
			btn.buttons.Right ? "Right" : ""
		);

		SetLEDs(btn.buttons.A << 3 | btn.buttons.B << 2 | btn.buttons.X << 1 | btn.buttons.Y);
	}
}
Beispiel #14
0
int main()
{
	InitializeSystem();
	SysTick_Config(HCLKFrequency()/100);
	InitializeLEDs();

	SetLEDs(0x01);

	uint8_t *framebuffer1=(uint8_t *)0x20000000;
	uint8_t *framebuffer2=(uint8_t *)0x20010000;
	SetLEDs(0x03);
	memset(framebuffer1,0,320*200);
	memset(framebuffer2,0,320*200);

	SetLEDs(0x07);

	IntializeVGAScreenMode320x200(framebuffer1);

	#define NumberOfStars 1050
	static struct Star
	{
		int x,y,dx,f;
	} stars[NumberOfStars];

	for(int i=0;i<NumberOfStars;i++)
	{
		stars[i].x=(RandomInteger()%352-16)<<12;
		stars[i].y=RandomInteger()%200;

		int z=sqrti((NumberOfStars-1-i)*NumberOfStars)*1000/NumberOfStars;
		stars[i].dx=6000*1200/(z+200);

		stars[i].f=(6-(z*7)/1000)+(RandomInteger()%6)*7;
	}

	const RLEBitmap *sprites[7*6]={
		&Star1_0,&Star2_0,&Star3_0,&Star4_0,&Star5_0,&Star6_0,&Star7_0,
		&Star1_1,&Star2_1,&Star3_1,&Star4_1,&Star5_1,&Star6_1,&Star7_1,
		&Star1_2,&Star2_2,&Star3_2,&Star4_2,&Star5_2,&Star6_2,&Star7_2,
		&Star1_3,&Star2_3,&Star3_3,&Star4_3,&Star5_3,&Star6_3,&Star7_3,
		&Star1_4,&Star2_4,&Star3_4,&Star4_4,&Star5_4,&Star6_4,&Star7_4,
		&Star1_5,&Star2_5,&Star3_5,&Star4_5,&Star5_5,&Star6_5,&Star7_5,
	};

	Bitmap frame1,frame2;
	InitializeBitmap(&frame1,320,200,320,framebuffer1);
	InitializeBitmap(&frame2,320,200,320,framebuffer2);

	int frame=0;

	while(1)
	{
		WaitVBL();

		Bitmap *currframe;
		if(frame&1) { currframe=&frame2; SetFrameBuffer(framebuffer1); }
		else { currframe=&frame1; SetFrameBuffer(framebuffer2); }

		ClearBitmap(currframe);

		for(int i=0;i<NumberOfStars;i++)
		{
			DrawRLEBitmap(currframe,sprites[stars[i].f],
			(stars[i].x>>12)-16,stars[i].y-16);

			stars[i].x-=stars[i].dx;
			if(stars[i].x<=-16<<12)
			{
				stars[i].x=(320+16)<<12;
				stars[i].y=RandomInteger()%200;
				stars[i].f=(stars[i].f%7)+(RandomInteger()%6)*7;
			}
		}

		frame++;
	}
}
Beispiel #15
0
int main()
{
	RCC_ClocksTypeDef RCC_Clocks;
	RCC_GetClocksFreq(&RCC_Clocks);

	SysTick_Config(RCC_Clocks.HCLK_Frequency / 100);

	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);

	InitializeLEDs();
	InitializeUserInterface();
	InitializeRandom();
	InitializeRumble();

	//Clear framebuffers
	memset(ADDR_FRAMEBUFFER1, 0x00, 320*200);
	memset(ADDR_FRAMEBUFFER2, 0x00, 320*200);

	//Create drawing surfaces
	InitializeBitmap(&frame1,320,200,320,ADDR_FRAMEBUFFER1);
	InitializeBitmap(&frame2,320,200,320,ADDR_FRAMEBUFFER2);

	//Switch on VGA
	IntializeVGAScreenMode320x200(ADDR_FRAMEBUFFER1);

	if(!TheGame) {
		EnableDebugOutput(DEBUG_USART);
		fprintf(stderr, "PANIC: Game structure pointer is NULL\r\n");
		return -1;
	}

	if(TheGame->currentState)
		TheGame->currentState->Init(NULL);

	if(!TheGame->currentState->Update || !TheGame->currentState->Draw) {
		fprintf(stderr, "PANIC: Update and/or Draw function pointer is NULL\r\n");
		return -1;
	}

	Gamestate *currentState = TheGame->currentState;

	while(1)
	{
		oldTime = currentTime;
		currentTime = SysTickCounter;
		if (currentState != TheGame->currentState)
		{
			Gamestate *newState = TheGame->currentState;
			if (!newState->initialized) {
				newState->Init(currentState);
				newState->initialized = true;
			}
			if (newState->OnEnter)
				newState->OnEnter(currentState);
			currentState = newState;
		}

		//Swap Buffers
		if(frame&1) { drawingSurface=&frame2; SetFrameBuffer(ADDR_FRAMEBUFFER1); }
		else { drawingSurface=&frame1; SetFrameBuffer(ADDR_FRAMEBUFFER2); }

		//Update and draw
		currentState->Update(currentTime - oldTime);
		currentState->Draw(drawingSurface);

		frame++;

		if (currentState != TheGame->currentState &&
			TheGame->currentState->OnLeave)
		{
			currentState->OnLeave(currentState);
		}
		//VSync
		WaitVBL();
	}
}
Beispiel #16
0
int main(){ // the argument list is not used
  // but there is provision for it.

  printf("Welcome to the FIREBALL Guider. Please wait while we configure\n");

    fflush(NULL);

  StartLog();
  GtoM_StartCount(); 
  GtoT_StartCount();
  ResetReceivedMessageCounters();

  trackpointEL = CHIPHEIGHT/2;
  trackpointCE = CHIPWIDTH/2;

  QCamera camera; // open the camera.

  //  UniversalTime();
  //  printf("The Local Sidereal Time is: %lf\n",LST(31.761, -95.63));

  /*
  double ra1, ra2;
  double dec1, dec2;
  double alt1, alt2;
  double az1, az2;
  double del, dce;
  double lat, lon;
  */ 

  GtoT_CameraError(0);

  SetLatLon(31.761,-95.64);

  /*  lat = 31.761;
  lon = -95.64;
  ra1 = 0.50;
  ra2 = 0.51;
  dec1 = 0.41;
  dec2 = 0.41;
  RADEC_to_ALTAZ(ra1,dec1, lat,lon, &alt1,&az1);
  printf("the first alt-az I have found: %lf %lf\n",alt1,az1);
  RADEC_to_ALTAZ(ra2,dec2, lat,lon, &alt2,&az2);
  printf("the second alt-az I have found: %lf %lf\n",alt2,az2);
  ALTAZ_to_ELCE(alt1,az1,alt2,az2,&del,&dce); 
  printf("The difference I have found is: %lf %lf\n",del,dce);
  */
  InitDAC(); // prepare the dac.

  InitializeLEDs(); // turn off the Lamp.

  if(!ComSetup()) GtoT_TextError("COM working");


  //  RunSillyProg();

  StartDisplay(); // begin the display.

  turnOnGps();
  

  // starts some of the statistic quantities. Defaulting to 100 frames -- 10s in full chip mode, 3s in ROI mode. 





  InitMode.setCallback(InitModeCallback);
  AutocollimationMode.setCallback(AutocollimationModeCallback);
  AlignmentMode.setCallback(AlignmentModeCallback);
  AlignmentSubMode.setCallback(AlignmentModeCallback);
  SlewingMode.setCallback(SlewPointModeCallback);
  PointingMode.setCallback(SlewPointModeCallback);
  PointingModeRoi.setCallback(SlewPointModeCallback);
 
  camera.prepSettings(InitMode,0,0);
  if(camera.LoadQCamState()){
    switch(camera.nextMode.getModeID()){
    case INITMODE:{
      camera.nextMode.setCallback(InitModeCallback);
      break;
    };
    case ALIGNMENTMODE:{
      camera.nextMode.setCallback(AlignmentModeCallback);
      alignmentMD.winx = camera.getWinX();
      alignmentMD.winy = camera.getWinY();
      alignmentMD.wind = camera.getWinDX();
      WriteToLog("Stuff","%d %d %d",alignmentMD.winx,alignmentMD.winy,alignmentMD.wind);
      break;
    };
    case SLEWINGMODE:{
      camera.nextMode.setCallback(SlewPointModeCallback);
      break;
    };
    case POINTINGMODE:{
      camera.nextMode.setCallback(SlewPointModeCallback);
      break;
    };
    case AUTOCOLLIMATIONMODE:{
      camera.nextMode.setCallback(AutocollimationModeCallback);
      break;
    };  
    default:
      break;
    };
  };
  //  camera.prepSettings(SlewingMode,0,0);
  //  camera.prepSettings(PointingMode,0,0);
  //  camera.nowMode.setEqual(AlignmentMode);
 
  //    HomeCamera();
  
    //MoveStage(30000);

  // periodicmessages.h/c contains the variables and calls needed to 
  // set up periodic messages that have to be sent to the MPF and the 
  // ground in various modes. 
#include "periodicmessages.h"
  
  // processmessages.h/c contains the variables and calls needed to 
  // process the messages from the MPF and the ground.
#include "processmessages.h"


  //for every change of mode there will be a goto mainloop command
  //to exit a program there will be a goto loopexit command. 

  FillRSquared();
  //  if(camera.getActiveSensor() == GUIDERSENSOR){
  //    GtoM_SwitchingGuiderRequest();
  //  };
  //  HelloDither.DitherPattern1(10);
 MainLoop:
  
  camera.stopStreaming();  // stop camera streaming


  camera.changeSettings(); // adjust camera parameters, including 
                           // the trigger time.

  modeID = camera.getModeID();

  camera.startStreaming(); // restart camera streaming. 


  //  WriteToLog("Got Here! B ");
  loopcounter = 0;

  if(camera.getModeID() == POINTINGMODE || (camera.getModeID()==ALIGNMENTMODE && camera.getSubModeID()==ALIGNTRACKROI)){
    ClearScreen();
    FontOverwrite();
  } else {
    FontMask();
  };
  
  //  WriteToLog("Got Here A !");

  if(camera.getModeID()==ALIGNMENTMODE && (camera.getSubModeID() == ALIGNTRACKROI || camera.getSubModeID() == ALIGNTRACKFULLCHIP || camera.getSubModeID() == ALIGNDRAGFULLCHIP)){
    //    GtoM_SwitchingGuiderRequest();
    //    camera.setActiveSensor(GUIDERSENSOR);
  } else {
    //    GtoM_SwitchingDTURequest();
    //    camera.setActiveSensor(OTHERSENSOR);
  }

  //    WriteToLog("Got Here!");
  //    WriteToLog("FLOOD","%d %d %d" ,camera.getRoiX(), camera.getRoiY(),camera.getRoiDX());
  do{

    #include "periodicmessages.cpp"
    #include "processmessages.cpp"

    camera.queueFrame();
    


  } while(1);
  

  camera.~QCamera();
  CloseLog();

  return 0;
};