Ajout de la gestion de la tirette
This commit is contained in:
		
							parent
							
								
									7f435ccf92
								
							
						
					
					
						commit
						74629edaa0
					
				| @ -279,6 +279,9 @@ void loop() | ||||
|       Servo_set(DOIGT_PINCE_GAUCHE_FERME); | ||||
|       Servo_set(DOIGT_PINCE_DROIT_FERME); | ||||
|     } | ||||
|     if(inByte == 'f'){ | ||||
|       Servo_set(FOURCHE_LEVEE); | ||||
|     } | ||||
|     if(inByte == '1'){ | ||||
|       reglage_servo(8); | ||||
|     } | ||||
|  | ||||
| @ -281,6 +281,7 @@ void gestion_match(){ | ||||
|   struct detect_gradin_t detect_gradin; | ||||
|   enum etat_action_t etat_action; | ||||
|   static int translation_x_mm, translation_y_mm; | ||||
|   static char tirette_enlevee=1; | ||||
|   static float rotation_rad; | ||||
|   static int couleur; | ||||
| 
 | ||||
| @ -343,6 +344,7 @@ void gestion_match(){ | ||||
|         } | ||||
|         delay(200); | ||||
|         IHM_attente_match(&couleur); | ||||
|         tirette_enlevee = 1; | ||||
| 
 | ||||
|         index_Maitre = MATCH_EN_COURS; | ||||
|          | ||||
| @ -369,8 +371,14 @@ void gestion_match(){ | ||||
|       break; | ||||
| 
 | ||||
|     case MATCH_EN_COURS: | ||||
|       if(Strategie(couleur) == ACTION_TERMINEE){ | ||||
|         index_Maitre = ATTENTE_ORDRE; | ||||
|       Serial.printf(">tirette_m:%d\n", tirette_enlevee); | ||||
|       if(tirette_enlevee == 0){ | ||||
|         lire_tirette(&tirette_enlevee); | ||||
|       } | ||||
|       if(tirette_enlevee == 1){ | ||||
|         if(Strategie(couleur) == ACTION_TERMINEE){ | ||||
|           index_Maitre = ATTENTE_ORDRE; | ||||
|         } | ||||
|       } | ||||
|       break; | ||||
| 
 | ||||
| @ -456,6 +464,9 @@ enum etat_action_t Strategie(int couleur){ | ||||
| 
 | ||||
|     case STRAT_ALLER_GRADINS_1_A: | ||||
|       if(couleur == COULEUR_JAUNE){ | ||||
|         translation_x_mm = 0; | ||||
|         translation_y_mm = 450; | ||||
|         rotation_rad = 0; | ||||
|         etat_action = deplacement_absolu(800, 800, -M_PI/2., 1); | ||||
|       }else{ | ||||
|         etat_action = deplacement_absolu(3000 - 800, 800, -M_PI/2., 1); | ||||
|  | ||||
| @ -9,4 +9,6 @@ struct detect_gradin_t{ | ||||
|   float angle_rad; | ||||
| }; | ||||
| 
 | ||||
| int lire_tirette(void); | ||||
| 
 | ||||
| #endif | ||||
| @ -30,3 +30,22 @@ int Detect_gradin(struct detect_gradin_t * detect_gradin, bool blocking){ | ||||
|   } | ||||
|   return error; | ||||
| } | ||||
| 
 | ||||
| int lire_tirette(char * tirette){ | ||||
|   return lire_tirette(tirette, true); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| int lire_tirette(char * tirette, bool continuous_try){ | ||||
|   unsigned char tampon; | ||||
|   //(Adresse I2c, Adresse dans le registre, tampon, longueur de donnée)
 | ||||
|   error = I2C_lire_registre(I2C_SLAVE_detect_gradin, 0x0d, &tampon, 1); | ||||
|   while(error !=0 && continuous_try){ | ||||
|     affiche_erreur("lire_tirette", "Erreur I2C"); | ||||
|     error = I2C_lire_registre(I2C_SLAVE_detect_gradin, 0x0d, &tampon, 1); | ||||
|   } | ||||
|   *tirette = tampon; | ||||
|   Serial.printf(">tirette:%d", *tirette); | ||||
|   return error; | ||||
| 
 | ||||
| } | ||||
|  | ||||
										
											Binary file not shown.
										
									
								
							
		Loading…
	
		Reference in New Issue
	
	Block a user