Ajout de la gestion de la tirette

This commit is contained in:
Samuel 2025-05-26 15:27:06 +02:00
parent 7f435ccf92
commit 74629edaa0
5 changed files with 37 additions and 2 deletions

View File

@ -279,6 +279,9 @@ void loop()
Servo_set(DOIGT_PINCE_GAUCHE_FERME); Servo_set(DOIGT_PINCE_GAUCHE_FERME);
Servo_set(DOIGT_PINCE_DROIT_FERME); Servo_set(DOIGT_PINCE_DROIT_FERME);
} }
if(inByte == 'f'){
Servo_set(FOURCHE_LEVEE);
}
if(inByte == '1'){ if(inByte == '1'){
reglage_servo(8); reglage_servo(8);
} }

View File

@ -281,6 +281,7 @@ void gestion_match(){
struct detect_gradin_t detect_gradin; struct detect_gradin_t detect_gradin;
enum etat_action_t etat_action; enum etat_action_t etat_action;
static int translation_x_mm, translation_y_mm; static int translation_x_mm, translation_y_mm;
static char tirette_enlevee=1;
static float rotation_rad; static float rotation_rad;
static int couleur; static int couleur;
@ -343,6 +344,7 @@ void gestion_match(){
} }
delay(200); delay(200);
IHM_attente_match(&couleur); IHM_attente_match(&couleur);
tirette_enlevee = 1;
index_Maitre = MATCH_EN_COURS; index_Maitre = MATCH_EN_COURS;
@ -369,8 +371,14 @@ void gestion_match(){
break; break;
case MATCH_EN_COURS: case MATCH_EN_COURS:
if(Strategie(couleur) == ACTION_TERMINEE){ Serial.printf(">tirette_m:%d\n", tirette_enlevee);
index_Maitre = ATTENTE_ORDRE; if(tirette_enlevee == 0){
lire_tirette(&tirette_enlevee);
}
if(tirette_enlevee == 1){
if(Strategie(couleur) == ACTION_TERMINEE){
index_Maitre = ATTENTE_ORDRE;
}
} }
break; break;
@ -456,6 +464,9 @@ enum etat_action_t Strategie(int couleur){
case STRAT_ALLER_GRADINS_1_A: case STRAT_ALLER_GRADINS_1_A:
if(couleur == COULEUR_JAUNE){ 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); etat_action = deplacement_absolu(800, 800, -M_PI/2., 1);
}else{ }else{
etat_action = deplacement_absolu(3000 - 800, 800, -M_PI/2., 1); etat_action = deplacement_absolu(3000 - 800, 800, -M_PI/2., 1);

View File

@ -9,4 +9,6 @@ struct detect_gradin_t{
float angle_rad; float angle_rad;
}; };
int lire_tirette(void);
#endif #endif

View File

@ -30,3 +30,22 @@ int Detect_gradin(struct detect_gradin_t * detect_gradin, bool blocking){
} }
return error; 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.