Code projet_gestion_de_commande_en_ligne

Dependencies:   TS_DISCO_F746NG LCD_DISCO_F746NG BSP_DISCO_F746NG BUTTON_GROUP

Revision:
2:e007f6b6e145
Parent:
1:7e34491bfd01
Child:
3:5b6f580d3f3a
diff -r 7e34491bfd01 -r e007f6b6e145 main.cpp
--- a/main.cpp	Fri Jun 19 14:12:12 2020 +0000
+++ b/main.cpp	Mon Jun 22 15:41:23 2020 +0000
@@ -13,8 +13,6 @@
 #include "haricot.h"
 
 
-
-
 Serial pc(USBTX, USBRX); // tx, rx
 
 using namespace Mikami;
@@ -195,15 +193,6 @@
 }
 
 
-
-
-
-
-
-
-
-
-
 int main()
 {
     unsigned int boutton_commande = 0;
@@ -213,6 +202,18 @@
     unsigned int boutton_acceuil = 0;
     unsigned int boutton_valider = 0;
     
+    unsigned int nb_pommes = 0;
+    unsigned int nb_poires = 0;
+    unsigned int nb_oranges = 0;
+    unsigned int nb_bananes = 0;
+    unsigned int nb_tomates = 0;
+    unsigned int nb_fraises = 0;
+    unsigned int nb_raisins = 0;
+    unsigned int nb_kiwis = 0;
+    unsigned int nb_haricots = 0;
+    
+    char buffer [50] ;
+    
     BSP_LCD_Init();
     BSP_LCD_LayerDefaultInit(LTDC_ACTIVE_LAYER, LCD_FB_START_ADDRESS);
     BSP_LCD_SelectLayer(LTDC_ACTIVE_LAYER);
@@ -248,29 +249,98 @@
         BSP_LCD_Clear(LCD_COLOR_WHITE);
         HAL_Delay(1000);
         
-        drawImage_pomme (0,70) ; 
-        drawImage_poire (0,130) ;
-        drawImage_orange (0,200) ;  
-        drawImage_banane (155,65) ;  
-        drawImage_tomate (155,130) ;  
-        drawImage_fraise (155,200) ;
-        drawImage_raisin (310,65) ;
-        drawImage_kiwi (317,138) ;
-        drawImage_haricot (310,200) ;
+        //Images produits
+        drawImage_pomme (10,45) ; 
+        drawImage_poire (10,130) ;
+        drawImage_orange (10,200) ;  
+        drawImage_banane (165,35) ;  
+        drawImage_tomate (165,122) ;  
+        drawImage_fraise (165,200) ;
+        drawImage_raisin (320,35) ;
+        drawImage_kiwi (330,125) ;
+        drawImage_haricot (330,205) ;
+        HAL_Delay(1000);
+        
+        BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
+        BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
+        
+        //Noms produits
+        BSP_LCD_SetFont(&Font12);
+        BSP_LCD_DisplayStringAt(350, 55, (uint8_t *)"Pommes", CENTER_MODE);
+        BSP_LCD_DisplayStringAt(350, 140, (uint8_t *)"Poires", CENTER_MODE);
+        BSP_LCD_DisplayStringAt(350, 210, (uint8_t *)"Oranges", CENTER_MODE);
+        BSP_LCD_DisplayStringAt(30, 55, (uint8_t *)"Bananes", CENTER_MODE);
+        BSP_LCD_DisplayStringAt(30, 140, (uint8_t *)"Tomates", CENTER_MODE);
+        BSP_LCD_DisplayStringAt(30, 210, (uint8_t *)"Fraises", CENTER_MODE);
+        BSP_LCD_DisplayStringAt(190, 55, (uint8_t *)"Raisins", CENTER_MODE);
+        BSP_LCD_DisplayStringAt(190, 140, (uint8_t *)"Kiwis", CENTER_MODE);
+        BSP_LCD_DisplayStringAt(190, 210, (uint8_t *)"Haricots", CENTER_MODE);
+        HAL_Delay(1000);
+        
+        //Prix produits
+        BSP_LCD_SetFont(&Font8);
+        BSP_LCD_DisplayStringAt(350, 75, (uint8_t *)"2,20 Euros/kg", CENTER_MODE);
+        BSP_LCD_DisplayStringAt(350, 160, (uint8_t *)"3,50 Euros/kg", CENTER_MODE);
+        BSP_LCD_DisplayStringAt(350, 230, (uint8_t *)"2,00 Euros/kg", CENTER_MODE);
+        BSP_LCD_DisplayStringAt(30, 75, (uint8_t *)"3,00 Euros/kg", CENTER_MODE);
+        BSP_LCD_DisplayStringAt(30, 160, (uint8_t *)"1,00 Euros/kg", CENTER_MODE);
+        BSP_LCD_DisplayStringAt(30, 230, (uint8_t *)"4,00 Euros/kg", CENTER_MODE);
+        BSP_LCD_DisplayStringAt(190, 75, (uint8_t *)"4,20 Euros/kg", CENTER_MODE);
+        BSP_LCD_DisplayStringAt(190, 160, (uint8_t *)"2,99 Euros/kg", CENTER_MODE);
+        BSP_LCD_DisplayStringAt(190, 230, (uint8_t *)"1,50 Euros/kg", CENTER_MODE);
+        HAL_Delay(1000);
+        
+        //Boutons produits
+        Button pommes(lcd_, ts_, 15, 93, 130, 20,
+                     LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Ajouter au panier", Font12);
+        pommes.Draw(LCD_COLOR_ORANGE, LCD_COLOR_BLACK);
+        
+        Button poires(lcd_, ts_, 15, 175, 130, 20,
+                     LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Ajouter au panier", Font12);
+        poires.Draw(LCD_COLOR_ORANGE, LCD_COLOR_BLACK);
+        
+        Button oranges(lcd_, ts_, 15, 248, 130, 20,
+                     LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Ajouter au panier", Font12);
+        oranges.Draw(LCD_COLOR_ORANGE, LCD_COLOR_BLACK);
+        
+        Button bananes(lcd_, ts_, 175, 93, 130, 20,
+                     LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Ajouter au panier", Font12);
+        bananes.Draw(LCD_COLOR_ORANGE, LCD_COLOR_BLACK);
+        
+        Button tomates(lcd_, ts_, 175, 175, 130, 20,
+                     LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Ajouter au panier", Font12);
+        tomates.Draw(LCD_COLOR_ORANGE, LCD_COLOR_BLACK);
+        
+        Button fraises(lcd_, ts_, 175, 248, 130, 20,
+                     LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Ajouter au panier", Font12);
+        fraises.Draw(LCD_COLOR_ORANGE, LCD_COLOR_BLACK);
+        
+        Button raisins(lcd_, ts_, 335, 93, 130, 20,
+                     LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Ajouter au panier", Font12);
+        raisins.Draw(LCD_COLOR_ORANGE, LCD_COLOR_BLACK);
+        
+        Button kiwis(lcd_, ts_, 335, 175, 130, 20,
+                     LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Ajouter au panier", Font12);
+        kiwis.Draw(LCD_COLOR_ORANGE, LCD_COLOR_BLACK);
+        
+        Button haricots(lcd_, ts_, 335, 248, 130, 20,
+                     LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Ajouter au panier", Font12);
+        haricots.Draw(LCD_COLOR_ORANGE, LCD_COLOR_BLACK);
+        HAL_Delay(1000);
          
         //Bouton retour
-        Button retour(lcd_, ts_, 10, 5, 60, 40,
-                     LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Retour", Font12);
+        Button retour(lcd_, ts_, 33, 5, 90, 30,
+                     LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Retour", Font16);
         retour.Draw(LCD_COLOR_GRAY, LCD_COLOR_BLACK);
         
         //Bouton scanner
-        Button scanner(lcd_, ts_, 200, 5, 60, 40,
-                     LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Scanner", Font12);
+        Button scanner(lcd_, ts_, 198, 5, 90, 30,
+                     LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Scanner", Font16);
         scanner.Draw(LCD_COLOR_GRAY, LCD_COLOR_BLACK);
         
         //Bouton panier
-        Button panier(lcd_, ts_, 410, 5, 60, 40,
-                     LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Panier", Font12);
+        Button panier(lcd_, ts_, 360, 5, 90, 30,
+                     LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Panier", Font16);
         panier.Draw(LCD_COLOR_GRAY, LCD_COLOR_BLACK);
         
         while(boutton_retour == 0 && boutton_scanner == 0 && boutton_panier == 0)
@@ -278,6 +348,15 @@
             if(retour.Touched())
             {
                 boutton_retour = 1;
+                nb_pommes = 0;
+                nb_poires = 0;
+                nb_oranges = 0;
+                nb_bananes = 0;
+                nb_tomates = 0;
+                nb_fraises = 0;
+                nb_raisins = 0;
+                nb_kiwis = 0;
+                nb_haricots = 0;
             }
             
             else if(scanner.Touched())
@@ -322,8 +401,71 @@
                 BSP_LCD_Clear(LCD_COLOR_WHITE);
                 HAL_Delay(1000);
                 
+                //Images produits
+                drawImage_pomme (10,15) ; 
+                drawImage_poire (10,100) ;
+                drawImage_orange (10,170) ;  
+                drawImage_banane (165,5) ;  
+                drawImage_tomate (165,92) ;  
+                drawImage_fraise (165,170) ;
+                drawImage_raisin (320,5) ;
+                drawImage_kiwi (330,95) ;
+                drawImage_haricot (330,175) ;
+                HAL_Delay(1000);
+                
+                BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
+                BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
+                
+                //Noms produits
+                BSP_LCD_SetFont(&Font12);
+                BSP_LCD_DisplayStringAt(350, 25, (uint8_t *)"Pommes", CENTER_MODE);
+                BSP_LCD_DisplayStringAt(350, 110, (uint8_t *)"Poires", CENTER_MODE);
+                BSP_LCD_DisplayStringAt(350, 180, (uint8_t *)"Oranges", CENTER_MODE);
+                BSP_LCD_DisplayStringAt(30, 25, (uint8_t *)"Bananes", CENTER_MODE);
+                BSP_LCD_DisplayStringAt(30, 110, (uint8_t *)"Tomates", CENTER_MODE);
+                BSP_LCD_DisplayStringAt(30, 180, (uint8_t *)"Fraises", CENTER_MODE);
+                BSP_LCD_DisplayStringAt(190, 25, (uint8_t *)"Raisins", CENTER_MODE);
+                BSP_LCD_DisplayStringAt(190, 110, (uint8_t *)"Kiwis", CENTER_MODE);
+                BSP_LCD_DisplayStringAt(190, 180, (uint8_t *)"Haricots", CENTER_MODE);
+                HAL_Delay(1000);
+                
+                //Prix produits
+                BSP_LCD_SetFont(&Font8);
+                BSP_LCD_DisplayStringAt(350, 45, (uint8_t *)"2,20 Euros/kg", CENTER_MODE);
+                BSP_LCD_DisplayStringAt(350, 130, (uint8_t *)"3,50 Euros/kg", CENTER_MODE);
+                BSP_LCD_DisplayStringAt(350, 200, (uint8_t *)"2,00 Euros/kg", CENTER_MODE);
+                BSP_LCD_DisplayStringAt(30, 45, (uint8_t *)"3,00 Euros/kg", CENTER_MODE);
+                BSP_LCD_DisplayStringAt(30, 130, (uint8_t *)"1,00 Euros/kg", CENTER_MODE);
+                BSP_LCD_DisplayStringAt(30, 200, (uint8_t *)"4,00 Euros/kg", CENTER_MODE);
+                BSP_LCD_DisplayStringAt(190, 45, (uint8_t *)"4,20 Euros/kg", CENTER_MODE);
+                BSP_LCD_DisplayStringAt(190, 130, (uint8_t *)"2,99 Euros/kg", CENTER_MODE);
+                BSP_LCD_DisplayStringAt(190, 200, (uint8_t *)"1,50 Euros/kg", CENTER_MODE);
+                HAL_Delay(1000);
+                
+                //Nombres produits dans panier
+                BSP_LCD_SetFont(&Font12);
+                sprintf(buffer, "Nombre : %d", nb_pommes);
+                BSP_LCD_DisplayStringAt(350, 55, (uint8_t *)buffer, CENTER_MODE);
+                sprintf(buffer, "Nombre : %d", nb_poires);
+                BSP_LCD_DisplayStringAt(350, 140, (uint8_t *)buffer, CENTER_MODE);
+                sprintf(buffer, "Nombre : %d", nb_oranges);
+                BSP_LCD_DisplayStringAt(350, 210, (uint8_t *)buffer, CENTER_MODE);
+                sprintf(buffer, "Nombre : %d", nb_bananes);
+                BSP_LCD_DisplayStringAt(30, 55, (uint8_t *)buffer, CENTER_MODE);
+                sprintf(buffer, "Nombre : %d", nb_tomates);
+                BSP_LCD_DisplayStringAt(30, 140, (uint8_t *)buffer, CENTER_MODE);
+                sprintf(buffer, "Nombre : %d", nb_fraises);
+                BSP_LCD_DisplayStringAt(30, 210, (uint8_t *)buffer, CENTER_MODE);
+                sprintf(buffer, "Nombre : %d", nb_raisins);
+                BSP_LCD_DisplayStringAt(190, 55, (uint8_t *)buffer, CENTER_MODE);
+                sprintf(buffer, "Nombre : %d", nb_kiwis);
+                BSP_LCD_DisplayStringAt(190, 140, (uint8_t *)buffer, CENTER_MODE);
+                sprintf(buffer, "Nombre : %d", nb_haricots);
+                BSP_LCD_DisplayStringAt(190, 210, (uint8_t *)buffer, CENTER_MODE);
+                HAL_Delay(1000);
+                
                 //Bouton valider la commande
-                Button valider(lcd_, ts_, 88, 215, 300, 40,
+                Button valider(lcd_, ts_, 88, 225, 300, 40,
                              LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Valider la commande", Font16);
                 valider.Draw(LCD_COLOR_GRAY, LCD_COLOR_BLACK);
                 
@@ -362,10 +504,64 @@
                     if(acceuil.Touched())
                     {
                         boutton_acceuil = 1;
+                        nb_pommes = 0;
+                        nb_poires = 0;
+                        nb_oranges = 0;
+                        nb_bananes = 0;
+                        nb_tomates = 0;
+                        nb_fraises = 0;
+                        nb_raisins = 0;
+                        nb_kiwis = 0;
+                        nb_haricots = 0;
                     }
                 }
                 boutton_acceuil = 0;
             }
+            
+            else if(pommes.Touched())
+            {
+                nb_pommes = nb_pommes + 1;
+            }
+            
+            else if(poires.Touched())
+            {
+                nb_poires = nb_poires + 1;
+            }  
+            
+            else if(oranges.Touched())
+            {
+                nb_oranges = nb_oranges + 1;
+            }   
+            
+            else if(bananes.Touched())
+            {
+                nb_bananes = nb_bananes + 1;
+            } 
+            
+            else if(tomates.Touched())
+            {
+                nb_tomates = nb_tomates + 1;
+            }   
+            
+            else if(fraises.Touched())
+            {
+                nb_fraises = nb_fraises + 1;
+            }     
+            
+            else if(raisins.Touched())
+            {
+                nb_raisins = nb_raisins + 1;
+            }   
+            
+            else if(kiwis.Touched())
+            {
+                nb_kiwis = nb_kiwis + 1;
+            }   
+            
+            else if(haricots.Touched())
+            {
+                nb_haricots = nb_haricots + 1;
+            }         
         }
         boutton_retour = 0;
         boutton_scanner = 0;