code avec modifs, programme mit dans les robots pour les derniers matchs

Dependencies:   mbed SerialHalfDuplex SDFileSystem liaison_Bluetooth ident_crac DISCO-F469NI_portrait

Revision:
35:2a745eeb7922
Parent:
34:c314feaa0d3e
Child:
36:c37dbe2be916
--- a/IHM/ihm.cpp	Mon May 17 07:19:15 2021 +0000
+++ b/IHM/ihm.cpp	Fri May 21 16:19:18 2021 +0000
@@ -1,5 +1,7 @@
 #include "global.h"
 
+#define M_PI 3.14159265358979323846
+ 
 #define VERT 0xFF00FF00
 #define ROUGE 0xFFFF0000
 #define BLEU 0xFF0000FF
@@ -10,6 +12,7 @@
 #define DIY_GREY 0xFFDFDFDF
 #define VIOLET 0xFF4527A0
 #define VERT_F 0xFF00C400
+#define VIOLET_F 0x788000FF
 TS_DISCO_F469NI ts;
 LCD_DISCO_F469NI lcd;
 
@@ -78,7 +81,7 @@
 void automate_etat_ihm(void)
 {
     char toto[12]; 
-    int j;
+    int j, old_time=0, actual_time=0, old_score=0, actual_score=0, unique=0;
     unsigned char maximilien=1, choix_groupe;
     if (j==0) {
         ts.Init(lcd.GetXSize(), lcd.GetYSize());
@@ -220,9 +223,12 @@
             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);
+            TEST_B.Draw(BLEU, BLANC);                
+            TEST_C.Draw(BLEU, BLANC) ;
+                
             while(strat_etat_s==TEST_ASSERVE) {
                 if(RETOUR.Touched()) {
                     while (RETOUR.Touched());
@@ -236,6 +242,12 @@
                     Rotate(3599);
                     TEST_B.Draw(BLEU, BLANC);
                 }  
+                  else if(TEST_C.Touched()) 
+                {
+                    while (TEST_C.Touched());
+                    BendRadius(1000,900,1,0);
+                    TEST_B.Draw(BLEU, BLANC);
+                }  
             }
         break; 
 
@@ -247,7 +259,6 @@
                 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);
@@ -257,6 +268,7 @@
                 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);
+                RETOUR.Draw(0xFFFF0000,0);
                 if(RETOUR.Touched()) {
                     while (RETOUR.Touched());
                     strat_etat_s=DEMO2;
@@ -1171,11 +1183,11 @@
             lcd.SetTextColor(LCD_COLOR_BLACK);
 
             if (Cote == 0) {
-                lcd.Clear(VERT);
-                lcd.SetBackColor(VERT);
+                lcd.Clear(LCD_COLOR_WHITE);
+                lcd.SetBackColor(LCD_COLOR_WHITE);
             } else if (Cote == 1) {
-                lcd.Clear(ORANGE);
-                lcd.SetBackColor(ORANGE);
+                lcd.Clear(LCD_COLOR_WHITE);
+                lcd.SetBackColor(LCD_COLOR_WHITE);
             } else {
                 lcd.Clear(VERT);
                 lcd.SetBackColor(VERT);
@@ -1183,20 +1195,71 @@
             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
+        case WAIT_JACK :
+            if(unique == 0)
+            {
+                lcd.SetTextColor(LCD_COLOR_BLUE);
+                lcd.DrawRect(0,50,400,320);
+                lcd.DisplayStringAt(100, LINE(8), (unsigned char *)"Score :", LEFT_MODE);
+                lcd.SetTextColor(LCD_COLOR_RED);
+                lcd.DrawRect(0,400,400,320);
+                lcd.DisplayStringAt(100, LINE(22), (unsigned char *)"Timer :", LEFT_MODE);
+                unique = 1;
+            }
+            int x_offsetc = -145*cos(theta_robot*M_PI/1800) - 0*sin(theta_robot*M_PI*1800);
+            int y_offsetc = -145*sin(theta_robot*M_PI/1800) + 0*cos(theta_robot*M_PI*1800);
+            
+            lcd.SetTextColor(LCD_COLOR_BLACK);
+            lcd.DisplayStringAt(100, LINE(14), (unsigned char *)"x_robot :", LEFT_MODE);
+            sprintf(toto,"%04d",(short)(x_robot+x_offsetc));
+            lcd.DisplayStringAt(250, LINE(14), (unsigned char *)toto, LEFT_MODE);
+            
+            lcd.DisplayStringAt(100, LINE(15), (unsigned char *)"y_robot :", LEFT_MODE);
+            sprintf(toto,"%04d",(short)(y_robot+y_offsetc));
+            lcd.DisplayStringAt(250, LINE(15), (unsigned char *)toto, LEFT_MODE);
+            
+            lcd.DisplayStringAt(100, LINE(16), (unsigned char *)"t_robot :", LEFT_MODE);
+            sprintf(toto,"%04d",theta_robot);
+            lcd.DisplayStringAt(250, LINE(16), (unsigned char *)toto, LEFT_MODE);
+            
+            lcd.DisplayStringAt(100, LINE(17), (unsigned char *)"g_vert :", LEFT_MODE);
+            sprintf(toto,"%04d",gobelet_vert);
+            lcd.DisplayStringAt(250, LINE(17), (unsigned char *)toto, LEFT_MODE);
+            
+            lcd.DisplayStringAt(100, LINE(18), (unsigned char *)"g_rouge :", LEFT_MODE);
+            sprintf(toto,"%04d",gobelet_rouge);
+            lcd.DisplayStringAt(250, LINE(18), (unsigned char *)toto, LEFT_MODE);
+            
+            lcd.DisplayStringAt(100, LINE(19), (unsigned char *)"g_port :", LEFT_MODE);
+            sprintf(toto,"%04d",gobelet_port);
+            lcd.DisplayStringAt(250, LINE(19), (unsigned char *)toto, LEFT_MODE);
+            
+            actual_time = gameTimer.read();
+            if(actual_time != old_time)
+            {
+                lcd.SetTextColor(LCD_COLOR_BLUE);
+                sprintf(toto,"%hd",score_final);
+                lcd.DisplayStringAt(250, LINE(8), (unsigned char *)toto, LEFT_MODE);
+                
+                lcd.SetTextColor(LCD_COLOR_RED);          
+                sprintf(toto,"%hd",actual_time);
+                lcd.DisplayStringAt(250, LINE(22), (unsigned char *)toto, LEFT_MODE);
+                old_time = actual_time;
+            }
             break;
-
+    
+        
         case FIN :  //AFFICHAGE DE FIN AVEC LE SCORE FINAL
-            lcd.Clear (LCD_COLOR_WHITE);
-            lcd.SetBackColor(LCD_COLOR_WHITE);
+//            lcd.Clear(LCD_COLOR_WHITE);
+//            lcd.SetBackColor(LCD_COLOR_WHITE);
 
 
             while(1); // force le redemarage du robot
             //break;
-
-    }
+        }
     }
 /****************************************************************************************/
 /* FUNCTION NAME: Bouton_Strat                                                          */