Alexandre Salconi-Denis / Mbed 2 deprecated ProjetOctopode

Dependencies:   debug mbed

Files at this revision

API Documentation at this revision

Comitter:
salco
Date:
Tue Sep 29 17:23:25 2015 +0000
Parent:
36:474d4795aafa
Child:
38:57d5f36a0333
Commit message:
modification de la fonction analiseMaze();

Changed in this revision

directive.cpp Show annotated file Show diff for this revision Revisions of this file
labyrinthe.cpp Show annotated file Show diff for this revision Revisions of this file
labyrinthe.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
settingDebug.h Show annotated file Show diff for this revision Revisions of this file
source/Task/TTaskGeneral.h Show annotated file Show diff for this revision Revisions of this file
--- a/directive.cpp	Sun Sep 13 06:56:09 2015 +0000
+++ b/directive.cpp	Tue Sep 29 17:23:25 2015 +0000
@@ -96,34 +96,66 @@
 {
        
        #ifdef DEBUG_BOOT_GRAPHICAL_INTERFACE
-    if(pc.readable()){
-        
-    debug("\x1B[2J"); //clear screen
-    debug("\x1B[25l");//hide cursor
-    debug("\x1B[;H"); //cursor default position
-    
-    int idCommand;
-    
-    idCommand = fgetc(pc) - '0';
-    switch(idCommand)
-    {
-        case 1:
-            createDLbox(0,0,10,25,"BrainControle");    
-            setText(1,3,"1) Move Up");
-            setText(1,4,"2) Move Down");
-            setText(1,5,"2) Move Left");
-            setText(1,6,"2) Move Right");
-        break;
-        
-        case 2:
-            createDLbox(0,0,10,20,"Show Maze");    
-        break;
-    }
-    }
+       debug("\x1B[2J"); //clear screen
+       debug("\x1B[25l");//hide cursor
+       debug("\x1B[;H"); //cursor default position
+       /*
+       createDLbox(0,0,10,25,"BrainControle");    
+        setText(1,3,"1) Move Up");
+        setText(1,4,"2) Move Down");
+        setText(1,5,"3) Move Left");
+        setText(1,6,"4) Move Right");
+                 
+       int idCommand;
+       do{
+            if(pc.readable()){
+                idCommand = fgetc(pc) - '0';
+                switch(idCommand)
+                {
+                case 1:
+                    myMaze->goUp();
+                    break;
+                case 2:
+                    myMaze->goDown();    
+                    break;
+                case 3:
+                    myMaze->goLeft();    
+                    break;
+                case 4:
+                    myMaze->goRight();    
+                    break;
+                }
+                myMaze->setMyPos(Labyrinthe::explorer);
+                
+                string mymap = myMaze->showMap();
+                debug(DEBUG_DIRECTIVE_LABYRINTH,"\n\r  Labyrinthe map: X:%02x Y:%02x \n\r",myMaze->getX(),myMaze->getY());
+                for(int i=0; i<3; i++) debug(DEBUG_DIRECTIVE_LABYRINTH," [%02X] ",mymap[i+6]);
+                debug(DEBUG_DIRECTIVE_LABYRINTH,"\n\r");
+                for(int i=0; i<3; i++) debug(DEBUG_DIRECTIVE_LABYRINTH," [%02X] ",mymap[i+3]);
+                debug(DEBUG_DIRECTIVE_LABYRINTH,"\n\r");
+                for(int i=0; i<3; i++) debug(DEBUG_DIRECTIVE_LABYRINTH," [%02X] ",mymap[i]);
+                debug(DEBUG_DIRECTIVE_LABYRINTH,"\n\r");
+                
+                #ifdef DBG_MAIN_DELAY_SEC
+                debug("\n\r\n wait \n\r\n");
+                wait(DBG_MAIN_DELAY_SEC);
+                #endif   
+                
+                debug("\x1B[2J"); //clear screen
+                debug("\x1B[;H"); //cursor default position
+                createDLbox(0,0,10,25,"BrainControle");    
+                setText(1,3,"1) Move Up");
+                setText(1,4,"2) Move Down");
+                setText(1,5,"3) Move Left");
+                setText(1,6,"4) Move Right");
+            }
+        }while(1);   */
     #endif
     
     //debug(DEBUG_DIRECTIVE_TEST,"\n\rIn task directive");
+    #ifndef DEBUG_DIRECTIVE_LEG_DISABLE
     if(ctrDesPattes->isSeqComplet()) {
+        
         if((tableauDeCommange[0] == 6) && (size_tableauDeCommange == 1)) {
             //addTableauDeCommande(0x81);
             //addTableauDeCommande(0x82);
@@ -135,6 +167,8 @@
             addTableauDeCommande(0x87);
             addTableauDeCommande(0x88);
         }
+     
+
         if(tableauDeCommange[0] == 0) {
             //pas sur que c'Est tout ce qui doit etre ici mais je vois pas quoi d'autre pour le moment.
 
@@ -152,7 +186,7 @@
                 debug("\n\r flag: %d",flag[0]);
                 debug("\n\r data: %x",data[0]);
             }*/
-#ifndef BACKUP
+
             updateModuleValue();
 
             //////////////////////////////
@@ -161,7 +195,7 @@
             debug(DEBUG_DIRECTIVE_TEST,"\n\r        -IRToCm(%02f): %02f",ADCTomv(m_valueCapteurIR),IRToCm(ADCTomv(m_valueCapteurIR)));
             debug(DEBUG_DIRECTIVE_TEST,"\n\r        -ultrasonicToInch: %02f",ultrasonicToInch(m_valueCapteurUltrasonic));
             debug(DEBUG_DIRECTIVE_TEST,"\n\r        -m_valueCapteurProximiter: %02d",m_valueCapteurProximiter);
-
+#endif //DEBUG_DIRECTIVE_LEG_DISABLE
             analiseMaze();
             char nextCase=0;
             switch(myMaze->getDirection()) {
@@ -183,14 +217,21 @@
             }
 
             switch(nextCase ) {
-                case Labyrinthe::vide:
+                case Labyrinthe::vide :
+                    #ifdef DEBUG_DIRECTIVE_LEG_DISABLE
+                    debug("nextCase Vide\n\r");
+                    #endif
                     debug(DEBUG_DIRECTIVE_TEST," Javance");
+                    #ifndef DEBUG_DIRECTIVE_LEG_DISABLE
                     addTableauDeCommande(6);
+                    #endif
                     break;
 
-                case EXPLORER:// ici pt amiliorer
+                case Labyrinthe::explorer :// ici pt amiliorer
                     debug(DEBUG_DIRECTIVE_TEST," Javance");
+                    #ifndef DEBUG_DIRECTIVE_LEG_DISABLE
                     addTableauDeCommande(6);
+                    #endif
                     break;
 
                 case Labyrinthe::mur:
@@ -222,14 +263,15 @@
 
                     break;
 
-                case Labyrinthe::pasExplorer:
+                case Labyrinthe::pasExplorer :
                     debug(DEBUG_DIRECTIVE_TEST," Javance");
+                    #ifndef DEBUG_DIRECTIVE_LEG_DISABLE
                     addTableauDeCommande(6);
+                    #endif
                     break;
             }
 
-#endif
-#if BACKUP
+#ifndef DEBUG_DIRECTIVE_LEG_DISABLE
             /*if((ultrasonicToInch(m_valueCapteurUltrasonic)< 1) && (IRToCm(ADCTomv(m_valueCapteurIR)) <= 80)) //capteur ultrasson embrouiller/imprecis
             {
                 debug(DEBUG_DIRECTIVE_TEST,"\n\r        -Capteur Ultrasson brouiller");
@@ -276,11 +318,13 @@
 
                 //addTableauDeCommande(6);
             }*/
-#endif
+
             ///////////////
             // Mouvement //
             ///////////////
-        } else {
+        }
+        else {
+            
             switch(tableauDeCommange[0]) {
                 case 11:
                     debug(DEBUG_DIRECTIVE_TEST,"\n\r        -set_calibre");
@@ -352,9 +396,11 @@
             tableauDeCommange[9]=0;
             if(size_tableauDeCommange != 0) size_tableauDeCommange--;
         }
-    } else {
+        
+    } else { 
         ctrDesPattes->exec();
     }
+    #endif //DEBUG_DIRECTIVE_LEG_DISABLE
     ////////////////////
     // Update memoire //
     ////////////////////
@@ -365,6 +411,12 @@
 
 
     //debug(DEBUG_DIRECTIVE_TEST,"\n\rOut task directive");
+   #ifdef DEBUG_BOOT_GRAPHICAL_INTERFACE
+                #ifdef DBG_MAIN_DELAY_SEC
+                debug("\n\r\n wait \n\r\n");
+                wait(DBG_MAIN_DELAY_SEC);
+                #endif   
+    #endif
 }
 double Directive::IRToCm (double miliVolt)
 {
@@ -423,6 +475,23 @@
     char areaVert =0;
     string mymap = myMaze->showMap();
     debug(DEBUG_DIRECTIVE_LABYRINTH,"\n\r  Labyrinthe map: X:%02x Y:%02x \n\r",myMaze->getX(),myMaze->getY());
+    
+    debug("Direction: ");
+    switch(myMaze->getDirection()) {
+        case UP:
+            debug(DEBUG_DIRECTIVE_LABYRINTH,"Up \n\r");
+            break;
+        case DOWN:
+            debug(DEBUG_DIRECTIVE_LABYRINTH,"Down \n\r");
+            break;
+        case LEFT:
+            debug(DEBUG_DIRECTIVE_LABYRINTH,"Left \n\r");
+            break;
+        case RIGHT:
+            debug(DEBUG_DIRECTIVE_LABYRINTH,"Right \n\r");
+            break;
+        }
+    
     for(int i=0; i<3; i++) debug(DEBUG_DIRECTIVE_LABYRINTH," [%02X] ",mymap[i+6]);
     debug(DEBUG_DIRECTIVE_LABYRINTH,"\n\r");
     for(int i=0; i<3; i++) debug(DEBUG_DIRECTIVE_LABYRINTH," [%02X] ",mymap[i+3]);
@@ -431,7 +500,7 @@
     debug(DEBUG_DIRECTIVE_LABYRINTH,"\n\r");
 
 
-
+#ifndef DEBUG_DIRECTIVE_LABYRINTH_USER_CTRL 
     if((ultrasonicToInch(m_valueCapteurUltrasonic)< 1) && (IRToCm(ADCTomv(m_valueCapteurIR)) <= 80)) { //capteur ultrasson embrouiller/imprecis
         debug(DEBUG_DIRECTIVE_TEST,"\n\r        -Capteur Ultrasson brouiller");
         //addTableauDeCommande(6);
@@ -444,6 +513,8 @@
         areaLatt =1;
         areaVert =1;
     }
+    debug(DEBUG_DIRECTIVE_TEST,": %i",ultrasonicToInch(m_valueCapteurUltrasonic));
+    
     if(IRToCm(ADCTomv(m_valueCapteurIR)) <= 60) {
         debug(DEBUG_DIRECTIVE_TEST,"\n\r          -Confirmation IR");
         areaVert =2;
@@ -451,216 +522,241 @@
         debug(DEBUG_DIRECTIVE_TEST,"\n\r          -Confirmation IR");
         areaVert =1;
     }
-
-
-    switch(myMaze->getDirection()) {
-        case UP:
-            switch(areaVert) {
-                case 0:
-                    myMaze->setC_Up(Labyrinthe::mur);
-                    break;
+    debug(DEBUG_DIRECTIVE_TEST,": %i",IRToCm(ADCTomv(m_valueCapteurIR));
+#endif
 
-                case 1:
-                    if(areaLatt == 0) {
-                        myMaze->setC_Up(Labyrinthe::mur);
-                    } else if(areaLatt == 1) {
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()-1,myMaze->getY()+1);
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX(),myMaze->getY()+1);
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()+1,myMaze->getY()+1);
+#ifdef DEBUG_DIRECTIVE_LABYRINTH_USER_CTRL
+    debug("\n\r---analise maze(manualy CTRL)---\n\r");
+    int idCommand = -1;
+    do{
+    debug("\n\r Enter areaVert [0,1,2]: "); idCommand = fgetc(pc) - '0';
+    debug(" %i",idCommand);
+    }while((idCommand < 0) && (idCommand > 2));
+    areaVert = idCommand;
+    
+    do{
+    debug("\n\r Enter areaLatt [0,1,2]: "); idCommand = fgetc(pc) - '0';
+    debug(" %i",idCommand);
+    }while((idCommand < 0) && (idCommand > 2));
+    areaLatt = idCommand;
 
-                        myMaze->setC(Labyrinthe::mur,myMaze->getX(),myMaze->getY()+2);
-                    } else if(areaLatt == 2) {
+    debug("\n\r");
+#endif
+//changer lalgoritme ici
+
+/*
+/---\
+|?M?| //vert 0
+|.X.| //latt 0
+|...|
+\---/
 
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()-1,myMaze->getY()+1);
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX(),myMaze->getY()+1);
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()+1,myMaze->getY()+1);
+/-M-\
+|?V?| //vert 1
+|.X.| //latt 0
+|...|
+\---/   
+        
+/?M?\
+|VVV| //vert 1
+|.X.| //latt 1
+|...| // objet possiblement a proximiter 
+\---/
 
-                        myMaze->setC(Labyrinthe::pasExplorer,myMaze->getX()-1,myMaze->getY()+2);
-                        myMaze->setC(Labyrinthe::mur,myMaze->getX(),myMaze->getY()+2);
-                        myMaze->setC(Labyrinthe::pasExplorer,myMaze->getX()+1,myMaze->getY()+2);
-                    }
-                    break;
+/?M?\
+|VVV| //vert 1
+|.X.| //latt 2
+|...| // cas impossible
+\---/
 
-                case 2:
-                    if(areaLatt == 0) {
-                        myMaze->setC_Up(Labyrinthe::mur);
-                    } else if(areaLatt == 1) {
-                        myMaze->setC(Labyrinthe::pasExplorer,myMaze->getX()-1,myMaze->getY()+1);//mur?
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX(),myMaze->getY()+1);
-                        myMaze->setC(Labyrinthe::pasExplorer,myMaze->getX()+1,myMaze->getY()+1);//mur?
+/?V?\
+|?V?| //vert 2
+|.X.| //latt 0
+|...| // objet possiblement a proximiter
+\---/
+
+/?V?\
+|VVV| //vert 2
+|.X.| //latt 1
+|...| // objet possiblement a proximiter
+\---/
 
-                        //myMaze->setC(Labyrinthe::pasExplorer,myMaze->getX()-1,myMaze->getY()+1);//mur?
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX(),myMaze->getY()+2);
-                        //myMaze->setC(Labyrinthe::pasExplorer,myMaze->getX()+1,myMaze->getY()+1);//mur?
-                    } else if(areaLatt == 2) {
-
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()-1,myMaze->getY()+1);
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX(),myMaze->getY()+1);
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()+1,myMaze->getY()+1);
+/VVV\
+|VVV| //vert 2
+|.X.| //latt 2
+|...|
+\---/
+*/
+//vertical==0 latt==0 //mur devant
+//vertical==1 latt==1
+////////////////////////////////////
+//345  415
+//012  203| numerotation des case
+///////////////////////////////////
+signed char fieldX[6]={0,0,0,0,0,0};
+signed char fieldY[6]={0,0,0,0,0,0};
+bool fieldSet = false;
 
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()-1,myMaze->getY()+2);
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX(),myMaze->getY()+2);
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()+1,myMaze->getY()+2);
-                    }
-                    break;
-            }
-
+switch(myMaze->getDirection()) 
+{
+    case UP:
+        fieldX[0] = myMaze->getX()-1;
+        fieldY[0] = myMaze->getY()+1;
+        fieldX[1] = myMaze->getX();
+        fieldY[1] = myMaze->getY()+1;
+        fieldX[2] = myMaze->getX()+1;
+        fieldY[2] = myMaze->getY()+1;
+        fieldX[3] = myMaze->getX()-1;
+        fieldY[3] = myMaze->getY()+2;
+        fieldX[4] = myMaze->getX();
+        fieldY[4] = myMaze->getY()+2;
+        fieldX[5] = myMaze->getX()+1;
+        fieldY[5] = myMaze->getY()+2;
+        break;
+        
+    case DOWN:
+        fieldX[0] = myMaze->getX()-1;
+        fieldY[0] = myMaze->getY()-1;
+        fieldX[1] = myMaze->getX();
+        fieldY[1] = myMaze->getY()-1;
+        fieldX[2] = myMaze->getX()+1;
+        fieldY[2] = myMaze->getY()-1;
+        fieldX[3] = myMaze->getX()-1;
+        fieldY[3] = myMaze->getY()-2;
+        fieldX[4] = myMaze->getX();
+        fieldY[4] = myMaze->getY()-2;
+        fieldX[5] = myMaze->getX()+1;
+        fieldY[5] = myMaze->getY()-2;
+        break;
+        
+    case LEFT:
+        fieldX[0] = myMaze->getX()-1;
+        fieldY[0] = myMaze->getY()-1;
+        fieldX[1] = myMaze->getX()-1;
+        fieldY[1] = myMaze->getY();
+        fieldX[2] = myMaze->getX()-1;
+        fieldY[2] = myMaze->getY()+1;
+        fieldX[3] = myMaze->getX()-2;
+        fieldY[3] = myMaze->getY()-1;
+        fieldX[4] = myMaze->getX()-2;
+        fieldY[4] = myMaze->getY();
+        fieldX[5] = myMaze->getX()-2;
+        fieldY[5] = myMaze->getY()+1;
+        break;
+        
+    case RIGHT:
+        fieldX[0] = myMaze->getX()+1;
+        fieldY[0] = myMaze->getY()-1;
+        fieldX[1] = myMaze->getX()+1;
+        fieldY[1] = myMaze->getY();
+        fieldX[2] = myMaze->getX()+1;
+        fieldY[2] = myMaze->getY()+1;
+        fieldX[3] = myMaze->getX()+2;
+        fieldY[3] = myMaze->getY()-1;
+        fieldX[4] = myMaze->getX()+2;
+        fieldY[4] = myMaze->getY();
+        fieldX[5] = myMaze->getX()+2;
+        fieldY[5] = myMaze->getY()+1;
+        break;
+}  
+    if(areaVert >= areaLatt)
+    {
+        switch(areaVert)
+        {
+         case 0:
+             /*
+                /---\
+                |?M?| //vert 0
+                |.X.| //latt 0
+                |...|
+                \---/
+             */
+            myMaze->setC(Labyrinthe::mur,fieldX[1],fieldY[1]);
+            fieldSet = true;
             break;
-
-        case DOWN:
-            switch(areaVert) {
-                case 0:
-                    myMaze->setC_Down(Labyrinthe::mur);
-                    break;
-
-                case 1:
-                    if(areaLatt == 0) {
-                        myMaze->setC_Down(Labyrinthe::mur);
-                    } else if(areaLatt == 1) {
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()-1,myMaze->getY()-1);
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX(),myMaze->getY()-1);
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()+1,myMaze->getY()-1);
-
-                        myMaze->setC(Labyrinthe::mur,myMaze->getX(),myMaze->getY()-2);
-                    } else if(areaLatt == 2) {
-
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()-1,myMaze->getY()-1);
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX(),myMaze->getY()-1);
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()+1,myMaze->getY()-1);
-
-                        myMaze->setC(Labyrinthe::pasExplorer,myMaze->getX()-1,myMaze->getY()-2);
-                        myMaze->setC(Labyrinthe::mur,myMaze->getX(),myMaze->getY()-2);
-                        myMaze->setC(Labyrinthe::pasExplorer,myMaze->getX()+1,myMaze->getY()-2);
-                    }
-                    break;
-
-                case 2:
-                    if(areaLatt == 0) {
-                        myMaze->setC_Down(Labyrinthe::mur);
-                    } else if(areaLatt == 1) {
-                        myMaze->setC(Labyrinthe::pasExplorer,myMaze->getX()-1,myMaze->getY()-1);//mur?
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX(),myMaze->getY()-1);
-                        myMaze->setC(Labyrinthe::pasExplorer,myMaze->getX()+1,myMaze->getY()-1);//mur?
-
-                        //myMaze->setC(Labyrinthe::pasExplorer,myMaze->getX()-1,myMaze->getY()+1);//mur?
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX(),myMaze->getY()-2);
-                        //myMaze->setC(Labyrinthe::pasExplorer,myMaze->getX()+1,myMaze->getY()+1);//mur?
-                    } else if(areaLatt == 2) {
-
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()-1,myMaze->getY()-1);
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX(),myMaze->getY()-1);
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()+1,myMaze->getY()-1);
-
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()-1,myMaze->getY()-2);
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX(),myMaze->getY()-2);
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()+1,myMaze->getY()-2);
-                    }
-                    break;
+         case 1:
+            /*
+                /-M-\
+                |?V?| //vert 1
+                |.X.| //latt 0
+                |...|
+                \---/ 
+            */
+            myMaze->setC(Labyrinthe::vide,fieldX[1],fieldY[1]);
+            myMaze->setC(Labyrinthe::mur,fieldX[4],fieldY[4]);
+            fieldSet = true;
+            
+            if(areaLatt == 1)
+            {
+                 /*
+                    /?M?\
+                    |VVV| //vert 1
+                    |.X.| //latt 1
+                    |...| // objet possiblement a proximiter 
+                    \---/
+                 */
+                 myMaze->setC(Labyrinthe::vide,fieldX[0],fieldY[0]);
+                 myMaze->setC(Labyrinthe::vide,fieldX[2],fieldY[2]);
             }
             break;
