carte esclave petit robot

Dependencies:   mbed Herkulex_Library_2019 actions_Gr ident_crac actions_Pr

Revision:
41:832128353732
Parent:
40:124575240d09
--- a/main.cpp	Thu May 23 18:42:51 2019 +0000
+++ b/main.cpp	Sat May 25 15:15:30 2019 +0000
@@ -14,7 +14,10 @@
 unsigned char EtatGameEnd=0;
 
 char cote;
+unsigned short distance_recalage,distance_revenir;
+unsigned short  distance_goldenium;
 
+Timer timeout;
 
 void canProcessRx(void);
 
@@ -65,7 +68,7 @@
     pc.printf("\nLAUNCHED");
     while(1) {
         canProcessRx();
-        f_mesure();//dt35
+        f_mesure();//dt35 distance
 
 
 #ifdef ROBOT_SMALL
@@ -108,7 +111,6 @@
 
     }
 }
-
 /****************************************************************************************/
 /* FUNCTION NAME: canProcessRx                                                          */
 /* DESCRIPTION  : Fonction de traitement des messages CAN                               */
@@ -156,12 +158,25 @@
                 SendAck(ACKNOWLEDGE_TELEMETRE,RECEPTION_DATA);
                 break;
 
+            case DATA_TELEMETRE_LOGIQUE:
+                msgTx.id=RECEPTION_TELEMETRE_LOGIQUE; // tx Valeur Telemetre1
+                msgTx.len=4;
+                msgTx.format=CANStandard;
+                msgTx.type=CANData;
+                msgTx.data[0]=(unsigned char)DT1_interrupt_Ex;
+                msgTx.data[1]=(unsigned char)DT2_interrupt_Ex;
+                msgTx.data[2]=(unsigned char)DT3_interrupt_Ex;
+                msgTx.data[3]=(unsigned char)DT4_interrupt_Ex;
+                can.write(msgTx);
+                SendAck(ACKNOWLEDGE_TELEMETRE,RECEPTION_TELEMETRE_LOGIQUE);
+                break;
+                
             case DATA_RECALAGE:
                 short distance1=lecture_telemetre(1);
                 short distance2=lecture_telemetre(2);
                 short distance3=lecture_telemetre(3);
                 short distance4=lecture_telemetre(4);
-
+          
                 msgTx.id=RECEPTION_RECALAGE; // tx Valeur Telemetre1
                 msgTx.len=8;
                 msgTx.format=CANStandard;
@@ -180,7 +195,6 @@
                 break;
 
 
-
 //--------------------------------------------------------------------------ACK carte pompe----------------------------------------------
 
 
@@ -200,8 +214,6 @@
 
 //-------------------------------------------------------------------------------------------------------------------------------------------
 
-
-
             case PRESENTOIR_AVANT:
                 fpresentoir_avant=1;
                 break;
@@ -209,7 +221,6 @@
             case GABARIT_ROBOT:
                 SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION);
                 gabarit_robot();
-
                 SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION);
                 break;
 
@@ -239,6 +250,8 @@
 
             case ACCELERATEUR_AVANT:
                 faccelerateur_avant=1;
+                distance_recalage=msgRxBuffer[FIFO_lecture].data[0]|((unsigned short)(msgRxBuffer[FIFO_lecture].data[1])<<8);
+                distance_revenir=msgRxBuffer[FIFO_lecture].data[2]|((unsigned short)(msgRxBuffer[FIFO_lecture].data[3])<<8);
                 break;
 
             case ACCELERATEUR_ARRIERE:
@@ -247,6 +260,8 @@
 
             case GOLDENIUM_AVANT:
                 fgoldenium_avant=1;
+                distance_goldenium=msgRxBuffer[FIFO_lecture].data[0]|((unsigned short)(msgRxBuffer[FIFO_lecture].data[1])<<8);
+
                 break;
 
             case GOLDENIUM_ARRIERE:
@@ -270,7 +285,6 @@
                 break;
 
 
-            
 
             case ARRIERE_RELACHE:
                 farriere_relache=1;