From aa9ec10e42b4f9596e28b2d5de5e5fbb9799f094 Mon Sep 17 00:00:00 2001 From: Samuel Date: Thu, 29 May 2025 22:52:18 +0200 Subject: [PATCH] =?UTF-8?q?Am=C3=A9lioration=20communication?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cerveau/Com_detection_adversaire.ino | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Cerveau/Com_detection_adversaire.ino b/Cerveau/Com_detection_adversaire.ino index f2eef8b..a08f949 100644 --- a/Cerveau/Com_detection_adversaire.ino +++ b/Cerveau/Com_detection_adversaire.ino @@ -6,17 +6,14 @@ int Detect_adv_lire(struct detect_adv_reception_t * detect_adv_reception){ return Detect_adv_lire(detect_adv_reception, true); } /// @brief Lit les capteurs VL53L1X -int Detect_adv_lire(struct detect_adv_reception_t * detect_adv_reception, bool blocking){ +int Detect_adv_lire(struct detect_adv_reception_t * detect_adv_reception, bool continuous_try){ unsigned char tampon2[14]; //(Adresse I2c, Adresse dans le registre, tampon, longueur de donnée) error = I2C_lire_registre(I2C_SLAVE_detect_adv, 0, detect_adv_reception->distance_cm, 12); - if (error !=0){ + while (error !=0 && continuous_try){ affiche_erreur("Scan_Detect_adversaire", "Erreur I2C"); - if(blocking){ - while(1); - } - }else{ - Serial.println("I2C OK"); + error = I2C_lire_registre(I2C_SLAVE_detect_adv, 0, detect_adv_reception->distance_cm, 12); + } return error; }