-
-        case LEFT:
-            switch(areaVert) {
-                case 0:
-                    myMaze->setC_Left(Labyrinthe::mur);
-                    break;
-
-                case 1:
-                    if(areaLatt == 0) {
-                        myMaze->setC_Left(Labyrinthe::mur);
-                    } else if(areaLatt == 1) {
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()-1,myMaze->getY()-1);
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()-1,myMaze->getY());
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()-1,myMaze->getY()+1);
-
-                        myMaze->setC(Labyrinthe::mur,myMaze->getX()-2,myMaze->getY());
-                    } else if(areaLatt == 2) {
-
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()-1,myMaze->getY()-1);
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()-1,myMaze->getY());
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()-1,myMaze->getY()+1);
-
-                        myMaze->setC(Labyrinthe::pasExplorer,myMaze->getX()-2,myMaze->getY()-1);
-                        myMaze->setC(Labyrinthe::mur,myMaze->getX()-2,myMaze->getY());
-                        myMaze->setC(Labyrinthe::pasExplorer,myMaze->getX()-2,myMaze->getY()+1);
-                    }
-                    break;
-
-                case 2:
-                    if(areaLatt == 0) {
-                        myMaze->setC_Left(Labyrinthe::mur);
-                    } else if(areaLatt == 1) {
-                        myMaze->setC(Labyrinthe::pasExplorer,myMaze->getX()-1,myMaze->getY()-1);//mur?
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()-1,myMaze->getY());
-                        myMaze->setC(Labyrinthe::pasExplorer,myMaze->getX()-1,myMaze->getY()+1);//mur?
-
-                        //myMaze->setC(Labyrinthe::pasExplorer,myMaze->getX()-1,myMaze->getY()+1);//mur?
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()-2,myMaze->getY());
-                        //myMaze->setC(Labyrinthe::pasExplorer,myMaze->getX()+1,myMaze->getY()+1);//mur?
-                    } else if(areaLatt == 2) {
-
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()-1,myMaze->getY()-1);
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()-1,myMaze->getY());
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()-1,myMaze->getY()+1);
-
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()-2,myMaze->getY()+1);
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()-2,myMaze->getY());
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()-2,myMaze->getY()+1);
-                    }
-                    break;
-            }
+         case 2:
+             fieldSet = true;
+             switch(areaLatt)
+             {
+              case 0:
+               /*
+                    /?V?\
+                    |?V?| //vert 2
+                    |.X.| //latt 0
+                    |...| // objet possiblement a proximiter
+                    \---/
+                */
+                myMaze->setC(Labyrinthe::vide,fieldX[1],fieldY[1]);
+                myMaze->setC(Labyrinthe::vide,fieldX[4],fieldY[4]);
+                break; 
+              case 1:
+                /*
+                    /?V?\
+                    |VVV| //vert 2
+                    |.X.| //latt 1
+                    |...| // objet possiblement a proximiter
+                    \---/
+                */
+                for(int i = 0;i<3;i++)myMaze->setC(Labyrinthe::vide,fieldX[i],fieldY[i]);
+                myMaze->setC(Labyrinthe::vide,fieldX[4],fieldY[4]);
+                break; 
+              case 2:
+                /*
+                    /VVV\
+                    |VVV| //vert 2
+                    |.X.| //latt 2
+                    |...|
+                    \---/
+                */
+                for(int i = 0;i<6;i++)myMaze->setC( Labyrinthe::vide,fieldX[i],fieldY[i]);
+                break; 
+             }
             break;
