code de la carte IHM avant les bugs et avant le travail effectué avec Melchior

Dependencies:   mbed SerialHalfDuplex SDFileSystem liaison_Bluetooth ident_crac DISCO-F469NI_portrait

IHM/ihm.cpp

Committer:
maximilienlv
Date:
2020-07-17
Revision:
28:7f2990747e09
Parent:
27:ff70537a7619
Child:
29:ff575aff301f

File content as of revision 28:7f2990747e09:

#include "global.h"

#define VERT 0xFF00FF00
#define ROUGE 0xFFFF0000
#define BLEU 0xFF0000FF
#define JAUNE 0xFFFDD835//FEFE00
#define BLANC 0xFF000000
#define ORANGE 0xFFFFA500
#define NOIR 0xFF000000
#define DIY_GREY 0xFFDFDFDF
#define VIOLET 0xFF4527A0
#define VERT_F 0xFF00C400
TS_DISCO_F469NI ts;
LCD_DISCO_F469NI lcd;


TS_StateTypeDef TS_State;


/////////////////DEFINITION DES BOUTONS////////////////////
Button COTE_JAUNE(0, 25, 400, 300, "JAUNE");
Button COTE_VIOLET(0, 350, 400, 300, "VIOLET");
Button RETOUR  (0, 680, 400, 110, "--Precedent--");
Button LANCER  (0, 200, 400, 200, "--LANCER--");
Button CHECK (0, 420, 400, 200, "Valider");
Button MATCH (0, 50, 400, 320, "Match");
Button DEMONSTRATION (0, 400, 400, 320, "Demo");
//menu demo
Button TEST_VENT(0, 25, 400, 100, "Test ventouses");
Button TEST_MOT(0, 135, 400, 100, "Test moteur");
Button TEST_COUL(0,245,400,100,"Test capteurs couleur");
Button TEST_BRAS(0,355,400,100,"Test Bras");
Button TEST_AUDIO(0,465,400,100,"Test Audio");

Button TEST_NEXT(0,575,400,100,"------>");
Button TEST_DIV(0,25,400,100,"Test Divers");
Button TEST_ASSERV(0, 135, 400, 100, "Test asserv");
//menu demo/demo/
Button TEST_A(0,25,195,100,"A");
Button TEST_B(205,25,195,100,"B");
Button TEST_C(0,135,195,100,"C");
Button TEST_D(205,135,195,100,"D");
Button TEST_NUM(0,245,400,100,"Num");
Button TEST_PLUS(205,355,195,100,"+");
Button TEST_MOINS(0,355,195,100,"-");
Button FORCE_LAUNCH(0, 600, 400, 100, "Force Launch");
Button SUIVANT(0,380,200,100,"Suivant");
////////////////////////////////////////////////////////////

signed char Bouton_Strat (void);
void DrawC (int l,int h,int x, int y, unsigned char fill);
void DrawR (int l,int h,int x, int y, unsigned char fill);
void DrawA (int l,int h,int x, int y, unsigned char fill);

void SelectionStrat (unsigned char numeroStrat);

