carte esclave Petit Robot

Dependencies:   mbed Herkulex_Library_2019 actions_Gr ident_crac actions_Pr

Revision:
8:8aeb718824ea
Parent:
7:553f3f1c2c53
Child:
9:9833e788942b
--- a/Capteurs/Capteur.cpp	Thu May 16 10:54:23 2019 +0000
+++ b/Capteurs/Capteur.cpp	Thu May 16 11:58:17 2019 +0000
@@ -1,41 +1,22 @@
 #include "Capteur.h"
 #include "mbed.h"
 #include "Actionneurs.h"
-#define NOMBRE_TELEMETRE 4
-#define precision 5
-#define CONSTANTE_TIR 0.639f
+#include "dt.h"
+
 
 ///////////////////////////////////////Capteurs de Contact///////////////////////
 DigitalIn capteur_contact_block(PB_15);
 DigitalIn capteur_contact1(PB_4);
 DigitalIn capteur_contact2(PB_5);
 DigitalIn capteur_contact3(PH_1);
-
 /////////////////////////////////////Lecture Batterie////////////////////////////
 AnalogIn Val_batterie(PC_2);
-
-
-////////////////////////////////////////Télémètres///////////////////////////////
-//distance
-AnalogIn telemetre1(PB_0);
-AnalogIn telemetre2(PC_5);
-AnalogIn telemetre3(PC_4);
-AnalogIn telemetre4(PA_5);
-//seuil logique
-DigitalIn telemetre1_isr(PB_1);
-DigitalIn telemetre2_isr(PA_7);
-DigitalIn telemetre3_isr(PA_6);
-DigitalIn telemetre4_isr(PA_4);
 ///////////////////////////////////Capteurs  multiCouleurs////////////////////////
-
-
-
 /////////////////////////////////////Capteurs monocouleur////////////////////////
 DigitalIn monocouleur1(PC_15);
 DigitalIn monocouleur2(PC_14);
 DigitalIn monocouleur3(PB_10);
 DigitalIn monocouleur4(PC_3);
-
 /////////////////////////////////////Capteurs industriels////////////////////////
 /*AnalogIn Capteur_indus1(PA_7);
 AnalogIn Capteur_indus2(PA_6);
@@ -46,71 +27,36 @@
 
 short distance_moyenne;
 
-short lecture_telemetre(char numero_telemetre){ // DEGUEUX MAIS FONCTIONNEL :')
-    //wait(1);
-    float telemetre_distance=0;
-    short distance;
-    long long distance_moyenne_somme=0;
-    for (unsigned char i=0; i<precision;i++){
-        if(numero_telemetre==1)
-        {
-            telemetre_distance=telemetre1.read();
-            distance=(((telemetre_distance)-0.2)*4671)+45;
-            wait_us(100);
-            telemetre_distance=telemetre1.read();
-            distance=(((telemetre_distance)-0.2)*4671)+50;
-            distance+=86;
-            distance=(distance*0.98)+16.6;
-        }
-        else if (numero_telemetre==2)
-        {
-            telemetre_distance=telemetre2.read();
-            distance=(((telemetre_distance)-0.2)*4671)+45;
-            wait_us(100);
-            telemetre_distance=telemetre2.read();
-            distance=(((telemetre_distance)-0.2)*4671)+50;
-            distance+=86;
-            distance=(distance*0.975)+25.7;
-        }
-        else if (numero_telemetre==3)
-        {
-            telemetre_distance=telemetre3.read();
-            distance=(((telemetre_distance)-0.2)*4671)+45;
-            wait_us(100);
-            telemetre_distance=telemetre3.read();
-            distance=(((telemetre_distance)-0.2)*4671)+50;
-            distance+=86;
-            distance=(distance*0.98)+15.6;
-        }
-        else if (numero_telemetre==4)
-        {
-            telemetre_distance=telemetre4.read();
-            distance=(((telemetre_distance)-0.2)*4671)+45;
-            wait_us(100);
-            telemetre_distance=telemetre4.read();
-            distance=(((telemetre_distance)-0.2)*4671)+50;
-            distance+=86;
-            distance=(distance*0.98)+11.15;
-        }
-        distance_moyenne_somme+=distance;
+short lecture_telemetre(char numero_telemetre)  // DEGUEUX MAIS FONCTIONNEL :')
+{
+    f_mesure();
+    switch(numero_telemetre) {
+        case 1:
+            distance_moyenne=(short)DT1_trait_Ex;
+            break;
+
+        case 2:
+            distance_moyenne=(short)DT2_trait_Ex;
+            break;
+
+        case 3:
+            distance_moyenne=(short)DT3_trait_Ex;
+            break;
+
+        case 4:
+            distance_moyenne=(short)DT4_trait_Ex;
+            break;
     }
-    distance_moyenne=(distance_moyenne_somme/precision);  
-    wait_us(100); 
     return distance_moyenne;
 }
 
 
 
-float Val_puissance(char zone_tir){
-    float voltage=Val_batterie.read()*3.3f;
-    float puissance_tir=CONSTANTE_TIR/voltage;
-    return puissance_tir;
-}
-int capteur_contact(void){
-    if(capteur_contact_block.read()==1){
+int capteur_contact(void)
+{
+    if(capteur_contact_block.read()==1) {
         return 1;
-    }
-    else{
+    } else {
         return 0;
     }
 }
\ No newline at end of file