+        }   
+    }
+    
+    if(fieldSet == false)// on a un cas impossible
+    {
+      myMaze->setC(Labyrinthe::error,fieldX[1],fieldY[1]);  
+    }
 
-        case RIGHT:
-            switch(areaVert) {
-                case 0:
-                    myMaze->setC_Right(Labyrinthe::mur);
-                    break;
+////////////////////////////////////
 
-                case 1:
-                    if(areaLatt == 0) {
-                        myMaze->setC_Right(Labyrinthe::mur);
-                    } else if(areaLatt == 1) {
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()+1,myMaze->getY()-1);
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()+1,myMaze->getY());
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()+1,myMaze->getY()+1);
-
-                        myMaze->setC(Labyrinthe::mur,myMaze->getX()+2,myMaze->getY());
-                    } else if(areaLatt == 2) {
-
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()+1,myMaze->getY()-1);
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()+1,myMaze->getY());
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()+1,myMaze->getY()+1);
-
-                        myMaze->setC(Labyrinthe::pasExplorer,myMaze->getX()+2,myMaze->getY()-1);
-                        myMaze->setC(Labyrinthe::mur,myMaze->getX()+2,myMaze->getY());
-                        myMaze->setC(Labyrinthe::pasExplorer,myMaze->getX()+2,myMaze->getY()+1);
-                    }
-                    break;
 