/****************************************************************************************/
/* FUNCTION NAME: automate_etat_ihm                                                     */
/* DESCRIPTION  : Automate de gestion de l'affichage                                    */
/****************************************************************************************/
void automate_etat_ihm(void)
{
    char toto[2]; 
    int j;
    unsigned char maximilien=1;
    if (j==0) {
        ts.Init(lcd.GetXSize(), lcd.GetYSize());
        j++;
    }
    ts.GetState(&TS_State);
    switch (strat_etat_s) {
        case INIT : //intialise l'écran et passe à l'attente d'initialisation des cartes
            ts.GetState(&TS_State);
            canProcessRx();
            lcd.SetBackColor(LCD_COLOR_WHITE);
            lcd.SetTextColor(LCD_COLOR_BLACK);
            lcd.Clear (LCD_COLOR_WHITE);
            wait(0.15);
            DrawC(95,150,0,50,0);
            DrawR(95,150,105,50,0);
            DrawA(95,150,210,50,0);
            DrawC(95,150,315,50,0);
            DrawCheck(30,30,50,243,0);
            DrawCheck(30,30,50,293,0);
            DrawCheck(30,30,50,343,0);
            DrawCheck(30,30,50,393,0);
            lcd.DisplayStringAt(100, 250, (uint8_t *)"Init CAN", LEFT_MODE);
            lcd.DisplayStringAt(100, 300, (uint8_t *)"Micro SD", LEFT_MODE);
            lcd.DisplayStringAt(100, 350, (uint8_t *)"Carte Moteur", LEFT_MODE);
            lcd.DisplayStringAt(100, 400, (uint8_t *)"Balise IR", LEFT_MODE);
            FORCE_LAUNCH.Draw(0xFFFF0000, 0);

            strat_etat_s=ATT;
            break;

        case ATT :  //Si les cartes sont présentes passe directement à choix sinon attente de force Launch (cette partie est encore buggée mais les cartes affichent bien leur présence donc faut juste force launch tout le temps...)
            if (flag_check_carte==1) {
                strat_etat_s = CHOIX;
                gameEtat = ETAT_CONFIG;
            } else if (FORCE_LAUNCH.Touched()) {
                strat_etat_s = CHOIX;
                gameEtat = ETAT_CONFIG;
                while(FORCE_LAUNCH.Touched());
            }

            break;


        case CHOIX :    //Match ou DEMO
            lcd.SetBackColor(LCD_COLOR_WHITE);
            lcd.SetTextColor(LCD_COLOR_BLACK);
            lcd.Clear (LCD_COLOR_WHITE);
            lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Match ou demonstration ?", LEFT_MODE);
            DEMONSTRATION.Draw(LCD_COLOR_LIGHTGREEN, 0);
            MATCH.Draw(0xFFF01010, 0);
            while(strat_etat_s == CHOIX) {
                canProcessRx();
                if(DEMONSTRATION.Touched()) {
                    strat_etat_s = DEMO;
                    while(DEMONSTRATION.Touched());
                }

                if(MATCH.Touched()) {
                    strat_etat_s = SELECT_SIDE;
                    while(MATCH.Touched());
                }

            }
            break;

        case DEMO :
            lcd.SetBackColor(LCD_COLOR_WHITE);
            lcd.SetTextColor(LCD_COLOR_BLACK);
            lcd.Clear (LCD_COLOR_WHITE);
            lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"DEMO 1/2", LEFT_MODE);
            RETOUR.Draw(0xFFFF0000, 0);
            TEST_VENT.Draw(VERT, 0);
            TEST_MOT.Draw(VERT, 0);
            TEST_COUL.Draw(VERT, 0);
            TEST_BRAS.Draw(VERT, 0);
            TEST_AUDIO.Draw(VERT, 0);
            TEST_NEXT.Draw(BLEU, 0);
            maximilien=0;
            while (strat_etat_s == DEMO) {
                canProcessRx();
                if(TEST_VENT.Touched()) {
                    while(TEST_VENT.Touched());
                    strat_etat_s = TEST_VENTOUSE;
                } else if(TEST_MOT.Touched()) {
                    while(TEST_MOT.Touched());
                    strat_etat_s = TEST_MOTEUR;
                } else if(TEST_NEXT.Touched()) {
                    while(TEST_NEXT.Touched());
                    strat_etat_s = DEMO2;
                } else if (TEST_COUL.Touched()) {
                    while(TEST_COUL.Touched());
                    strat_etat_s =TEST_COULEUR ;
                } else if (TEST_BRAS.Touched()) {
                    while(TEST_BRAS.Touched());
                    strat_etat_s =TEST_SERVO_BRAS ;
                } else if(TEST_AUDIO.Touched()) {
                    while(TEST_AUDIO.Touched());
                    strat_etat_s=TEST_AUD;
                } else if(RETOUR.Touched()) {
                    while(RETOUR.Touched());
                    strat_etat_s = CHOIX;
                }
            }
            break;
        
        case DEMO2 :
            lcd.SetBackColor(LCD_COLOR_WHITE);
            lcd.SetTextColor(LCD_COLOR_BLACK);
            lcd.Clear (LCD_COLOR_WHITE);
            lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"DEMO 2/2", LEFT_MODE);
            RETOUR.Draw(0xFFFF0000, 0);
            TEST_DIV.Draw(VERT, 0);
            TEST_ASSERV.Draw(VERT, 0);
            TEST_NEXT.Draw(BLEU, 0);
            maximilien=0;
            while (strat_etat_s == DEMO2) {
                canProcessRx();
                if(TEST_NEXT.Touched()) {
                    while(TEST_NEXT.Touched());
                    strat_etat_s = DEMO;
                } else if(TEST_DIV.Touched()) {
                    while(TEST_DIV.Touched());
                    strat_etat_s = TEST_DIVE;
                } else if(TEST_ASSERV.Touched()) {
                    while(TEST_ASSERV.Touched());
                    strat_etat_s = TEST_ASSERVE;
                } else if(RETOUR.Touched()) {
                    while(RETOUR.Touched());
                    strat_etat_s = CHOIX;
                }
            }
        break;
        
        case TEST_ASSERVE:
            lcd.SetBackColor(LCD_COLOR_WHITE);
            lcd.SetTextColor(LCD_COLOR_BLACK);
            lcd.Clear (LCD_COLOR_WHITE);
            lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Asservissements", LEFT_MODE);
            RETOUR.Draw(0xFFFF0000,0);
            TEST_A.Draw(BLEU, BLANC);
            TEST_B.Draw(BLEU, BLANC);
            while(strat_etat_s==TEST_ASSERVE) {
                if(RETOUR.Touched()) {
                    while (RETOUR.Touched());
                    strat_etat_s=DEMO2;
                } else if(TEST_A.Touched()) {
                    while (TEST_A.Touched());
                    GoToPosition(2000,0,0,0);
                    TEST_A.Draw(BLEU, BLANC);  
                }  else if(TEST_B.Touched()) {
                    while (TEST_B.Touched());
                    Rotate(3599);
                    TEST_B.Draw(BLEU, BLANC);
                }  
            }
        break; 

        case TEST_DIVE:
            
            while(strat_etat_s==TEST_DIVE) {
                canProcessRx();
                lcd.SetBackColor(LCD_COLOR_WHITE);
                lcd.SetTextColor(LCD_COLOR_BLACK);
                lcd.Clear (LCD_COLOR_WHITE);
                lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Coordonnees", LEFT_MODE);
                RETOUR.Draw(0xFFFF0000,0);
                sprintf(toto,"%hd",x_robot);
                lcd.DisplayStringAt(0, LINE(10), (unsigned char *)"X :", LEFT_MODE);
                lcd.DisplayStringAt(50, LINE(10), (unsigned char *)toto, LEFT_MODE);
                sprintf(toto,"%hd",y_robot);
                lcd.DisplayStringAt(0, LINE(11), (unsigned char *)"Y :", LEFT_MODE);
                lcd.DisplayStringAt(50, LINE(11), (unsigned char *)toto, LEFT_MODE);
                sprintf(toto,"%hd",theta_robot);
                lcd.DisplayStringAt(0, LINE(12), (unsigned char *)"T :", LEFT_MODE);
                lcd.DisplayStringAt(50, LINE(12), (unsigned char *) toto, LEFT_MODE);
                if(RETOUR.Touched()) {
                    while (RETOUR.Touched());
                    strat_etat_s=DEMO2;
                } 
                wait(0.2);
            }
        break;

        case TEST_VENTOUSE:   
            lcd.SetBackColor(LCD_COLOR_WHITE);
            lcd.SetTextColor(LCD_COLOR_BLACK);
            lcd.Clear (LCD_COLOR_WHITE);   
            lcd.Clear (LCD_COLOR_WHITE);
            lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Test Ventouse", LEFT_MODE);
            sprintf(toto,"%hd",maximilien);
            lcd.DisplayStringAt(50, LINE(20), (unsigned char *)toto, LEFT_MODE);
            RETOUR.Draw(0xFFFF0000,0);
            TEST_A.Draw(BLEU, BLANC);
            TEST_NUM.Draw(BLEU, BLANC);
            TEST_PLUS.Draw(BLEU, BLANC);
            TEST_MOINS.Draw(BLEU, BLANC);
            while(strat_etat_s==TEST_VENTOUSE) {
                if(RETOUR.Touched()) {
                    while (RETOUR.Touched());
                    strat_etat_s=DEMO;
                } else if(TEST_A.Touched()) {
                    while (TEST_A.Touched());
                    SendRawId(VENT_ETAT);
                    TEST_A.Draw(BLEU, BLANC);
                }  else if(TEST_NUM.Touched()) {
                    while (TEST_NUM.Touched());
                    TEST_NUM.Draw(BLEU, BLANC);
                    switch(maximilien){
                    case 1:
                    SendRawId(TEST_VENT_1_ON);
                    break;
                    case 2:
                    SendRawId(TEST_VENT_1_OFF);
                    break;
                    case 3:
                    //SendRawId(TEST_VENT_3);
                    break;
                    case 4:
                    //SendRawId(TEST_VENT_4);
                    break;
                    case 5:
                    //SendRawId(TEST_VENT_5);
                    break;
                    case 6:
                    //SendRawId(TEST_VENT_6);
                    break;
                    }
                } else if(TEST_PLUS.Touched()) {
                    while (TEST_PLUS.Touched());
                    TEST_PLUS.Draw(BLEU, BLANC);
                    if(maximilien!=6)maximilien++;
                    sprintf(toto,"%hd",maximilien);
                    lcd.SetBackColor(LCD_COLOR_WHITE);
                    lcd.SetTextColor(LCD_COLOR_BLACK);
                    lcd.DisplayStringAt(50, LINE(20), (unsigned char *)toto, LEFT_MODE);
                } else if(TEST_MOINS.Touched()) {
                    while (TEST_MOINS.Touched());
                    TEST_MOINS.Draw(BLEU, BLANC);
                    if(maximilien!=1)maximilien--;
                    sprintf(toto,"%hd",maximilien);
                    lcd.SetBackColor(LCD_COLOR_WHITE);
                    lcd.SetTextColor(LCD_COLOR_BLACK);
                    lcd.DisplayStringAt(50, LINE(20), (unsigned char *)toto, LEFT_MODE);
                }
            }
            break;
        
        case TEST_ELECTROV:
            lcd.SetBackColor(LCD_COLOR_WHITE);
            lcd.SetTextColor(LCD_COLOR_BLACK);
            lcd.Clear (LCD_COLOR_WHITE);   
            lcd.Clear (LCD_COLOR_WHITE);
            lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"A : Manches B : Pavillon", LEFT_MODE);
            RETOUR.Draw(0xFFFF0000,0);
            TEST_A.Draw(BLEU, BLANC);
            TEST_B.Draw(BLEU, BLANC);
            while(strat_etat_s==TEST_ELECTROV) {
                if(RETOUR.Touched()) {
                    while (RETOUR.Touched());
                    strat_etat_s=DEMO;
                } else if(TEST_A.Touched()) {
                    while (TEST_A.Touched());
                    //SendRawId(TEST_ELECTROV_A);
                    TEST_A.Draw(BLEU, BLANC);
                }  else if(TEST_B.Touched()) {
                    while (TEST_B.Touched());
                    //SendRawId(TEST_ELECTROV_A);
                    TEST_B.Draw(BLEU, BLANC);
                }  
            }
            break;
            
        case TEST_AUD:  
              
            lcd.SetBackColor(LCD_COLOR_WHITE);
            lcd.SetTextColor(LCD_COLOR_BLACK);
            lcd.Clear (LCD_COLOR_WHITE);   
            lcd.Clear (LCD_COLOR_WHITE);
            lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Test Audio", LEFT_MODE);
            sprintf(toto,"%hd",maximilien);
            lcd.DisplayStringAt(50, LINE(20), (unsigned char *)toto, LEFT_MODE);
            RETOUR.Draw(0xFFFF0000,0);
            TEST_NUM.Draw(BLEU, BLANC);
            TEST_PLUS.Draw(BLEU, BLANC);
            TEST_MOINS.Draw(BLEU, BLANC);
            while(strat_etat_s==TEST_AUD) {
                if(RETOUR.Touched()) {
                    while (RETOUR.Touched());
                    strat_etat_s=DEMO;
                }  else if(TEST_NUM.Touched()) {
                    while (TEST_NUM.Touched());
                    TEST_NUM.Draw(BLEU, BLANC);
                    Debug_Audio(3,maximilien);
                } else if(TEST_PLUS.Touched()) {
                    while (TEST_PLUS.Touched());
                    TEST_PLUS.Draw(BLEU, BLANC);
                    if(maximilien!=20)maximilien++;
                    sprintf(toto,"%hd",maximilien);
                    lcd.SetBackColor(LCD_COLOR_WHITE);
                    lcd.SetTextColor(LCD_COLOR_BLACK);
                    lcd.DisplayStringAt(50, LINE(20), (unsigned char *)toto, LEFT_MODE);
                } else if(TEST_MOINS.Touched()) {
                    while (TEST_MOINS.Touched());
                    TEST_MOINS.Draw(BLEU, BLANC);
                    if(maximilien!=1)maximilien--;
                    sprintf(toto,"%hd",maximilien);
                    lcd.SetBackColor(LCD_COLOR_WHITE);
                    lcd.SetTextColor(LCD_COLOR_BLACK);
                    lcd.DisplayStringAt(50, LINE(20), (unsigned char *)toto, LEFT_MODE);
                }
            }
            break;
            
        case TEST_SERVO_BRAS:  
              
            lcd.SetBackColor(LCD_COLOR_WHITE);
            lcd.SetTextColor(LCD_COLOR_BLACK);
            lcd.Clear (LCD_COLOR_WHITE);   
            lcd.Clear (LCD_COLOR_WHITE);
            lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Test Bras", LEFT_MODE);
            sprintf(toto,"%hd",maximilien);
            lcd.DisplayStringAt(50, LINE(20), (unsigned char *)toto, LEFT_MODE);
            RETOUR.Draw(0xFFFF0000,0);
            TEST_A.Draw(BLEU, BLANC);
            TEST_B.Draw(BLEU, BLANC);
            TEST_C.Draw(BLEU, BLANC);
            TEST_D.Draw(BLEU, BLANC);
            TEST_NUM.Draw(BLEU, BLANC);
            TEST_PLUS.Draw(BLEU, BLANC);
            TEST_MOINS.Draw(BLEU, BLANC);
            while(strat_etat_s==TEST_SERVO_BRAS) {
                if(RETOUR.Touched()) {
                    while (RETOUR.Touched());
                    strat_etat_s=DEMO;
                } else if(TEST_A.Touched()) {
                    while (TEST_A.Touched());
                    SendRawId(TEST_BRAS_A);
                    TEST_A.Draw(BLEU, BLANC);
                } else if(TEST_B.Touched()) {
                    while (TEST_B.Touched());
                    SendRawId(TEST_BRAS_B);
                    TEST_B.Draw(BLEU, BLANC);
                } else if(TEST_C.Touched()) {
                    while (TEST_C.Touched());
                    SendRawId(TEST_BRAS_C);
                    TEST_C.Draw(BLEU, BLANC);
                } else if(TEST_D.Touched()) {
                    while (TEST_D.Touched());
                    SendRawId(TEST_BRAS_D);
                    TEST_D.Draw(BLEU, BLANC);
                }  else if(TEST_NUM.Touched()) {
                    while (TEST_NUM.Touched());
                    TEST_NUM.Draw(BLEU, BLANC);
                    switch(maximilien){
                    case 1:
                    SendRawId(TEST_BRAS_1);
                    break;
                    case 2:
                    SendRawId(TEST_BRAS_2);
                    break;
                    case 3:
                    SendRawId(TEST_BRAS_3);
                    break;
                    case 4:
                    SendRawId(TEST_BRAS_4);
                    break;
                    case 5:
                    SendRawId(TEST_BRAS_5);
                    break;
                    case 6:
                    SendRawId(TEST_BRAS_6);
                    break;
                    }
                } else if(TEST_PLUS.Touched()) {
                    while (TEST_PLUS.Touched());
                    TEST_PLUS.Draw(BLEU, BLANC);
                    if(maximilien!=6)maximilien++;
                    sprintf(toto,"%hd",maximilien);
                    lcd.SetBackColor(LCD_COLOR_WHITE);
                    lcd.SetTextColor(LCD_COLOR_BLACK);
                    lcd.DisplayStringAt(50, LINE(20), (unsigned char *)toto, LEFT_MODE);
                } else if(TEST_MOINS.Touched()) {
                    while (TEST_MOINS.Touched());
                    TEST_MOINS.Draw(BLEU, BLANC);
                    if(maximilien!=1)maximilien--;
                    sprintf(toto,"%hd",maximilien);
                    lcd.SetBackColor(LCD_COLOR_WHITE);
                    lcd.SetTextColor(LCD_COLOR_BLACK);
                    lcd.DisplayStringAt(50, LINE(20), (unsigned char *)toto, LEFT_MODE);
                }
            }
            break;
        
        case TEST_COULEUR:      
            lcd.Clear (LCD_COLOR_WHITE);
            lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Test Couleur", LEFT_MODE);
            TEST_A.Draw(BLEU, BLANC);
            TEST_B.Draw(BLEU, BLANC);
            TEST_C.Draw(BLEU, BLANC);
            TEST_D.Draw(BLEU, BLANC);
            RETOUR.Draw(0xFFFF0000,0);
            while(strat_etat_s==TEST_COULEUR) {
                if(RETOUR.Touched()) {
                    while (RETOUR.Touched());
                    strat_etat_s=DEMO;
                    lcd.Clear (LCD_COLOR_WHITE);
                }else if(TEST_A.Touched()) {
                    while (TEST_A.Touched());
                    SendRawId(TEST_BRAS_A);
                    TEST_A.Draw(BLEU, BLANC);
                } else if(TEST_B.Touched()) {
                    while (TEST_B.Touched());
                    SendRawId(TEST_BRAS_B);
                    TEST_B.Draw(BLEU, BLANC);
                } else if(TEST_C.Touched()) {
                    while (TEST_C.Touched());
                    SendRawId(TEST_BRAS_C);
                    TEST_C.Draw(BLEU, BLANC);
                } else if(TEST_D.Touched()) {
                    while (TEST_D.Touched());
                    SendRawId(TEST_BRAS_D);
                    TEST_D.Draw(BLEU, BLANC);
                } 
            }
            break;

        case TEST_MOTEUR:
            lcd.SetBackColor(LCD_COLOR_WHITE);
            lcd.SetTextColor(LCD_COLOR_BLACK);
            lcd.Clear (LCD_COLOR_WHITE);   
            lcd.Clear (LCD_COLOR_WHITE);
            lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Test Moteur", LEFT_MODE);
            RETOUR.Draw(0xFFFF0000,0);
            TEST_A.Draw(BLEU, BLANC);
            TEST_B.Draw(BLEU, BLANC);
            while(strat_etat_s==TEST_MOTEUR) {
                if(RETOUR.Touched()) {
                    while (RETOUR.Touched());
                    strat_etat_s=DEMO;
                } else if(TEST_A.Touched()) {
                    while (TEST_A.Touched());
                    BendRadius(150,1800,1,0);
                    TEST_A.Draw(BLEU, BLANC);
                } else if(TEST_B.Touched()) {
                    while (TEST_B.Touched());
                    BendRadius(150,1800,0,0);
                    TEST_B.Draw(BLEU, BLANC);
                } 
            }
            break;      ///////////////////////////////////////////FIN DES DEMOS/////////////////////////////////////////////////


        case SELECT_SIDE :      // CHOIX DU COTE DU TERRAIN + INVERSION DE LA STRAT SI COTE ORANGE+ ENVOI DU COTE A LA CARTE CAPTEUR/ACTIONNEURS
            lcd.Clear(LCD_COLOR_WHITE);
            lcd.SetBackColor(LCD_COLOR_WHITE);
            lcd.SetTextColor(LCD_COLOR_BLACK);

            lcd.DisplayStringAt(70, LINE(0), (uint8_t *)"Choisir le cote", LEFT_MODE);
            COTE_JAUNE.Draw(JAUNE, 0);
            COTE_VIOLET.Draw(VIOLET, 0);
            RETOUR.Draw(LCD_COLOR_RED, 0);


            while (strat_etat_s == SELECT_SIDE) {
                canProcessRx();
                if(COTE_JAUNE.Touched()) {
                    Cote = 0x1;
                    InversStrat = Cote;
                    strat_etat_s = TACTIQUE;
                    CANMessage trame_Tx = CANMessage();
                    trame_Tx.len = 1;
                    trame_Tx.format = CANStandard;
                    trame_Tx.type = CANData;
                    trame_Tx.id=CHOICE_COLOR;
                    trame_Tx.data[0]=Cote;
                    can2.write(trame_Tx);
                    while(COTE_JAUNE.Touched());

                }

                if(COTE_VIOLET.Touched()) {
                    Cote = 0x0;
                    InversStrat= Cote;
                    strat_etat_s = TACTIQUE;
                    CANMessage trame_Tx = CANMessage();
                    trame_Tx.len = 1;
                    trame_Tx.format = CANStandard;
                    trame_Tx.type = CANData;
                    trame_Tx.id=CHOICE_COLOR;
                    trame_Tx.data[0]=Cote;
                    can2.write(trame_Tx);
                    while(COTE_VIOLET.Touched());
                }

                if(RETOUR.Touched()) {
                    strat_etat_s = CHOIX;
                    while(RETOUR.Touched());
                }
            }

            break;

        case TACTIQUE : //AFFICHE LA LISTE DES STRATS AFIN DE SELECTIONNER CELLE VOULUE
            if (Cote == 0) {
                lcd.Clear(JAUNE);
                lcd.SetBackColor(JAUNE);
            } else if (Cote == 1) {
                lcd.Clear(VIOLET);
                lcd.SetBackColor(VIOLET);
            } else {
                lcd.Clear(BLEU);
                lcd.SetBackColor(BLEU);
            }

            lcd.SetTextColor(LCD_COLOR_BLACK);

            lcd.DisplayStringAt(20, LINE(0), (uint8_t *)"Choisir une strategie", LEFT_MODE);

            nbStrat = Bouton_Strat(); // retourne valeur de Strategie si bouton strat renvoi -1 on reviens en arriere
            if (nbStrat == -1) {
                strat_etat_s = SELECT_SIDE;
            } else {
                strat_etat_s = DETAILS;
            }
            wait(0.1);
            break;

        case DETAILS :  //SECONDE VALIDATION DE LA STRAT
            lcd.Clear(LCD_COLOR_WHITE);
            lcd.SetBackColor(LCD_COLOR_WHITE);
            lcd.SetTextColor(LCD_COLOR_BLACK);
            CHECK.Draw(VERT);
            RETOUR.Draw(LCD_COLOR_RED);

            SelectionStrat(nbStrat); //affiche la stratégie selectionnée

            while (strat_etat_s == DETAILS) {
                canProcessRx();
                if (CHECK.Touched()) {
                    if(gameEtat == ETAT_CONFIG) {
                        gameEtat = ETAT_GAME_INIT;
                        strat_etat_s=LECTURE;

                    }
                    while(CHECK.Touched());
                }

                if(RETOUR.Touched()) {
                    strat_etat_s = TACTIQUE;
                    while(RETOUR.Touched());
                }
            }
            break;


        case LECTURE :
            break;
        case AFF_WAIT_JACK : //FONCTIONS D'AFFICHAGE DE L'ATTENTE DU JACK
            lcd.Clear(BLANC);
            lcd.SetBackColor(LCD_COLOR_WHITE);
            lcd.SetTextColor(LCD_COLOR_BLACK);

            if (Cote == 0) {
                lcd.Clear(VERT);
                lcd.SetBackColor(VERT);
            } else if (Cote == 1) {
                lcd.Clear(ORANGE);
                lcd.SetBackColor(ORANGE);
            } else {
                lcd.Clear(VERT);
                lcd.SetBackColor(VERT);
            }
            canProcessRx();
            lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"En attente du Jack", CENTER_MODE);
            strat_etat_s=WAIT_JACK;
            break;

        case WAIT_JACK: //VERITABLE ATTENTE DU JACK
            break;

        case FIN :  //AFFICHAGE DE FIN AVEC LE SCORE FINAL
            lcd.Clear (LCD_COLOR_WHITE);
            lcd.SetBackColor(LCD_COLOR_WHITE);


            while(1); // force le redemarage du robot
            //break;

    }
    }
