コード例 #1
0
ファイル: main.c プロジェクト: Adam140/SW
/*****************************************************************************
 *
 * Description:
 *    A process entry function 
 *
 * Params:
 *    [in] arg - This parameter is not used in this application. 
 *
 ****************************************************************************/
static void proc2(void* arg) {
	//	testJoy();

	tU32 oldIOPIN, tmp;

	/* read input from joystick */
	IODIR &= ~0x001f0000;
	messageOnLCD("Joystick works!", TRUE);
	/* joystick support */
	tU32 oldMove;
	int i = 0, j = 0, h = 0;
	for (;;) {

		//		printf("IOPIN = %d",(IOPIN));

		oldIOPIN = IOPIN;
		osSleep(10);
		if (IOPIN == 1589624063) {
			printf("work");

		}
		tmp = (oldIOPIN & ~IOPIN);// & 0x001f0000;
		printf("tmp = %d", tmp);
		printf("\n");
		//	    if( oldMove != tmp)
		//	    	oldMove = tmp;`
		//	    if(tmp != 0x00000000) {
		//	      if(tmp == 0x00020000) {
		//	    	  messageOnLCD("Gora",TRUE);
		//	      }
		//	      else if(tmp == 0x00040000) messageOnLCD("Prawo",TRUE);
		//	      else if(tmp == 0x00100000)
		//	    	  {
		//	    	  messageOnLCD("Dol",TRUE);
		//	    	  }
		//	      else if(tmp == 0x00080000) messageOnLCD("Lewo",TRUE);
		//	      else if(tmp == 0x00010000) messageOnLCD("Center",TRUE);
		//	    }
		//	    if(tmp != 0) {
		if (tmp == 131072)
		{
			messageOnLCD("up", TRUE);

			if(h<8)
				h++;
			testLedMatrix(h);
			led(h);
//			IODIR0	|=	BUZZ_PIN;		//Select the Buzzer pin as Output
//			IOPIN0	&= ~(BUZZ_PIN);		//Clear the Buzzer pin
//
//		    while(1)
//			{
//				IOPIN0 |= BUZZ_PIN;		//Set the Buzzer pin High
//				osSleep(25);
//				//_DelayMs(250);	  		//A Delay
//				IOPIN0 &= ~BUZZ_PIN;	//Set the Buzzer pin Low
//				//_DelayMs(250);	       	//A Delay
//				osSleep(25);
//		    }
		}

		else if (tmp == 262144) {
			messageOnLCD("right", TRUE);
		} else if (tmp == 16384) {
			messageOnLCD("button", TRUE);

		} else if (tmp == 524288) {
			messageOnLCD("left", TRUE);
		} else if (tmp == 65536) {
			messageOnLCD("Center", TRUE);
			testMotor(0);

		} else if (tmp == 1048576)
			messageOnLCD("down", TRUE);
			if(h>0)
				h--;

			testLedMatrix(h);
			led(h);
		//	  }
		//	  else
		//	  {
		//		  messageOnLCD("NIC",TRUE);
		//	  }
	}
	osDeleteProcess();

}
コード例 #2
0
task main()
{
	textToAdd = "system test initialized.";
	addLog();
	textToAdd = "using I2C functions.";
	addLog();

	textToAdd = "waiting 5 seconds for the arm to reset...";
	addLog();
	for (int i = 0; i < 5000; i++)
	{
		Arm_Update();
		Sleep(1);
	}

	textToAdd = "moving the arm to a sane place...";
	addLog();
	Arm_SetSpeed(15);
	for (int i = 0; i < 30; i++)
	{
		Arm_Update();
		Sleep(1);
	}

	textToAdd = "testing encoders...";
	addLog();
	textToAdd = "using daisychain 1, motor 1.";
	addLog();
	testEncoder(1, 1);
	textToAdd = "using daisychain 1, motor 2.";
	addLog();
	testEncoder(1, 2);
	textToAdd = "using daisychain 2, motor 1.";
	addLog();
	testEncoder(2, 1);
	textToAdd = "using daisychain 2, motor 2.";
	addLog();
	testEncoder(2, 2);

	wait5();

	textToAdd = "testing motors...";
	addLog();
	textToAdd = "using daisychain 1, motor 1.";
	addLog();
	textToAdd = "running at power level 100.";
	addLog();
	testMotor(1, 1);
	textToAdd = "using daisychain 1, motor 1.";
	addLog();
	textToAdd = "running at power level 100.";
	addLog();
	testMotor(1, 2);
	textToAdd = "using daisychain 1, motor 1.";
	addLog();
	textToAdd = "running at power level 100.";
	addLog();
	testMotor(2, 1);
	textToAdd = "using daisychain 2, motor 2.";
	addLog();
	textToAdd = "running at power level 100.";
	addLog();
	testMotor(2, 2);

	wait5();

	textToAdd = "testing servos...";
	addLog();
	textToAdd = "using daisychain 3, servo 1.";
	addLog();
	testservo(3, 1);

	textToAdd = "physical systems check complete.";
	addLog();
	textToAdd = "software systems check unimplemented.";
	addLog();
	textToAdd = "systems check complete.";
	addLog();
}