-                case 2:
-                    if(areaLatt == 0) {
-                        myMaze->setC_Right(Labyrinthe::mur);
-                    } else if(areaLatt == 1) {
-                        myMaze->setC(Labyrinthe::pasExplorer,myMaze->getX()+1,myMaze->getY()-1);//mur?
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()+1,myMaze->getY());
-                        myMaze->setC(Labyrinthe::pasExplorer,myMaze->getX()+1,myMaze->getY()+1);//mur?
-
-                        //myMaze->setC(Labyrinthe::pasExplorer,myMaze->getX()-1,myMaze->getY()+1);//mur?
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()+2,myMaze->getY());
-                        //myMaze->setC(Labyrinthe::pasExplorer,myMaze->getX()+1,myMaze->getY()+1);//mur?
-                    } else if(areaLatt == 2) {
-
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()+1,myMaze->getY()-1);
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()+1,myMaze->getY());
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()+1,myMaze->getY()+1);
-
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()+2,myMaze->getY()+1);
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()+2,myMaze->getY());
-                        myMaze->setC(Labyrinthe::vide,myMaze->getX()+2,myMaze->getY()+1);
-                    }
-                    break;
-            }
-            break;
-    }
+    #ifdef DEBUG_DIRECTIVE_LABYRINTH_USER_CTRL
+    mymap = myMaze->showMap();
+    for(int i=0; i<3; i++) debug(DEBUG_DIRECTIVE_LABYRINTH," [%02X] ",mymap[i+6]);
+    debug(DEBUG_DIRECTIVE_LABYRINTH,"\n\r");
+    for(int i=0; i<3; i++) debug(DEBUG_DIRECTIVE_LABYRINTH," [%02X] ",mymap[i+3]);
+    debug(DEBUG_DIRECTIVE_LABYRINTH,"\n\r");
+    for(int i=0; i<3; i++) debug(DEBUG_DIRECTIVE_LABYRINTH," [%02X] ",mymap[i]);
+    debug(DEBUG_DIRECTIVE_LABYRINTH,"\n\r");
+    
+    debug("\n\r-------------------\n\r");
+    #endif
 }