/****************************************************************************************/
/* FUNCTION NAME: Bouton_Strat                                                          */
/* DESCRIPTION  : Sélection de la strat sur le lcd puis envoie sur CAN (à modifier!)    */
/****************************************************************************************/
signed char Bouton_Strat (void)
{
    char Ack_strat = 0;
    signed char Strat = 0;
    Button STRAT_1 (0, 30, 190, 110, strat_sd[0]);
    Button STRAT_2 (210, 30, 190, 110, strat_sd[1]);
    Button STRAT_3 (0, 150, 190, 110, strat_sd[2]);
    Button STRAT_4 (210, 150, 190, 110, strat_sd[3]);
    Button STRAT_5 (0, 270, 190, 110,strat_sd[4]);
    Button STRAT_6 (210, 270, 190, 110, strat_sd[5]);
    Button STRAT_7 (0, 390, 190, 110, strat_sd[6]);
    Button STRAT_8 (210, 390, 190, 110, strat_sd[7]);
    Button STRAT_9 (0, 510, 190, 110, strat_sd[8]);
    Button STRAT_10 (210, 510, 190, 110, strat_sd[9]);
    Button RETOUR  (0, 680, 400, 110, "--Precedent--");
    //Definition des boutons

    Ack_strat = 0;
    Strat = 0;
    STRAT_1.Draw(0xFFF0F0F0, 0);
    STRAT_2.Draw(0xFFF0F0F0, 0);
    STRAT_3.Draw(0xFFF0F0F0, 0);
    STRAT_4.Draw(0xFFF0F0F0, 0);
    STRAT_5.Draw(0xFFF0F0F0, 0);
    STRAT_6.Draw(0xFFF0F0F0, 0);
    STRAT_7.Draw(0xFFF0F0F0, 0);
    STRAT_8.Draw(0xFFF0F0F0, 0);
    STRAT_9.Draw(0xFFF0F0F0, 0);
    STRAT_10.Draw(0xFFF0F0F0, 0);
    RETOUR.Draw(0xFFFF0000, 0);

    while(Ack_strat == 0) {
        canProcessRx();
        CANMessage msgTx=CANMessage();
        //msgTx.id=ECRAN_CHOICE_STRAT;
        if (RETOUR.Touched())
            return -1;
        while(RETOUR.Touched());
        //////////////////////////////STRATEGIE N°1
        if (STRAT_1.Touched()) {
            Strat = 0;
            //msgTx.data[0] = 0x1;
            //can2.write(msgTx);
            while(STRAT_1.Touched());
            Ack_strat =1;
        }
        /////////////////////////////STRATEGIE N°2
        if (STRAT_2.Touched()) {
            Strat = 1;
            //msgTx.data[0] = 0x2;
            //can2.write(msgTx);
            while(STRAT_2.Touched());
            Ack_strat =1;
        }
        //////////////////////////////STRATEGIE N°3
        if (STRAT_3.Touched()) {
            Strat = 2;
            //msgTx.data[0] = 0x3;
            //can2.write(msgTx);
            while(STRAT_3.Touched());
            Ack_strat =1;
        }
        /////////////////////////////STRATEGIE N°4
        if (STRAT_4.Touched()) {
            Strat = 3;
            //msgTx.data[0] = 0x4;
            //can2.write(msgTx);
            while(STRAT_4.Touched());
            Ack_strat =1;
        }
        ///////////////////////////////STRATEGIE N°5
        if (STRAT_5.Touched()) {
            Strat = 4;
            //msgTx.data[0] = 0x5;
            //can2.write(msgTx);
            while(STRAT_5.Touched());
            Ack_strat =1;
        }
        ////////////////////////////////STRATEGIE N°6
        if (STRAT_6.Touched()) {
            Strat = 5;
            //msgTx.data[0] = 0x6;
            //can2.write(msgTx);
            while(STRAT_6.Touched());
            Ack_strat =1;
        }
        /////////////////////////////////STRATEGIE N°7
        if (STRAT_7.Touched()) {
            Strat = 6;
            //msgTx.data[0] = 0x7;
            //can2.write(msgTx);
            while(STRAT_7.Touched());
            Ack_strat =1;
        }
        /////////////////////////////////STRATEGIE N°8
        if (STRAT_8.Touched()) {
            Strat = 7;
            //msgTx.data[0] = 0x8;
            //can2.write(msgTx);
            while(STRAT_8.Touched());
            Ack_strat =1;
        }
        /////////////////////////////////STRATEGIE N°9
        if (STRAT_9.Touched()) {
            Strat = 8;
            //msgTx.data[0] = 0x9;
            //can2.write(msgTx);
            while(STRAT_9.Touched());
            Ack_strat =1;
        }
        ///////////////////////////////////STRATEGIE N°10
        if (STRAT_10.Touched()) {
            Strat = 9;
            //msgTx.data[0] = 0xA;
            //can2.write(msgTx);
            while(STRAT_10.Touched());
            Ack_strat =1;
        }

    }
    return Strat;

}
/****************************************************************************************/
/* FUNCTION NAME: SelectionStrat                                                        */
/* DESCRIPTION  : Affiche la Stratégie sélectionnée sur l'ihm                           */
/****************************************************************************************/


