X

Dependencies:   mbed BSP_DISCO_F746NG

Revision:
3:92661d767dd1
Parent:
1:80d2a1719d10
Child:
4:8f6e0ef3fffe
--- a/main.cpp	Wed Nov 04 14:42:33 2020 +0000
+++ b/main.cpp	Sun Nov 08 18:33:37 2020 +0000
@@ -1,16 +1,20 @@
-#include "mbed.h"
-#include "stm32746g_discovery_lcd.h"
-#include "stm32746g_discovery_ts.h"
 #include "fonctions.h"
 
 int main()
 {
 
-    uint16_t x;
-    uint8_t temps = 700;
+    uint16_t x=0;
+    uint16_t y=0;
+    uint16_t temps = 100;
     int NumeroPage = 0;
 
 
+
+    char Text[2];
+    
+    int TAB_ingredients[6]={0,0,0,0,0,0};
+    
+
     BSP_LCD_Init(); //Initialisation LCD
     BSP_LCD_LayerDefaultInit(LTDC_ACTIVE_LAYER, LCD_FB_START_ADDRESS);
     BSP_LCD_SelectLayer(LTDC_ACTIVE_LAYER);
@@ -18,29 +22,44 @@
     TS_StateTypeDef TS_State;
     BSP_TS_Init(BSP_LCD_GetXSize(), BSP_LCD_GetYSize()); // Initialisation de la fonction tactile
     AfficherPage(0);
+
     while (1) {
-        
+
         BSP_TS_GetState(&TS_State);
-        
-        if (TS_State.touchEventId [0] == TOUCH_EVENT_PRESS_DOWN ) {  
-            
-            //LaisseAppuyer = true;
+
+        if (TS_State.touchEventId [0] == TOUCH_EVENT_PRESS_DOWN ) {
+
             x = TS_State.touchX[0];
-            //y = TS_State.touchY[0];
+            y = TS_State.touchY[0];
 
-            if (x<= 237) {
-                NumeroPage = NumeroPage - 1;
-                TS_State.touchEventId [0] = 0;
-                //LaisseAppuyer = false;
+            if (( Bouton(160,0,80,33,x,y) == true ) && ( NumeroPage == 0 )) {
+                NumeroPage =1;
+                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(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);
+            }
+            
+            
+        HAL_Delay(temps);
+        TS_State.touchEventId [0] = 0;
+        TS_State.touchEventId [1] = 0;
+        
 
-            } else if (x > 237){
-                NumeroPage =NumeroPage +1;
-                TS_State.touchEventId [0] = 0;
-                //LaisseAppuyer = false;
-            }
-            AfficherPage(NumeroPage);
-            HAL_Delay(temps);
         }
-    
+        
     }
 }