\ No newline at end of file
--- a/labyrinthe.cpp	Sun Sep 13 06:56:09 2015 +0000
+++ b/labyrinthe.cpp	Tue Sep 29 17:23:25 2015 +0000
@@ -23,27 +23,30 @@
 {
 }
 
-coordonerr Labyrinthe::getCoordoner(char &x, char &y)
+//modifie X et Y pour metre le bon formatage des coordoner et sort l'ID de la case
+//tout ca est qu'un formatage il ne garanti pas que la tuile existe
+coordonerr Labyrinthe::getCoordoner(signed char &x, signed char &y) 
 {
     coordonerr result = unset;
-    char newPosX,newPosY;
+    signed char newPosX = (signed char)x;
+    signed char newPosY = (signed char)y;
     
     #ifdef DEGUG_LABIRINTH_GET_COORDONER
     debug("\n\r----------getCoordoner------\n\r");
-    debug(" x: %i Y: %i\n\r",x,y);
+    debug(" x: %i Y: %i\n\r",(signed char)x, (signed char)newPosY);
     #endif
     
         
-    newPosX = 3*((((signed)x<0)? x-2:x)/3); // je veux le nobre de fois quil a fait un tours et donc seulment les entier
-    newPosY = 3*((((signed)y<0)? y-2:y)/3);
+    newPosX = 3*((((signed char)newPosX<0)? (signed char)newPosX-2:(signed char)newPosX)/3); // je veux le nobre de fois quil a fait un tours et donc seulment les entier
+    newPosY = 3*((((signed char)newPosY<0)? (signed char)newPosY-2:(signed char)newPosY)/3);
     
     #ifdef DEGUG_LABIRINTH_GET_COORDONER
-    debug(" newPosX: %i newPosY: %i\n\r",newPosX,newPosY);
+    debug(" newPosX: %i newPosY: %i\n\r",(signed char)newPosX,(signed char)newPosY);
     #endif
 
     
     
-    switch(x - newPosX){
+    switch((signed char)x - (signed char)newPosX){
         case 0:
             switch(y - newPosY){
                 case 0:
@@ -51,11 +54,11 @@
                     break;
                 
                 case 1:
-                    result=C2;
+                    result=C4;
                     break;
                 
                 case 2:
-                    result=C3;
+                    result=C7;
                     break;
                 }
         break;
@@ -63,7 +66,7 @@
         case 1:
             switch(y - newPosY){
                 case 0:
-                    result=C4;
+                    result=C2;
                     break;
                 
                 case 1:
@@ -71,7 +74,7 @@
                     break;
                 
                 case 2:
-                    result=C6;
+                    result=C8;
                     break;
                 }
         break;
@@ -79,11 +82,11 @@
         case 2:
             switch(y - newPosY){
                 case 0:
-                    result=C7;
+                    result=C3;
                     break;
                 
                 case 1:
-                    result=C8;
+                    result=C6;
                     break;
                 
                 case 2:
@@ -93,7 +96,7 @@
         break;       
         }
     
-    x = newPosX;
+    x = (signed char)newPosX;
     y = newPosY;
     /*result =(coordonerr)( 2 + newPosX);
 
@@ -111,10 +114,10 @@
             break;
     }*/
     #ifdef DEGUG_LABIRINTH_GET_COORDONER
-    debug(" newPosX: %i newPosY: %i\n\r",newPosX,newPosY);
+    //debug(" newPosX: %i newPosY: %i\n\r",newPosX,newPosY);
     //debug("\n\r result: X: %02d   Y:%02d",newPosX,newPosY);
     debug("\n\r result: :%02d \n\r",result);
-    debug("\n\r--------------------\n\r");
+    debug("--------------------\n\r");
     #endif
 
     return result;
@@ -122,8 +125,8 @@
 coordonerr Labyrinthe::getCoordoner(void)
 {
     coordonerr result;
-    char newPosX = m_posX;
-    char newPosY = m_posY;
+    signed char newPosX = m_posX;
+    signed char newPosY = m_posY;
     
     result = getCoordoner(newPosX,newPosY);
 
@@ -134,11 +137,14 @@
 {
     return showMap(m_posX,m_posY);
 }
-string Labyrinthe::showMap(char x, char y)
+string Labyrinthe::showMap(signed char x, signed char y)
 {
     //bool result=false;
     string theMap;
     theMap.clear();
+    #ifdef DEBUG_LABYRINTHE_SHOW_MAP
+    debug("\n\r----------showmap------\n\r");
+    #endif
     /* char newPosX = x;
      char newPosY = y;
 
@@ -171,11 +177,11 @@
         theMap.append(1,((mapDuLabyrinthe[(stringPosition)+3]>>0)& 3));
     }
     
-    #ifdef DEBUG_BOOT_GRAPHICAL_INTERFACE
-    debug("\n\r----------showmap------\n\r");
-    debug(" map size: %i \n\r",mapDuLabyrinthe.size());
+    #ifdef DEBUG_LABYRINTHE_SHOW_MAP
+    debug(" mapDuLabyrinthe size: %i \n\r",mapDuLabyrinthe.size());
     debug("  stringPosition: %i \n\r",stringPosition); 
     if(stringPosition != -1) {
+        debug(" theMap size: %i \n\r",theMap.size());
         debug("  (mapDuLabyrinthe[(stringPosition)+1]>>0): %i &3== %i  \n\r",(mapDuLabyrinthe[(stringPosition)+1]>>0),((mapDuLabyrinthe[(stringPosition)+1]>>0)& 3)); //c1
         debug("  (mapDuLabyrinthe[(stringPosition)+2]>>6): %i &3== %i  \n\r",(mapDuLabyrinthe[(stringPosition)+2]>>6),((mapDuLabyrinthe[(stringPosition)+2]>>6)& 3)); //c2
         debug("  (mapDuLabyrinthe[(stringPosition)+2]>>4): %i &3== %i  \n\r",(mapDuLabyrinthe[(stringPosition)+2]>>4),((mapDuLabyrinthe[(stringPosition)+2]>>4)& 3)); //c3
@@ -198,13 +204,16 @@
 {
     return updateMap(mapUpdated,m_posX,m_posY);
 }
-bool Labyrinthe::updateMap(string mapUpdated,char x, char y)
+bool Labyrinthe::updateMap(string mapUpdated,signed char x, signed char y)
 {
+    #ifdef DEBUG_LABYRINTHE_GRAPHICAL_INTERFACE
+    debug("\n\r----------updateMap------\n\r");
+    #endif
     bool result = true;
     int stringPosition = searchCoord(x,y);
 
     if(stringPosition == -1)
-        result= false;
+        result= false; 
     else {
         mapDuLabyrinthe[(stringPosition)+1] = ((mapDuLabyrinthe[(stringPosition)+1]) & 0xFC) | ((mapUpdated[0] &0x03)<<0); 
         mapDuLabyrinthe[(stringPosition)+2] = ((mapDuLabyrinthe[(stringPosition)+2]) & 0x3F) | ((mapUpdated[1] &0x03)<<6); 
@@ -212,24 +221,43 @@
 
         mapDuLabyrinthe[(stringPosition)+2] = ((mapDuLabyrinthe[(stringPosition)+2]) & 0xF3) | ((mapUpdated[3] &0x03)<<2);
         mapDuLabyrinthe[(stringPosition)+2] = ((mapDuLabyrinthe[(stringPosition)+2]) & 0xFC) | ((mapUpdated[4] &0x03)<<0);
-        mapDuLabyrinthe[(stringPosition)+2] = ((mapDuLabyrinthe[(stringPosition)+3]) & 0x3F) | ((mapUpdated[5] &0x03)<<6);
+        mapDuLabyrinthe[(stringPosition)+3] = ((mapDuLabyrinthe[(stringPosition)+3]) & 0x3F) | ((mapUpdated[5] &0x03)<<6);
 
-        mapDuLabyrinthe[(stringPosition)+2] = ((mapDuLabyrinthe[(stringPosition)+2]) & 0xCF) | ((mapUpdated[6] &0x03)<<4);
-        mapDuLabyrinthe[(stringPosition)+2] = ((mapDuLabyrinthe[(stringPosition)+2]) & 0xF3) | ((mapUpdated[7] &0x03)<<2);
-        mapDuLabyrinthe[(stringPosition)+2] = ((mapDuLabyrinthe[(stringPosition)+2]) & 0xFC) | ((mapUpdated[8] &0x03)<<0);
+        mapDuLabyrinthe[(stringPosition)+3] = ((mapDuLabyrinthe[(stringPosition)+3]) & 0xCF) | ((mapUpdated[6] &0x03)<<4);
+        mapDuLabyrinthe[(stringPosition)+3] = ((mapDuLabyrinthe[(stringPosition)+3]) & 0xF3) | ((mapUpdated[7] &0x03)<<2);
+        mapDuLabyrinthe[(stringPosition)+3] = ((mapDuLabyrinthe[(stringPosition)+3]) & 0xFC) | ((mapUpdated[8] &0x03)<<0);
     }
-
+    
+     #ifdef DEBUG_LABYRINTHE_GRAPHICAL_INTERFACE
+    debug(" result: %i \n\r",result?1:0);
+    debug("  stringPosition: %i \n\r",stringPosition); 
+    if(stringPosition != -1) {
+        debug("  (mapDuLabyrinthe[(stringPosition)+1]>>0): %i &3== %i  \n\r",(mapDuLabyrinthe[(stringPosition)+1]>>0),((mapDuLabyrinthe[(stringPosition)+1]>>0)& 3)); //c1
+        debug("  (mapDuLabyrinthe[(stringPosition)+2]>>6): %i &3== %i  \n\r",(mapDuLabyrinthe[(stringPosition)+2]>>6),((mapDuLabyrinthe[(stringPosition)+2]>>6)& 3)); //c2
+        debug("  (mapDuLabyrinthe[(stringPosition)+2]>>4): %i &3== %i  \n\r",(mapDuLabyrinthe[(stringPosition)+2]>>4),((mapDuLabyrinthe[(stringPosition)+2]>>4)& 3)); //c3
+        debug("  \n\r");
+        debug("  (mapDuLabyrinthe[(stringPosition)+2]>>2): %i &3== %i  \n\r",(mapDuLabyrinthe[(stringPosition)+2]>>2),((mapDuLabyrinthe[(stringPosition)+2]>>2)& 3)); //c4
+        debug("  (mapDuLabyrinthe[(stringPosition)+2]>>0): %i &3== %i  \n\r",(mapDuLabyrinthe[(stringPosition)+2]>>0),((mapDuLabyrinthe[(stringPosition)+2]>>0)& 3)); //c5
+        debug("  (mapDuLabyrinthe[(stringPosition)+3]>>6): %i &3== %i  \n\r",(mapDuLabyrinthe[(stringPosition)+3]>>6),((mapDuLabyrinthe[(stringPosition)+3]>>6)& 3)); //c6
+        debug("  \n\r");
+        debug("  (mapDuLabyrinthe[(stringPosition)+3]>>4): %i &3== %i  \n\r",(mapDuLabyrinthe[(stringPosition)+3]>>4),((mapDuLabyrinthe[(stringPosition)+3]>>4)& 3)); //c7
+        debug("  (mapDuLabyrinthe[(stringPosition)+3]>>2): %i &3== %i  \n\r",(mapDuLabyrinthe[(stringPosition)+3]>>2),((mapDuLabyrinthe[(stringPosition)+3]>>2)& 3)); //c8
+        debug("  (mapDuLabyrinthe[(stringPosition)+3]>>0): %i &3== %i  \n\r",(mapDuLabyrinthe[(stringPosition)+3]>>0),((mapDuLabyrinthe[(stringPosition)+3]>>0)& 3)); //c9
+        debug("  \n\r");
+    }
+    debug("\n\r----------------------\n\r");
+    #endif
 
     return result;
 }
-bool Labyrinthe::addMap(char x, char y)
+bool Labyrinthe::addMap(signed char x, signed char y)
 {
     bool result = true;
     x &= 0x7F; // on coupe le 8eme bit
     y &= 0x7F; //
 
     mapDuLabyrinthe.append(1,((x<<1) | (y>>6)) );//x7,x6,x5,x4,x3,x2,x1,y7
-    mapDuLabyrinthe.append(1,y<<1);              //y6,y5,y4,y3,y2,y1,[C1],[C1]
+    mapDuLabyrinthe.append(1,y<<2);              //y6,y5,y4,y3,y2,y1,[C1],[C1]
     mapDuLabyrinthe.append(2,0);                 //add C2-C9 vide
     
     #ifdef DEBUG_LABYRINTHE_ADD_MAP
@@ -237,6 +265,7 @@
     debug("x = %i \n\r",x);
     debug("y = %i \n\r",y);
     debug("((x<<1) | (y>>6)) = %i \n\r",((x<<1) | (y>>6)));
+    
     debug("-------------\n\r");
     #endif
 
@@ -244,17 +273,19 @@
 }
 
 //renvoi l'ID du 4 byte de la tuile dans le string
-int Labyrinthe::searchCoord(char posX,char posY)
+// renvoi -1 en cas d'erreur
+int Labyrinthe::searchCoord(signed char posX,signed char posY)
 {
     bool result=false;
-    char newPosX = posX;
-    char newPosY = posY;
-    unsigned char templateX = 0;
-    unsigned char templateY = 0;
+    signed char newPosX = posX;
+    signed char newPosY = posY;
+    signed char templateX = 0;
+    signed char templateY = 0;
     int i=0;
+    
     //string theMap;
     //theMap.clear();
-    debug(DEBUGLABSEARCHCOORD,"------Search coord------");
+    debug(DEBUGLABSEARCHCOORD,"------Search coord------\n\r");
     debug(DEBUGLABSEARCHCOORD," posX: %i posY: %i \n\r",posX,posY);
     
     
@@ -266,9 +297,15 @@
     for( ; ((i*DEFAULTLABLEIGHT) < mapDuLabyrinthe.size()) && (!result); i++) {
        
         templateX = (mapDuLabyrinthe[(i*DEFAULTLABLEIGHT)])>>1;
-        templateY = (((mapDuLabyrinthe[(i*DEFAULTLABLEIGHT)])&1)<<7) | ((mapDuLabyrinthe[(i*DEFAULTLABLEIGHT)+1])>>2);
+        templateY = (((mapDuLabyrinthe[(i*DEFAULTLABLEIGHT)])&1)<<6) + ((mapDuLabyrinthe[(i*DEFAULTLABLEIGHT)+1])>>2);
+        
+        //patch pour les nombre negatif vue que originelment on est sur un 7 bit
+        if(templateX & 0x40) templateX |= 0x80;
+        if(templateY & 0x40) templateY |= 0x80;
+        
         //templateY += ((mapDuLabyrinthe[(i*DEFAULTLABLEIGHT)+1])>>2);
-
+        debug(DEBUGLABSEARCHCOORD," mapDuLabyrinthe par1: %i mapDuLabyrinthe part2: %i \n\r",mapDuLabyrinthe[(i*DEFAULTLABLEIGHT)],mapDuLabyrinthe[(i*DEFAULTLABLEIGHT)+1]);
+        debug(DEBUGLABSEARCHCOORD," templateX: %i templateY: %i \n\r",templateX,templateY);
         if((templateX == newPosX) && (templateY == newPosY)) {
             result=true;
             //theMap.append(1,((mapDuLabyrinthe[(i*DEFAULTLABLEIGHT)+1])& 3));
@@ -279,7 +316,7 @@
     debug(DEBUGLABSEARCHCOORD," templateY: %i \n\r",templateY);
     debug(DEBUGLABSEARCHCOORD," result: %i \n\r",result?1:0);
     debug(DEBUGLABSEARCHCOORD," i*DEFAULTLABLEIGHT: %i \n\r",i*DEFAULTLABLEIGHT); 
-    debug(DEBUGLABSEARCHCOORD,"--------------------");
+    debug(DEBUGLABSEARCHCOORD,"--------------------\n\r");
     return (result==false? -1:i*DEFAULTLABLEIGHT);
 }
 
@@ -292,65 +329,76 @@
 * @param y position Y.
 * @return 
 */
-case_t Labyrinthe::getC(char x, char y)
+case_t Labyrinthe::getC(signed char x, signed char y)
 {
-    char newPosX = x;
-    char newPosY = y;
+    signed char newPosX = x;
+    signed char newPosY = y;
     coordonerr maCoordoner;
     maCoordoner=getCoordoner(newPosX,newPosY);
     
  return  getC(x, y, maCoordoner);
 }
 
-case_t Labyrinthe::getC(char x, char y, coordonerr cX)
+case_t Labyrinthe::getC(signed char x, signed char y, coordonerr cX)
 {
-    char myCoordoner = 0xFF;
-    string result = showMap(x,y);
-    if(result.size() != 0) {
-        myCoordoner= result[cX];
-    }
-    return (case_t)myCoordoner;
-}
-void Labyrinthe::setC(case_t value, char x, char y, coordonerr cX)
-{
-    #ifdef DEGUG_LABIRINTH_SET_COORDONER
-        debug("------SetC coord------");
-        #endif
+    case_t myCoordoner = error;
     string result = showMap(x,y);
     if(result.size() != 0) {
-        result[cX-1]=value;
-        
-        
-        #ifdef DEGUG_LABIRINTH_SET_COORDONER
-        debug("\n\r  Labyrinthe map: X:%02x Y:%02x \n\r",x,y);
-        debug("value: %i\n\r",value);
+        myCoordoner = case_t(result[cX]);
+    }
+    return myCoordoner;
+}
+void Labyrinthe::setC(case_t value, signed char x, signed char y, coordonerr cX)
+{
+    #ifdef DEGUG_LABIRINTH_SET_COORDONER
+        debug("------SetC coord------\n\r");
+        debug(" value: %i\n\r",value);
         debug("coordoner: %i\n\r",cX);
-        for(int i=0; i<3; i++) debug(" [%02X] ",result[i+6]);
-        debug("\n\r");
-        for(int i=0; i<3; i++) debug(" [%02X] ",result[i+3]);
-        debug("\n\r");
-        for(int i=0; i<3; i++) debug(" [%02X] ",result[i]);
-        debug("\n\r");
+        debug("  X:%i Y:%i \n\r",x,y);
+        #endif
+    
+    if(value != error){
+        string result = showMap(x,y);
+        
+        if(result.size() == 0) {//no map found so we create new tuile
+        #ifdef DEGUG_LABIRINTH_SET_COORDONER
+        debug(" no tuile found\n\r");
         #endif
+            signed char newPosX = x;
+            signed char newPosY = y;   
+            
+            getCoordoner(newPosX,newPosY);
+            addMap(newPosX,newPosY);
+            result = showMap(x,y);
+            #ifdef DEGUG_LABIRINTH_SET_COORDONER
+            debug(" result: %i\n\r",result.size());
+            #endif
+        }
         
-    updateMap(result,x,y);
-        
+        if(result.size() != 0){   
         #ifdef DEGUG_LABIRINTH_SET_COORDONER
-        debug("---------------------");
+        debug(" tuile found\n\r");
         #endif
+        result[cX-1]=value;
+        updateMap(result,x,y);//on remet les case modifier dans le string==map
+        }
     }
+        
+     #ifdef DEGUG_LABIRINTH_SET_COORDONER
+        debug("---------------------\n\r");
+        #endif
 }
 void Labyrinthe::setC(case_t value, coordonerr cX)
 {
     setC(value,m_posX, m_posY,cX);
 }
-void Labyrinthe::setC(case_t value, char x, char y)
+void Labyrinthe::setC(case_t value, signed char x, signed char y)
 {
-    char newPosX = x;
-    char newPosY = y;
+    signed char newPosX = x;
+    signed char newPosY = y;
     coordonerr maCoordoner;
     maCoordoner=getCoordoner(newPosX,newPosY);
-    
+    debug("-setcase tempo newPosX: %i, x: %i\n\r",newPosX,x);
     setC(value,x,y,maCoordoner);
 }
 void Labyrinthe::setC_Up(case_t value)
--- a/labyrinthe.h	Sun Sep 13 06:56:09 2015 +0000
+++ b/labyrinthe.h	Tue Sep 29 17:23:25 2015 +0000
@@ -10,7 +10,7 @@
   
 #define DEFAULTLABLEIGHT 4
 #define DEBUGLABCOORD 0
-#define DEBUGLABSEARCHCOORD 1
+#define DEBUGLABSEARCHCOORD 0
 
 #include "mbed.h"
 #include "debug.h"
@@ -23,10 +23,10 @@
 #define RIGHT 4
 
 
-#define VIDE 3
+/*#define VIDE 3
 #define EXPLORER 1
 #define MUR 2
-#define PAS_EXPLORER 0
+#define PAS_EXPLORER 0*/
 
 // 1 tuile == 4 byte
 
@@ -34,11 +34,11 @@
     
 class Labyrinthe
 {
-char m_posX,m_posY;
+signed char m_posX,m_posY;
 char direction;
 string mapDuLabyrinthe;
 
-int searchCoord(char posX,char posY);
+
 
 public:
 enum coordoner_t{
@@ -58,6 +58,7 @@
     };
     
     enum case_t{
+        error       =-1,
         pasExplorer = 0,
         explorer    = 1,
         mur         = 2,
@@ -70,26 +71,25 @@
 char getDirection(){return direction;}
 void setDirection(char dir){direction= dir;}
 
-char getX(void){return m_posX;}
-void setX(char x){m_posX = x;}
+signed char getX(void){return m_posX;}
+void setX(signed char x){m_posX = x;}
 
-char getY(void){return m_posY;}
-void getY(char y){m_posY = y;}
+signed char getY(void){return m_posY;}
+void getY(signed char y){m_posY = y;}
 
 void goUp(void){m_posY++;}
 void goDown(void){m_posY--;}
 void goLeft(void){m_posX--;}
-void posRight(void){m_posX++;}
+void goRight(void){m_posX++;}
 
-coordoner_t getCoordoner(char &x, char &y);
-coordoner_t getCoordoner(void);
+
 
 case_t getC(coordoner_t cX);
-case_t getC(char x, char y, coordoner_t cX);
-case_t getC(char x, char y);
-void setC(case_t value, char x, char y, coordoner_t cX);
+case_t getC(signed char x, signed char y, coordoner_t cX);
+case_t getC(signed char x, signed char y);
+void setC(case_t value, signed char x, signed char y, coordoner_t cX);
 void setC(case_t value, coordoner_t cX);
-void setC(case_t value, char x, char y);
+void setC(case_t value, signed char x, signed char y);
 
 void setC_Up(case_t value);
 void setC_Down(case_t value);
@@ -109,12 +109,20 @@
        * @param y position Y.
        * @return The formated map 3x3 result
        */
-        string showMap(char x, char y);
+        string showMap(signed char x, signed char y);
+
+
+
 
-bool updateMap(string mapUpdated);
-bool updateMap(string mapUpdated,char x, char y);
-bool addMap(char x, char y);
+    private:
+    int searchCoord(signed char posX,signed char posY);
 
+    coordoner_t getCoordoner(signed char &x, signed char &y);
+    coordoner_t getCoordoner(void);
+    
+    bool updateMap(string mapUpdated);
+    bool updateMap(string mapUpdated,signed char x, signed char y);
+    bool addMap(signed char x, signed char y);
 
 };
 #endif //LABYRINTHE_H//
\ No newline at end of file
--- a/main.cpp	Sun Sep 13 06:56:09 2015 +0000
+++ b/main.cpp	Tue Sep 29 17:23:25 2015 +0000
@@ -75,7 +75,7 @@
         #ifdef DBG_MAIN_INIT
         debug("\n\rInit taskGeneral ...");
         #endif
-            TTaskGeneral taskGeneral(20);
+            TTaskGeneral taskGeneral(2/*0*/);
         #ifdef DBG_MAIN_INIT 
         debug(" end taskGeneral");
         #endif
@@ -123,6 +123,7 @@
             #endif
             
             #ifdef DBG_MAIN_DELAY_SEC
+            debug("\n\r\n TICK \n\r\n");
             wait(DBG_MAIN_DELAY_SEC);
             #endif          
         #endif
--- a/mbed.bld	Sun Sep 13 06:56:09 2015 +0000
+++ b/mbed.bld	Tue Sep 29 17:23:25 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/b9ad9a133dc7
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/ba1f97679dad
\ No newline at end of file
--- a/settingDebug.h	Sun Sep 13 06:56:09 2015 +0000
+++ b/settingDebug.h	Tue Sep 29 17:23:25 2015 +0000
@@ -8,9 +8,10 @@
 
 #define DBG_MAIN_INIT //enable to make sure all task is created
     #define DEBUG_INIT_TASKCRITT 1
-    #define DBG_MAIN_DELAY_SEC 2 
+    #define DBG_MAIN_DELAY_SEC 1 
 #define DEBUG_BOOT_GRAPHICAL_INTERFACE // enable ANSI interface to view all process 
 #define DEBUG_DIRECTIVE_GRAPHICAL_INTERFACE // enable ANSI interface to view directive process 
+//#define DEBUG_LABYRINTHE_GRAPHICAL_INTERFACE
 
 //#define DBG_MAIN_FLAG //Show Flag trought each process
 
@@ -19,8 +20,12 @@
     
 #define DEBUG_MOUVEMENT_COMM_OFF    //disable comm with ssc-32
 
+#define DEBUG_DIRECTIVE_LEG_DISABLE //skip all linked whit the control of leg
+#define DEBUG_DIRECTIVE_LABYRINTH_USER_CTRL // chose manualy what robot see
 //#define DEBUG_LABYRINTHE_ADD_MAP //show process "addmap(char x, char y)"
 
-#define DEGUG_LABIRINTH_GET_COORDONER
-#define DEGUG_LABIRINTH_SET_COORDONER
+//#define DEGUG_LABIRINTH_GET_COORDONER
+//#define DEGUG_LABIRINTH_SET_COORDONER
+//#define DEBUG_LABYRINTHE_ADD_MAP
+//#define DEBUG_LABYRINTHE_SHOW_MAP
 #endif
\ No newline at end of file
--- a/source/Task/TTaskGeneral.h	Sun Sep 13 06:56:09 2015 +0000
+++ b/source/Task/TTaskGeneral.h	Tue Sep 29 17:23:25 2015 +0000
@@ -3,7 +3,7 @@
   * @brief      Cette classe controle tout ce qui ce relie au Flag Critique et a la gestion prioritaire.
   * @author     Salco
   * @version    2.00
-  * @date       11 mars 2015
+  * @date       11 june 2015
   */
 #ifndef TTASKGENERAL_H
 #define TTASKGENERAL_H