void SelectionStrat (unsigned char Strategie)
{
    lcd.SetBackColor(LCD_COLOR_WHITE);
    lcd.SetTextColor(LCD_COLOR_BLACK);

    switch (Strategie+1) {
        case 0x1 :
            //description de Strategie n°1
            lcd.DisplayStringAt(150, 0, (uint8_t *)strat_sd[Strategie], LEFT_MODE);
            break;

        case 0x2 :
            //description de Strategie n°2
            lcd.DisplayStringAt(150,0, (uint8_t *)strat_sd[Strategie], LEFT_MODE);
            break;

        case 0x3 :
            //description de Strategie n°3
            lcd.DisplayStringAt(150,0, (uint8_t *)strat_sd[Strategie], LEFT_MODE);
            break;

        case 0x4 :
            //description de Strategie n°4
            lcd.DisplayStringAt(150,0, (uint8_t *)strat_sd[Strategie], LEFT_MODE);
            break;

        case 0x5 :
            //description de Strategie n°5
            lcd.DisplayStringAt(150,0, (uint8_t *)strat_sd[Strategie], LEFT_MODE);
            break;

        case 0x6 :
            //description de Strategie n°5
            lcd.DisplayStringAt(150,0, (uint8_t *)strat_sd[Strategie], LEFT_MODE);
            break;

        case 0x7 :
            //description de Strategie n°5
            lcd.DisplayStringAt(150,0, (uint8_t *)strat_sd[Strategie], LEFT_MODE);
            break;

        case 0x8 :
            //description de Strategie n°5
            lcd.DisplayStringAt(150,0, (uint8_t *)strat_sd[Strategie], LEFT_MODE);
            break;

        case 0x9 :
            //description de Strategie n°5
            lcd.DisplayStringAt(150,0, (uint8_t *)strat_sd[Strategie], LEFT_MODE);
            break;

        case 0xA :
            //description de Strategie n°5
            lcd.DisplayStringAt(150,0, (uint8_t *)strat_sd[Strategie], LEFT_MODE);
            break;
    }
}

