Exemple #1
0
void	pwm_leftback(u8 highpwm) //
{
	if (highpwm !=0)
	pwm_left(0);
	PWMn_Update(PCA2,highpwm);
}
void strat_manage(struct strategy * strat){
	static uint24_t starttime;
	
	if( beudatraj.state==READY){
	
			switch(Strat_State){
				case STRAT_GET_ELT_ON_TABLE:
				#ifdef DEBUG_STRAT
				UART_CPutString("strat> get elt on table\r\n");
				#endif
					strat_go_get_elts_on_table(strat);
				break;
			
					 
				case STRAT_CONSTRUCT_TEMPLE_3:
				#ifdef DEBUG_STRAT
				UART_CPutString("strat> hav to build a temple 3\r\n");
				#endif
					strat_construct_temple(strat,3,0); //0 it depends on our color
				break;
				
				case STRAT_GET_LINT_1:
				#ifdef DEBUG_STRAT
				UART_CPutString("strat> get lint area 1\r\n");
				#endif
					strat_go_get_lint(strat,LINT_DISP_L1);
				break;
				
				case STRAT_GET_LINT_2:
				#ifdef DEBUG_STRAT
				UART_CPutString("strat> get lint area 2\r\n");
				#endif
					strat_go_get_lint(strat,LINT_DISP_L2);
				break;
				
				case STRAT_GET_ELT_ON_FIXED_DISP:
				#ifdef DEBUG_STRAT
				UART_CPutString("strat> get elt on fixed disp\r\n");
				#endif
					strat_go_get_elts_disp(strat,0);
				break;
				
				
				case STRAT_GET_ELT_ON_RAND_DISP_1:
				#ifdef DEBUG_STRAT
				UART_CPutString("strat> get elt on rand 1\r\n");
				#endif
					strat_go_get_elts_disp(strat,1);
				break;
				
				case STRAT_GET_ELT_ON_RAND_DISP_2:
				#ifdef DEBUG_STRAT
				UART_CPutString("strat> get elt on disp 2\r\n");
				#endif
					strat_go_get_elts_disp(strat,2);
				break;
				 
				case STRAT_CONSTRUCT_TEMPLE_2_1:
				#ifdef DEBUG_STRAT
				UART_CPutString("strat> constr temp 2 1\r\n");
				#endif
					strat_construct_temple(strat,2,1);

				break;
				
				case STRAT_CONSTRUCT_TEMPLE_2_2:
				#ifdef DEBUG_STRAT
				UART_CPutString("strat> constr temp 2 2\r\n");
				#endif
					strat_construct_temple(strat,2,2);
				break;
			
				case STRAT_CONSTRUCT_TEMPLE_1_1:
				#ifdef DEBUG_STRAT
				UART_CPutString("strat> constr temp 1 1\r\n");
				#endif
					strat_construct_temple(strat,1,1);
				break;
				
				case STRAT_CONSTRUCT_TEMPLE_1_2:
				#ifdef DEBUG_STRAT
				UART_CPutString("strat> constr temp 1 2\r\n");
				#endif
					strat_construct_temple(strat,1,2);
				break;
				
				case STRAT_CONSTRUCT_TEMPLE_1_3:
				#ifdef DEBUG_STRAT
				UART_CPutString("strat> constr temp 1 3\r\n");
				#endif
					strat_construct_temple(strat,1,3);
				break;
				
				case STRAT_CONSTRUCT_TEMPLE_1_4:
				#ifdef DEBUG_STRAT
				UART_CPutString("strat> constr temp 1 4\r\n");
				#endif
					strat_construct_temple(strat,1,4);
				break;
				
				case STRAT_EMERGENCY_BEHAVIOUR:
				#ifdef DEBUG_STRAT
				UART_CPutString("strat> emergency behaviour on\r\n");
				#endif
					strat_do_emergency_behaviour();
					PRT2DR ^=0x80;
				break;
				
				case STRAT_EXIT:
			
					#ifdef DEBUG_STRAT
					UART_CPutString("strat> exit\r\n");
					#endif
					pwm_left(0);
					pwm_right(0);
					
					//ordre i2c pour sortir et ouvrir la pince
					i2c_send_only(I2C_TAPIS_ROULEAUX_ADDR, I2C_TAPIS_EJECT);
					i2c_send_only(I2C_LINTO_ADDR,I2C_LINT_DROP);
					i2c_send_only(I2C_PINCE_ADDR,I2C_PINCE_DROP);
					
					starttime = gettime();
					while(gettime() < (starttime + DELAY_TAPIS_EJECT));
						i2c_send_only(I2C_TAPIS_ROULEAUX_ADDR, I2C_TAPIS_STOP);
						clearBit(beudabot.events,EVENT_DO_STRAT);
					while(1);
				break;
			}
	}
}
Exemple #3
0
/**************************停止*****************************/
void stop() {pwm_left(0);	pwm_right(0);	pwm_leftback(0);}