From 19834f01110cc8cf38173577c96ce17153d681b7 Mon Sep 17 00:00:00 2001 From: Samuel Date: Mon, 24 Apr 2023 22:43:21 +0200 Subject: [PATCH] =?UTF-8?q?Fonction=20pour=20lancer=20les=20cerises=20revu?= =?UTF-8?q?e,=20envoie=20des=20cerises=20une=20=C3=A0=20une?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Strategie.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/Strategie.c b/Strategie.c index 8624b21..68b30a6 100644 --- a/Strategie.c +++ b/Strategie.c @@ -146,6 +146,7 @@ enum etat_action_t lance_balles(uint32_t step_ms){ LANCE_PROPULSEUR_ON, LANCE_TEMPO_PROP_ON, LANCE_PORTE_OUVERTE, + LANCE_OUVERTURE_INITIALE, } etat_lance_balle = LANCE_PROPULSEUR_ON; switch(etat_lance_balle){ @@ -153,36 +154,38 @@ enum etat_action_t lance_balles(uint32_t step_ms){ i2c_annexe_active_propulseur(); tempo_ms = 1000; nb_iteration=0; - etat_lance_balle = LANCE_TEMPO_PROP_ON; + etat_lance_balle = LANCE_OUVERTURE_INITIALE; + break; + + case LANCE_OUVERTURE_INITIALE: + if(temporisation_terminee(&tempo_ms, step_ms)){ + i2c_annexe_ouvre_porte(); + etat_lance_balle = LANCE_PORTE_OUVERTE; + tempo_ms = 250; + } break; case LANCE_TEMPO_PROP_ON: - if (tempo_ms < step_ms){ + if(temporisation_terminee(&tempo_ms, step_ms)){ + i2c_annexe_ouvre_porte(); nb_iteration++; if(nb_iteration > 10){ + nb_iteration=0; etat_action = ACTION_TERMINEE; etat_lance_balle = LANCE_PROPULSEUR_ON; i2c_annexe_desactive_propulseur(); }else{ etat_lance_balle = LANCE_PORTE_OUVERTE; - tempo_ms = 300; + tempo_ms = 150; } - - i2c_annexe_ouvre_porte(); - - }else{ - tempo_ms -= step_ms; } break; case LANCE_PORTE_OUVERTE: - if (tempo_ms < step_ms){ - i2c_annexe_ferme_porte(); + if(temporisation_terminee(&tempo_ms, step_ms)){ + i2c_annexe_mi_ferme_porte(); etat_lance_balle = LANCE_TEMPO_PROP_ON; - tempo_ms = 450; - - }else{ - tempo_ms -= step_ms; + tempo_ms = 500; } break;