X

Dependencies:   mbed BSP_DISCO_F746NG

Files at this revision

API Documentation at this revision

Comitter:
valentin__
Date:
Wed Nov 11 15:27:24 2020 +0000
Parent:
3:92661d767dd1
Commit message:
X

Changed in this revision

fonctions.cpp Show annotated file Show diff for this revision Revisions of this file
fonctions.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
--- a/fonctions.cpp	Sun Nov 08 18:33:37 2020 +0000
+++ b/fonctions.cpp	Wed Nov 11 15:27:24 2020 +0000
@@ -1,5 +1,21 @@
 #include "fonctions.h"
 
+void Affiche_Ingredients(int TAB_ingredients[]){
+    int i=0;
+    BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
+    for(i=0; i<3; i++){
+        char Text[1];
+        sprintf((char*)&Text, "%d", TAB_ingredients[i]);
+        BSP_LCD_DisplayStringAt(162*i,37, (uint8_t *)&Text, LEFT_MODE);
+        }
+    for(i=3; i<6; i++){
+        char Text2[1];
+        sprintf((char*)&Text2, "%d", TAB_ingredients[i]);
+        BSP_LCD_DisplayStringAt(162*i,149,(uint8_t *)&Text2, LEFT_MODE);
+        }
+    }
+    
+    
 bool Bouton(uint16_t Xpos, uint16_t Ypos, uint16_t Xdim, uint16_t Ydim,uint16_t x,uint16_t y){
     if((x >= Xpos) && (x<= Xpos+Xdim ) && (y <= Ypos + Ydim) && (y>= Ypos )){
         return true;
@@ -18,14 +34,12 @@
             
             BSP_LCD_DrawPixel(Xpos + j, Ypos + i, img[j + i*Largeur] + 0xFF000000); //j + i*Largeur
         }
-        
     }
-   
     }
 
-void Page1()
+void Page_Recette()
 {
-    BSP_LCD_Clear(LCD_COLOR_WHITE);
+    
     BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
     BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
     BSP_LCD_DisplayStringAt(0, LINE(5), (uint8_t *)"Recettes", CENTER_MODE);
@@ -34,7 +48,7 @@
 
 
 
-void Ingredients()
+void Page_Ingredients()
 {
     AfficheImage(0,0,160,90,image1);
     AfficheImage(160,0,160,90,image2);
@@ -55,10 +69,10 @@
 {
 
     if(NumeroPage==0){
-        Ingredients();
+        Page_Ingredients();
         }
     else if(NumeroPage == 1){
-        Page1();
+        Page_Recette();
         }
 }
 
--- a/fonctions.h	Sun Nov 08 18:33:37 2020 +0000
+++ b/fonctions.h	Wed Nov 11 15:27:24 2020 +0000
@@ -17,4 +17,5 @@
 void Page2(void);
 void PageErreur(void);
 bool Bouton(uint16_t , uint16_t , uint16_t , uint16_t , uint16_t,uint16_t);
-void AfficheImage(uint32_t , uint32_t , uint32_t , uint32_t Huteur, const unsigned long );
\ No newline at end of file
+void AfficheImage(uint32_t , uint32_t , uint32_t , uint32_t, const unsigned long );
+void Affiche_Ingredients(int TAB_ingredients[]);
\ No newline at end of file
--- a/main.cpp	Sun Nov 08 18:33:37 2020 +0000
+++ b/main.cpp	Wed Nov 11 15:27:24 2020 +0000
@@ -7,18 +7,15 @@
     uint16_t y=0;
     uint16_t temps = 100;
     int NumeroPage = 0;
-
-
-
-    char Text[2];
     
-    int TAB_ingredients[6]={0,0,0,0,0,0};
+    int TAB_ingredients[6]={0,0,0,0,0,0};//Dans l'ordre : Pates, oeufs, tomate, lardon, steak, creme;
     
 
     BSP_LCD_Init(); //Initialisation LCD
     BSP_LCD_LayerDefaultInit(LTDC_ACTIVE_LAYER, LCD_FB_START_ADDRESS);
     BSP_LCD_SelectLayer(LTDC_ACTIVE_LAYER);
-
+    BSP_LCD_Clear(LCD_COLOR_WHITE);
+    
     TS_StateTypeDef TS_State;
     BSP_TS_Init(BSP_LCD_GetXSize(), BSP_LCD_GetYSize()); // Initialisation de la fonction tactile
     AfficherPage(0);
@@ -32,33 +29,43 @@
             x = TS_State.touchX[0];
             y = TS_State.touchY[0];
 
-            if (( Bouton(160,0,80,33,x,y) == true ) && ( NumeroPage == 0 )) {
+            if (( Bouton(160,0,80,33,x,y) == true ) && ( NumeroPage == 0 )) { //Validation
                 NumeroPage =1;
+                BSP_LCD_Clear(LCD_COLOR_WHITE);
                 AfficherPage(NumeroPage);
             } 
-            
-            else if (( Bouton(240,0,80,33,x,y)== true ) && ( NumeroPage== 0 )) {
-                TAB_ingredients[0]=0;
-                sprintf((char*)&TextTomate, "%d", TAB_ingredients[0]);
-                BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
-                BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
-                BSP_LCD_DisplayStringAt(400, 61, (uint8_t *)&Text, LEFT_MODE);
+            else if (( Bouton(240,0,80,33,x,y)== true ) && ( NumeroPage== 0 )) {//Annulation
+               TAB_ingredients[0]=TAB_ingredients[1]=TAB_ingredients[2]=TAB_ingredients[3]=TAB_ingredients[4]=TAB_ingredients[5]=0;
+               BSP_LCD_Clear(LCD_COLOR_WHITE);
+                AfficherPage(NumeroPage);              
+            }
+            else if (( Bouton(0,33,160,90,x,y)== true ) && ( NumeroPage== 0 )) {//Pates
+                TAB_ingredients[0]+=1;                
             }
-            
-            else if (( Bouton(320,33,160,90,x,y)== true ) && ( NumeroPage== 0 )) {
-                TAB_ingredients[0]+=1;
-                sprintf((char*)&TextTomate[0], "%d", TAB_ingredients[0]);
-                BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
-                BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
-                BSP_LCD_DisplayStringAt(400, 61, (uint8_t *)&Text, LEFT_MODE);
-            }
-            
-            
+            else if (( Bouton(160,33,160,90,x,y)== true ) && ( NumeroPage== 0 )) {//Oeufs
+                TAB_ingredients[1]+=1;
+                }
+            else if (( Bouton(320,33,160,90,x,y)== true ) && ( NumeroPage== 0 )) {//Tomates
+                TAB_ingredients[2]+=1;
+                }
+            else if (( Bouton(0,123,160,90,x,y)== true ) && ( NumeroPage== 0 )) {//Lardons
+                TAB_ingredients[3]+=1;
+                }
+            else if (( Bouton(160,123,160,90,x,y)== true ) && ( NumeroPage== 0 )) {//Steak
+                TAB_ingredients[4]+=1;
+                 }
+            else if (( Bouton(320,123,160,90,x,y)== true ) && ( NumeroPage== 0 )) {//creme
+                TAB_ingredients[5]+=1;
+                }
+                
+                
+        if(NumeroPage == 0){ //Affichage du tableau ingredients
+            Affiche_Ingredients(TAB_ingredients); 
+         }              
         HAL_Delay(temps);
         TS_State.touchEventId [0] = 0;
         TS_State.touchEventId [1] = 0;
-        
-
+    
         }
         
     }