예제 #1
0
파일: Repeat.cpp 프로젝트: Sytten/Armus
void repeatSongSelection()
{
	AUDIO_PlayFile(VOIX_REPEAT);
	LCD_ClearAndPrint("Bonne chance!\n");
	LCD_Printf("1\n");
	THREAD_MSleep(1000);
	LCD_Printf("2\n");
	THREAD_MSleep(1000);
	LCD_Printf("3\n");
	THREAD_MSleep(1000);
	LCD_Printf("GO!!!\n");

	//Random number to select the song to play
	int songSelect = rand()%4 + 1;

	switch (songSelect)
	{
		case 1:
			repeat(PATH_CLAIRE_FONTAINE);
			break;
		case 2:
			repeat(PATH_HYMNE_A_LA_JOIE);
			break;
		case 3:
			repeat(PATH_STAR_WARS);
			break;
		case 4:
			repeat(PATH_RENNE_NEZ_ROUGE);
			break;
		default:
			break;
	}
}
예제 #2
0
void set_expected_encoder_reads(int motor_speed){
	int average_encoder_read_right = 0, average_encoder_read_left = 0, total_encoder_read_right = 0, total_encoder_read_left = 0;
	int calculation_period = 3000;
	prompt_bumpers();
	reset_encoders();
	set_motors_speed(motor_speed);
	LCD_ClearAndPrint("Testing and setting encoder expected reads for %d ms...", calculation_period);
	THREAD_MSleep(calculation_period);
	total_encoder_read_right += ENCODER_Read(ENCODER_RIGHT);
	total_encoder_read_left += ENCODER_Read(ENCODER_LEFT);
	stop();
	EXPECTED_ENCODER_READ_LEFT = (int)floor(total_encoder_read_left/(calculation_period/__PID_TIME_INTERVAL__));
	EXPECTED_ENCODER_READ_RIGHT = (int)floor(total_encoder_read_right/(calculation_period/__PID_TIME_INTERVAL__));
	LCD_ClearAndPrint("Done!\nExpected encoder reads are:\nRight: %d\nLeft: %d\nPress any bumper to continue!",EXPECTED_ENCODER_READ_RIGHT,EXPECTED_ENCODER_READ_LEFT);
	prompt_bumpers();
	reset_encoders();
}
예제 #3
0
void testCouleur()
{
	//TODO: un 'if' qui prend la couleur avec le i2c ou analogue dependant du robot

	//le robot 43 a une pin entre le digital 9 et le Vcc
	bool estRobot43 = (DIGITALIO_Read(9) == 1);

	//initialiser le capteur cest important quand on s'appelle robot 43
	if(estRobot43)
		initCapteurI2C();

	//ofstream fichier;
	//fichier.open("couleur.txt");
	while(1)
	{
		RgbColor readColor;
		//step 1
		if(estRobot43)
			readColor = getColorI2C();
		else
			readColor = getColorAnalog();
		LCD_ClearAndPrint("\nR=%i, G=%i, B=%i", readColor.r, readColor.g, readColor.b);

		//fichier << "background-color: rgb(" <<readColor.r<<","<<readColor.g<<","<<readColor.b<<")"<< endl;
		//step 2
        HsbColor colorsHSB = RGBtoHSB(readColor);
		LCD_Printf("\nH=%.4f, S=%.4f, B=%.4f ", colorsHSB.hue, colorsHSB.saturation, colorsHSB.brightness);

		int laCouleur = currentFloorColor(colorsHSB,estRobot43);
		LCD_Printf("\n");
		switch(laCouleur){
					case 0:
						LCD_Printf("BLANC");break;
					case 1:
						LCD_Printf("BLEU");break;
					case 2:
						LCD_Printf("ROUGE");break;
					case 3:
						LCD_Printf("VERT");break;
					case 4:
						LCD_Printf("JAUNE");break;
					case 5:
						LCD_Printf("WTF");break;
					case 6:
						LCD_Printf("Noir");break;
					default:
						LCD_Printf("default");break;
				}

		//LCD_Printf("%s",laCouleur.c_str());
		/*if(estRobot43)
			laCouleur = currentFloorColor(colorsHSB);*/
		//else
			//laCouleur = currentFloorColorAnalog(colorsHSB);
		//LCD_Printf("%s",laCouleur.c_str());
	}
}
예제 #4
0
파일: Free.cpp 프로젝트: Sytten/Armus
void freePlay()
{
    AllLED(VERT);
	AUDIO_PlayFile(VOIX_FREE);
	LCD_ClearAndPrint("Je t'ecoute!\n");
	LCD_ClearAndPrint("Appuie sur un des trois boutons pour revenir au menu.\n");
	THREAD_MSleep(3000);

	PianoStream stream;

	stream.size = PIANO_SIZE;
	stream.streamID = -1;
	stream.currentNote = -1;

	Note notes[PIANO_SIZE] = {{false, true, VAL_DO1},
							  {false, true, VAL_RE},
							  {false, true, VAL_MI},
							  {false, true, VAL_FA},
							  {false, true, VAL_SOL},
							  {false, true, VAL_LA},
							  {false, true, VAL_SI},
							  {false, true, VAL_DO2}};
	stream.notes = notes;

	AUDIO_SetVolume(50);

	//Infinite loop until the buttons call break
	while(1)
	{
		CheckPressedKeys(&stream);
		PlayAndStopNotes(&stream);

		THREAD_MSleep(10);
		if(ButtonStatus(1) == 1 || ButtonStatus(2) == 1 || ButtonStatus(3) == 1)
			break;
	}

	//Assure the piano has stopped playing sounds
	ResetStream(&stream);
	PlayAndStopNotes(&stream);
}
예제 #5
0
void testDistance(){
	LCD_Printf("lol");
	bool IRgauche, IRdroite;
	while(1){

	switch(IR_Detect(IR_FRONT))
	      {
	          case 0: IRgauche=false;IRdroite=false;break;
	          case 1: IRdroite=true;IRgauche=false;break;
	          case 2: IRdroite=false;IRgauche=true;break;
	          case 3: IRdroite=true;IRgauche=true;break;
	      }
	      //----------------------------------------------
	      //tourne a droite si obstacle a gauche
	      if(IRgauche==false && IRdroite == false)
	      {
	    	  LCD_ClearAndPrint("Rien");

	      }
	      else if(IRgauche==true && IRdroite == false)
	      {
	    	  LCD_ClearAndPrint("Gauche");

	      }
	      else if(IRdroite==true && IRgauche == false)
	      {
	    	  LCD_ClearAndPrint("Droite");

	      }
	      else // 2 dÈtecteurs activÈs
	      {
	    	  LCD_ClearAndPrint("Deux");

	      }
	}
}
예제 #6
0
void testInfrarouge()
{

	LCD_ClearAndPrint("Test Infrarouge\n");

		int sortie = 0;
		sortie = IR_Detect(IR_FRONT);
		switch(sortie)
		{
			case 0: LCD_Printf("RIEN\n");break;
			case 1: LCD_Printf("DROITE\n");break;
			case 2: LCD_Printf("GAUCHE\n");break;
			case 3: LCD_Printf("DROITE ET GAUCHE\n");break;
		}
		THREAD_MSleep(100);
}