void DrawC (int l,int h,int x, int y, unsigned char fill){
    Point c[8]={{l,0},{l,h/6},{l/5,h/3},{l/5,2*(h/3)},{l,5*(h/6)},{l,h},{0,5*(h/6)},{0,h/6}};
    for(int a=0;a<8;a++){
        c[a].X+=x;
        c[a].Y+=y;
    }
    lcd.DrawPolygon(c, 8);
    
}
void DrawR (int l,int h,int x, int y, unsigned char fill){
    Point r[10]={{0,0},{5*(l/6),0},{l,h/3},{5*(l/6),h/2},{l/2,h/2},{l,h},{2*(l/3),h},{l/4,h/2},{l/4,h},{0,h}};
    for(int a=0;a<10;a++){
        r[a].X+=x;
        r[a].Y+=y;
    }
    lcd.DrawPolygon(r, 10);
}
void DrawA (int l,int h,int x, int y, unsigned char fill){
    Point a[8]={{l/4,0},{3*(l/4),0},{l,h},{5*(l/6),h},{4*(l/6),h/2},{2*(l/6),h/2},{l/6,h},{0,h}};
    for(int z=0;z<8;z++){
        a[z].X+=x;
        a[z].Y+=y;
    }
    lcd.DrawPolygon(a, 8);
}
void DrawCheck (int l,int h,int x, int y, int cochage){
    if(x<3)x=3;
    if(cochage == 1){
        lcd.SetTextColor(VERT_F);
        lcd.DrawLine(x,y-(h/2),x+l/2,y+h/2);
        lcd.DrawLine(x-1,y-(h/2),x+l/2,y+h/2+1);
        lcd.DrawLine(x-2,y-(h/2),x+l/2,y+h/2+2);
        lcd.DrawLine(x+l/2,y+h/2,x+(4*(l/3)),y);
        lcd.DrawLine(x+l/2,y+h/2+1,x+(4*(l/3))+1,y);
        lcd.DrawLine(x+l/2,y+h/2+2,x+(4*(l/3))+2,y);
        lcd.SetTextColor(NOIR);
    } else {
        Point a[4]={{0,0},{l,0},{l,h},{0,h}};
        for(int z=0;z<8;z++){
            a[z].X+=x;
            a[z].Y+=y;
        }
        lcd.DrawPolygon(a, 4);
    }
}