diff --git a/Actionneurs/Actionneurs.ino b/Actionneurs/Actionneurs.ino index 9d2acce..d11eddd 100644 --- a/Actionneurs/Actionneurs.ino +++ b/Actionneurs/Actionneurs.ino @@ -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); } diff --git a/Cerveau/Cerveau.ino b/Cerveau/Cerveau.ino index e171e6e..ba6cd41 100644 --- a/Cerveau/Cerveau.ino +++ b/Cerveau/Cerveau.ino @@ -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); diff --git a/Cerveau/Com_gradins.h b/Cerveau/Com_gradins.h index 8325890..af32f12 100644 --- a/Cerveau/Com_gradins.h +++ b/Cerveau/Com_gradins.h @@ -9,4 +9,6 @@ struct detect_gradin_t{ float angle_rad; }; +int lire_tirette(void); + #endif \ No newline at end of file diff --git a/Cerveau/Com_gradins.ino b/Cerveau/Com_gradins.ino index 24b09e1..e35e067 100644 --- a/Cerveau/Com_gradins.ino +++ b/Cerveau/Com_gradins.ino @@ -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; + +} diff --git a/Doc/Communication I2C.odt b/Doc/Communication I2C.odt index f1193c0..e7e9c64 100644 Binary files a/Doc/Communication I2C.odt and b/Doc/Communication I2C.odt differ