Team Projet / Mbed 2 deprecated Projet_Avec_Img

Dependencies:   mbed BSP_DISCO_F746NG

Files at this revision

API Documentation at this revision

Comitter:
valentin__
Date:
Wed Oct 21 14:22:59 2020 +0000
Parent:
0:816f0e6362c5
Child:
2:3070bad3789b
Commit message:
test

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fonctions.cpp	Wed Oct 21 14:22:59 2020 +0000
@@ -0,0 +1,67 @@
+#include "mbed.h"
+#include "stm32746g_discovery_lcd.h"
+#include "stm32746g_discovery_ts.h"
+#include "fonctions.h"
+
+
+void Page1()
+{
+    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 *)"Page1", CENTER_MODE);
+}
+
+
+void Page2()
+{
+    BSP_LCD_Clear(LCD_COLOR_ORANGE);
+    BSP_LCD_SetBackColor(LCD_COLOR_GREEN);
+    BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
+    BSP_LCD_DisplayStringAt(0, LINE(5), (uint8_t *)"Page2", CENTER_MODE);
+
+}
+
+void Bienvenue()
+{
+    BSP_LCD_Clear(LCD_COLOR_WHITE);
+    BSP_LCD_Clear(LCD_COLOR_WHITE);
+    BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
+    BSP_LCD_DisplayStringAt(0, LINE(5), (uint8_t *)"Bienvenue", CENTER_MODE);
+    
+}
+
+void AfficherPage(int NumeroPage)
+{
+
+    switch(NumeroPage) {
+        case 0 :
+            Bienvenue();
+            
+            break;
+        case 1 :
+            Page1();
+
+            break;
+        case 2 :
+            Page2();
+            printf("Affichage page %d\n", NumeroPage);
+ 
+            break;
+
+        //case 4 :
+        //    printf("Affichage page %d\n", NumeroPage);
+        //    break;
+        default :
+            PageErreur();
+            printf("erreur appel AfficherPage %d", NumeroPage);
+
+    }
+}
+
+void PageErreur(){
+    BSP_LCD_Clear(LCD_COLOR_BLUE);
+    BSP_LCD_SetBackColor(LCD_COLOR_BLUE);
+    BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
+    BSP_LCD_DisplayStringAt(0, LINE(5), (uint8_t *)"ERREUR", CENTER_MODE);
+    }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fonctions.h	Wed Oct 21 14:22:59 2020 +0000
@@ -0,0 +1,8 @@
+#include "mbed.h"
+#include "stm32746g_discovery_lcd.h"
+#include "stm32746g_discovery_ts.h"
+
+void AfficherPage(int);
+void Page1(void);
+void Page2(void);
+void PageErreur(void);
\ No newline at end of file
--- a/main.cpp	Wed Oct 14 16:11:49 2020 +0000
+++ b/main.cpp	Wed Oct 21 14:22:59 2020 +0000
@@ -1,41 +1,46 @@
 #include "mbed.h"
 #include "stm32746g_discovery_lcd.h"
 #include "stm32746g_discovery_ts.h"
+#include "fonctions.h"
 
-int main() {  
-    uint8_t status;
-    uint16_t x, y;
-    BSP_LCD_Init();
+int main()
+{
+
+    uint16_t x;
+    uint8_t temps = 700;
+    int NumeroPage = 0;
+
+
+    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_RED);
-    BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
-    BSP_LCD_DisplayStringAt(0, LINE(5), (uint8_t *)"BIENVENUE", CENTER_MODE);
+
     TS_StateTypeDef TS_State;
-    
-    status = BSP_TS_Init(BSP_LCD_GetXSize(), BSP_LCD_GetYSize());
-    while (1){   
-    BSP_TS_GetState(&TS_State);
-    if (TS_State.touchDetected) {
+    BSP_TS_Init(BSP_LCD_GetXSize(), BSP_LCD_GetYSize()); // Initialisation de la fonction tactile
+    AfficherPage(0);
+    while (1) {
+        
+        BSP_TS_GetState(&TS_State);
         
-        BSP_LCD_Clear(LCD_COLOR_BLACK); 
-        BSP_LCD_SetBackColor(LCD_COLOR_WHITE);     
-        BSP_LCD_DisplayStringAt(0, LINE(5), (uint8_t *)"PAGE1", CENTER_MODE);
-        x = TS_State.touchX[0];
-        y = TS_State.touchY[0];
-        if (x<= 237){
-            BSP_LCD_Clear(LCD_COLOR_BLACK); 
-            BSP_LCD_SetBackColor(LCD_COLOR_WHITE);     
-            BSP_LCD_DisplayStringAt(0, LINE(5), (uint8_t *)"BIENVENU", CENTER_MODE);
+        if (TS_State.touchEventId [0] == TOUCH_EVENT_PRESS_DOWN ) {  
+            
+            //LaisseAppuyer = true;
+            x = TS_State.touchX[0];
+            //y = TS_State.touchY[0];
+
+            if (x<= 237) {
+                NumeroPage = NumeroPage - 1;
+                TS_State.touchEventId [0] = 0;
+                //LaisseAppuyer = false;
+
+            } else if (x > 237){
+                NumeroPage =NumeroPage +1;
+                TS_State.touchEventId [0] = 0;
+                //LaisseAppuyer = false;
+            }
+            AfficherPage(NumeroPage);
+            HAL_Delay(temps);
         }
-        else{
-            BSP_LCD_Clear(LCD_COLOR_BLACK); 
-            BSP_LCD_SetBackColor(LCD_COLOR_WHITE);     
-            BSP_LCD_DisplayStringAt(0, LINE(5), (uint8_t *)"PAGE2", CENTER_MODE);         
-            }
-        
-        }
-
-        }
+    
+    }
 }