LAST PUBLISH MATRIX PROJECT

Dependencies:   mbed

Revision:
1:7a7366246b30
Parent:
0:c78ec5cab98d
Child:
2:552c5891b8c5
--- a/main.cpp	Fri Mar 23 13:28:47 2018 +0000
+++ b/main.cpp	Tue Jun 22 11:55:19 2021 +0000
@@ -1,31 +1,30 @@
-/**
- * LED Matrix library for http://www.seeedstudio.com/depot/ultrathin-16x32-red-led-matrix-panel-p-1582.html
- * The LED Matrix panel has 32x16 pixels. Several panel can be combined together as a large screen.
- *
- * Coordinate & Connection (mbed -> panel 0 -> panel 1 -> ...)
- *   (0, 0)                                     (0, 0)
- *     +--------+--------+--------+               +--------+--------+
- *     |   5    |    3   |    1   |               |    1   |    0   |
- *     |        |        |        |               |        |        |<----- mbed
- *     +--------+--------+--------+               +--------+--------+
- *     |   4    |    2   |    0   |                              (64, 16)
- *     |        |        |        |<----- mbed
- *     +--------+--------+--------+
- *                             (96, 32)
- *
- */
-
+////////////// INCLUSION DES LIBRAIRIES (L1-L18)//////////////
 #include "mbed.h"
 #include "LEDMatrix.h"
 #include "smallFont.h"
-
-#define WIDTH   128
-#define HEIGHT  64
+#include "stm32746g_discovery_ts.h"
+#include "stm32746g_discovery_lcd.h"
+#include "fleche.h"
+#include "dessin.h"
+#include "drapeau.h"
+#include "croixbmp.h"
+#include "gommebmp.h"
+#include "allemagnebmp.h"
+#include "belgiquebmp.h"
+#include "beninbmp.h"
+#include "francebmp.h"
+#include "lgbpbmp.h"
+#include "italiebmp.h"
+/////////////////FIN INCLUSION DES LIBRAIRIES/////////////////
 
-BusOut leds(LED1, LED2, LED3, LED4);
+//////DEFINITION LARGEUR ET LONGUEURE DE LECRAN LED (L20-L23)//////
+#define WIDTH   64
+#define HEIGHT  32
+//////// FIN DEFINITION LARGEUR ET LONGUEURE DE LECRAN LED ////////
+
 //stb c'est le latch
-// LEDMatrix(a, b, c, d, oe_1, r3, r4, b3, b4, g3, g4, g1, r1, b1, r2, g2, b2, stb_1, clk_1,);
-LEDMatrix matrix(p12, p13, p14, p15, p18, p25, p23, p24, p21, p26, p22, p9, p8, p10, p7, p11, p6, p17, p16);
+// LEDMatrix    (a, b,  c, d,  oe_1, r1, r2, b1, b2, g1, g2, stb_1, clk_1);
+LEDMatrix matrix(D1,D10,D0,D11,D7,   D5, D3, D4, D2, D8, D9, D12,   D13);
 Ticker scanner;
 
 // Display Buffer
@@ -33,177 +32,712 @@
     0x00
 };
 
-// Instantiation de Led
-DigitalOut Led(LED1);
+
+/////////DEFINITION DES PROTOTYPES (L36-L40)/////////
+void page_accueil(void);
+void page_dessin(void);
+void page_drapeau(void);
+/////////FIN DE DEFINITION DES PROTOTYPES////////////
+
+/////////DEFINITION DES VARIABLES GLOBALES (L42-L46)/////////
+int xb=0, yb=0; // La valeur de x et y correspondante a l'ecran LCD
+uint8_t text[30]; // SPRINTF
+int p=0;// Pour le multicolor
+/////////FIN DE DEFINITION DES VARIABLES GLOBALES ////////////
+
+////////////////DEFINITION DES FONCTIONS DE DESSIN D'IMAGE (L48-L237)/////////////////////
+//fleche
+void drawImage_fleche(int offsetX, int offsetY)
+{
+    int x = 0;
+    int y = 0;
+    uint32_t* dataPtr = (uint32_t*)fleche.data;
+    while(y < fleche.height) {
+        while(x < fleche.width) {
+            BSP_LCD_DrawPixel(x + offsetX, y + offsetY, *dataPtr);
+            dataPtr++;
+            x++;
+        }
+        x = 0;
+        y++;
+    }
+}
 
-// Initialisation de la liaison Bluetooth
-Serial Bluetooth(p28, p27); // tx, rx
+//belgique
+void drawImage_belgique(int offsetX, int offsetY)
+{
+    int x = 0;
+    int y = 0;
+    uint32_t* dataPtr = (uint32_t*)belgiquebmp.data;
+    while(y < belgiquebmp.height) {
+        while(x < belgiquebmp.width) {
+            BSP_LCD_DrawPixel(x + offsetX, y + offsetY, *dataPtr);
+            dataPtr++;
+            x++;
+        }
+        x = 0;
+        y++;
+    }
+}
+
+//allemagne
+void drawImage_allemagne(int offsetX, int offsetY)
+{
+    int x = 0;
+    int y = 0;
+    uint32_t* dataPtr = (uint32_t*)allemagnebmp.data;
+    while(y < allemagnebmp.height) {
+        while(x < allemagnebmp.width) {
+            BSP_LCD_DrawPixel(x + offsetX, y + offsetY, *dataPtr);
+            dataPtr++;
+            x++;
+        }
+        x = 0;
+        y++;
+    }
+}
 
-// 16 * 8 digital font
-const uint8_t digitals[] = {
-    0x00, 0x1C, 0x36, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x00, 0x00, 0x00, 0x00, // 0
-    0x00, 0x18, 0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7E, 0x00, 0x00, 0x00, 0x00, // 1
-    0x00, 0x3E, 0x63, 0x63, 0x63, 0x06, 0x06, 0x0C, 0x18, 0x30, 0x63, 0x7F, 0x00, 0x00, 0x00, 0x00, // 2
-    0x00, 0x3E, 0x63, 0x63, 0x06, 0x1C, 0x06, 0x03, 0x03, 0x63, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, // 3
-    0x00, 0x06, 0x0E, 0x1E, 0x36, 0x36, 0x66, 0x66, 0x7F, 0x06, 0x06, 0x1F, 0x00, 0x00, 0x00, 0x00, // 4
-    0x00, 0x7F, 0x60, 0x60, 0x60, 0x7C, 0x76, 0x03, 0x03, 0x63, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, // 5
-    0x00, 0x1E, 0x36, 0x60, 0x60, 0x7C, 0x76, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x00, 0x00, 0x00, 0x00, // 6
-    0x00, 0x7F, 0x66, 0x66, 0x0C, 0x0C, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, // 7
-    0x00, 0x3E, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x36, 0x63, 0x63, 0x63, 0x3E, 0x00, 0x00, 0x00, 0x00, // 8
-    0x00, 0x1C, 0x36, 0x63, 0x63, 0x63, 0x37, 0x1F, 0x03, 0x03, 0x36, 0x3C, 0x00, 0x00, 0x00, 0x00, // 9
-};
+//benin
+void drawImage_benin(int offsetX, int offsetY)
+{
+    int x = 0;
+    int y = 0;
+    uint32_t* dataPtr = (uint32_t*)beninbmp.data;
+    while(y < beninbmp.height) {
+        while(x < beninbmp.width) {
+            BSP_LCD_DrawPixel(x + offsetX, y + offsetY, *dataPtr);
+            dataPtr++;
+            x++;
+        }
+        x = 0;
+        y++;
+    }
+}
+
+//france
+void drawImage_france(int offsetX, int offsetY)
+{
+    int x = 0;
+    int y = 0;
+    uint32_t* dataPtr = (uint32_t*)francebmp.data;
+    while(y < francebmp.height) {
+        while(x < francebmp.width) {
+            BSP_LCD_DrawPixel(x + offsetX, y + offsetY, *dataPtr);
+            dataPtr++;
+            x++;
+        }
+        x = 0;
+        y++;
+    }
+}
 
-// (x, y) top-left position, x should be multiple of 8
-void drawDigital(uint16_t x, uint16_t y, uint8_t n)
+//italie
+void drawImage_italie(int offsetX, int offsetY)
 {
-    /*    if ((n >= 10) || (0 != (x % 8))) {
-            return;
+    int x = 0;
+    int y = 0;
+    uint32_t* dataPtr = (uint32_t*)italiebmp.data;
+    while(y < italiebmp.height) {
+        while(x < italiebmp.width) {
+            BSP_LCD_DrawPixel(x + offsetX, y + offsetY, *dataPtr);
+            dataPtr++;
+            x++;
         }
+        x = 0;
+        y++;
+    }
+}
 
-        uint8_t *pDst = displaybuf + y * (WIDTH / 8) + x / 8;
-        const uint8_t *pSrc = digitals + n * 16;
-        for (uint8_t i = 0; i < 16; i++) {
-            *pDst = *pSrc;
-            pDst += WIDTH / 8;
-            pSrc++;
-        }*/
+//lgbt
+void drawImage_lgbt(int offsetX, int offsetY)
+{
+    int x = 0;
+    int y = 0;
+    uint32_t* dataPtr = (uint32_t*)lgbpbmp.data;
+    while(y < lgbpbmp.height) {
+        while(x < lgbpbmp.width) {
+            BSP_LCD_DrawPixel(x + offsetX, y + offsetY, *dataPtr);
+            dataPtr++;
+            x++;
+        }
+        x = 0;
+        y++;
+    }
+}
+
+//drapeau
+void drawImage_drapeau(int offsetX, int offsetY)
+{
+    int x = 0;
+    int y = 0;
+    uint32_t* dataPtr = (uint32_t*)drapeau.data;
+    while(y < drapeau.height) {
+        while(x < drapeau.width) {
+            BSP_LCD_DrawPixel(x + offsetX, y + offsetY, *dataPtr);
+            dataPtr++;
+            x++;
+        }
+        x = 0;
+        y++;
+    }
 }
 
 
+//gomme
+void drawImage_gomme(int offsetX, int offsetY)
+{
+    int x = 0;
+    int y = 0;
+    uint32_t* dataPtr = (uint32_t*)gommebmp.data;
+    while(y < gommebmp.height) {
+        while(x < gommebmp.width) {
+            BSP_LCD_DrawPixel(x + offsetX, y + offsetY, *dataPtr);
+            dataPtr++;
+            x++;
+        }
+        x = 0;
+        y++;
+    }
+}
+
+//croix
+void drawImage_croix(int offsetX, int offsetY)
+{
+    int x = 0;
+    int y = 0;
+    uint32_t* dataPtr = (uint32_t*)croixbmp.data;
+    while(y < croixbmp.height) {
+        while(x < croixbmp.width) {
+            BSP_LCD_DrawPixel(x + offsetX, y + offsetY, *dataPtr);
+            dataPtr++;
+            x++;
+        }
+        x = 0;
+        y++;
+    }
+}
+
+
+//dessin
+void drawImage_dessin(int offsetX, int offsetY)
+{
+    int x = 0;
+    int y = 0;
+    uint32_t* dataPtr = (uint32_t*)dessin.data;
+    while(y < dessin.height) {
+        while(x < dessin.width) {
+            BSP_LCD_DrawPixel(x + offsetX, y + offsetY, *dataPtr);
+            dataPtr++;
+            x++;
+        }
+        x = 0;
+        y++;
+    }
+}
+////////////////FIN DEFINITION DES FONCTIONS DE DESSIN D'IMAGE (L48-L237)/////////////////////
+
+
+/// FONCTION DE SCAN DE L'ECRAN LED//////
 void scan()
 {
     matrix.scan();
 }
-
-void setup()
-{
-    // Initialisation Communication et premier message Bluetooth
-    Bluetooth.baud(9600);//vitesse de communication
-    Bluetooth.format(8,SerialBase::None,1);//
-
-    Bluetooth.printf("\r\n Setup OK !! \r\n");
+///FIN FONCTION DE SCAN DE L'ECRAN LED//////
 
-    // Clignotement led
-    Led = 1;
-    wait(1);
-    Led = 0;
-    wait(1);
-    Led = 1;
-} //End setup
-
+///////////////////////// DEBUT DU MAIN (L247-LXXX)////////////////////////////////////////
 int main()
 {
-    setup();
-    int i, j, c=1;
+    TS_StateTypeDef TS_State; // Definition de l'objet qui servira pour la detection de clic sur la STM32
+    
+    
+    //Definition des variables locales au main
+    uint16_t x, y;
+    uint8_t status;
+    uint8_t idx;
+    uint8_t prev_nb_touches = 0;
+    int i,  c=1;
+    int page = 0;
+    int couleur=7;//1 rouge; 2 vert; 3 jaune; 4 bleu; 5 violet; 6 cyan; 7 blanc
+    
+    
+    ////////////////INITIALISATION DE LECRAN DE LA STM32//////////////
+    BSP_LCD_Init();
+    BSP_LCD_LayerDefaultInit(LTDC_ACTIVE_LAYER, LCD_FB_START_ADDRESS);
+    BSP_LCD_SelectLayer(LTDC_ACTIVE_LAYER);
+    //////////////////////////////////////////////////////////////////
+
+
+    status = BSP_TS_Init(BSP_LCD_GetXSize(), BSP_LCD_GetYSize());               // Recupération d'un status
+    if (status != TS_OK) {                                                      // SI LE STATUS N'EST PAS OK L'INIT FAIL
+        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 *)"TOUCHSCREEN INIT FAIL", CENTER_MODE);   
+    } 
+    else {                                                                      // SINON "INITIALISATION S'AFFICHE
+        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 *)"INITIALISATION", CENTER_MODE);        
+    }
+
+    HAL_Delay(500);                         // Delais en ms
+    BSP_LCD_SetFont(&Font12);               // Police d'écriture
+    BSP_LCD_SetBackColor(LCD_COLOR_WHITE);  // Fond blanc
+    BSP_LCD_SetTextColor(LCD_COLOR_BLUE);   // Coleur du texte bleu
     
-    char carac;
-    initFonts();
+    initFonts(); 
+
+    matrix.begin((uint8_t *)displaybuf, WIDTH, HEIGHT);     // Sauv en mémoire la taille de la matrice LED
+    
+    scanner.attach(scan, 0.0005);   //Gère l'affiche sur la matrice LED
+                                    //Un scan trop lent (>0.0009) provoque un effet de scintillement
+                                    //Un scan trop rapide (<0.0001) provoque un effet d'allumage des LEDs qui sont sur la même ligne
+    
+    matrix.clear();        
+    matrix.drawRect(0,0,21,64,4);
+    matrix.drawRect(21,0,43,64,7);
+    matrix.drawRect(43,0,64,64,1);   
+    matrix.swap();
+    while (!matrix.synchro());
+    wait(1);
+    matrix.clear();
+        
+    for (i=200; i>-400; i-=4) 
+        {
+            matrix.clear();
+            matrix.drawCharString(i,0,"MATRICE LED LP SESAM",c,fonts[0]);
+            matrix.drawCharString(i,15,"CARPENTIER ANTOINE",c,fonts[0]);
+            matrix.swap();
+            wait(0.05);
+            while (!matrix.synchro());
+        }
+        matrix.clear();
+        
+        BSP_LCD_Clear(LCD_COLOR_WHITE);
+        
+    while (1) {  
+        
+        BSP_TS_GetState(&TS_State);
+        if (TS_State.touchDetected) 
+        {
+            // Clear lines corresponding to old touches coordinates
+            if (TS_State.touchDetected < prev_nb_touches) 
+            {
+                for (idx = (TS_State.touchDetected + 1); idx <= 5; idx++) 
+                {
+                    BSP_LCD_ClearStringLine(idx);
+                }
+            }
+            prev_nb_touches = TS_State.touchDetected;
+
 
-    matrix.begin((uint8_t *)displaybuf, WIDTH, HEIGHT);
-    scanner.attach(scan, 0.0005);
-
-//defilement point
-    /*    for (i=0; i<64; i++) {
-            for (j=0; j<128; j++) {
-                matrix.clear();
-                matrix.drawPoint(j,i,4);
+           
+            for (idx = 0; idx < TS_State.touchDetected; idx++) 
+            {
+                x = TS_State.touchX[idx];
+                y = TS_State.touchY[idx];
+                xb = x/7.5;
+                yb = y/7.5;
+               
+            }
+        }
+    
+        //VERS PAGE DESSIN
+       if ((page == 0) && (x>= 10 && x<= 235) && (y>= 10 && y<= 235))
+        {
+            x=0;
+            y=272;
+            BSP_LCD_Clear(LCD_COLOR_WHITE);
+            matrix.clear();
+            matrix.swap();
+            while (!matrix.synchro()); 
+            page = 1;
+            HAL_Delay(300);
+            }
+            
+            
+      // VERS DRAPEAU   
+      if ((page==0)&&(x>=245 && x<=470)&&(y>= 10 && y<= 235))
+      {
+        x=0;
+        y=0;
+        BSP_LCD_Clear(LCD_COLOR_WHITE);
+        matrix.clear();
+        matrix.swap();
+        while (!matrix.synchro()); 
+        page = 2;
+        HAL_Delay(100);
+        }
+            
+        if (page == 0)
+        {
+             page_accueil();
+            }
+        
+        else if (page == 2)
+        {
+            page_drapeau();
+                           
+               //HAUT GAUCHE
+                if ((x>= 8 && x<= 236) && (y>= 29 && y<= 103))
+                {
+                    x = 0;
+                    y = 0;
+                    //ALLEMAGNE
+                    matrix.clear();
+                    matrix.drawRect(0,10,64,21,3);
+                    matrix.drawRect(0,21,64,32,1); 
+                    matrix.swap();
+                    while (!matrix.synchro());
+              
+                    }
+                   
+                // HAUT DROITE  
+                else if ((x>= 244 && x<= 472) && (y>= 29 && y<= 103))
+                {
+                     x = 0;
+                     y = 0;
+                    // BELGE
+                    matrix.clear();        
+                    matrix.drawRect(21,0,43,64,3);
+                    matrix.drawRect(43,0,64,64,1);
+                    matrix.swap();
+                    while (!matrix.synchro());
+                   
+                     
+                    }
+                    
+                // MILIEU GAUCHE 
+                else if ((x>= 8 && x<= 236) && (y>= 110 && y<= 184))
+                {
+                    x = 0;
+                    y = 0;
+                    //BENIN
+                    matrix.clear();        
+                    matrix.drawRect(0,0,21,64,2);
+                    matrix.drawRect(21,0,64,16,3);
+                    matrix.drawRect(21,16,64,32,1);  
+                    matrix.swap();
+                    while (!matrix.synchro());
+                    
+                    }
+        
+                // MILIEU DROITE  
+                else if ((x>= 244 && x<= 472) && (y>= 110 && y<= 184))
+                {
+                    x = 0;
+                    y = 0;
+                    //LGBT
+                    matrix.clear();//1 rouge; 2 vert; 3 jaune; 4 bleu; 5 violet; 6 cyan; 7 blanc
+                    matrix.drawRect(0,0,64,4,7);
+                    matrix.drawRect(0,4,64,8,1);
+                    matrix.drawRect(0,8,64,12,3);
+                    matrix.drawRect(0,12,64,16,2);
+                    matrix.drawRect(0,16,64,20,4);
+                    matrix.drawRect(0,20,64,24,6);
+                    matrix.drawRect(0,24,64,28,5);
+                    matrix.drawRect(0,28,64,32,7);
+                    matrix.swap();
+                    while (!matrix.synchro());
+                        
+                    }
+                    
+                // BAS GAUCHE    
+                else if ((x>= 8 && x<= 236) && (y>= 192 && y<= 266))
+                {
+                    x = 0;
+                    y = 0;
+                    //FRANCE
+                    matrix.clear();        
+                    matrix.drawRect(0,0,21,64,4);
+                    matrix.drawRect(21,0,43,64,7);
+                    matrix.drawRect(43,0,64,64,1);    
+                    matrix.swap();
+                    while (!matrix.synchro());
+                    
+                    }
+                    
+                    
+                // BAS DROITE
+                else if ((x>= 244 && x<= 472) && (y>= 192 && y<= 266))
+                {
+                     x = 0;
+                     y = 0;
+                     //ITALIE
+                     matrix.clear();        
+                     matrix.drawRect(0,0,21,64,2);
+                     matrix.drawRect(21,0,43,64,7);
+                     matrix.drawRect(43,0,64,64,1);  
+                     matrix.swap();
+                     while (!matrix.synchro());
+                    }
+                
+                if ((page==2)&&(x>= 458 && x<= 480) && (y>= 0 && y<= 22))
+                {
+                 BSP_LCD_Clear(LCD_COLOR_WHITE);
+                 matrix.clear();
+                 matrix.swap();
+                 while (!matrix.synchro()); 
+                 x = 0;
+                 y = 0;
+                 page = 0;
+                 
+                    }     
+            
+            }
+    
+    
+        else if(page == 1)
+        {     
+         page_dessin();
+        
+         matrix.swap();
+         while (!matrix.synchro());   
+        
+            if (y<241)
+            {
+            
+            
+                if(couleur != 0)
+                {
+                    BSP_LCD_DrawPixel(TS_State.touchX[0], TS_State.touchY[0], LCD_COLOR_ORANGE);
+                    matrix.drawPoint(xb,yb,couleur);
+                    }
+                else
+                {
+                    BSP_LCD_DrawPixel(TS_State.touchX[0], TS_State.touchY[0], LCD_COLOR_WHITE);
+                    BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
+                    BSP_LCD_FillRect(x-7.5,y-7.5,22.5,22.5);
+                    
+                    matrix.drawPoint(xb,yb,couleur);
+                    matrix.drawPoint(xb+1,yb+1,couleur);
+                    matrix.drawPoint(xb-1,yb-1,couleur);
+                    matrix.drawPoint(xb+1,yb-1,couleur);
+                    matrix.drawPoint(xb-1,yb+1,couleur);
+                    matrix.drawPoint(xb-1,yb,couleur);
+                    matrix.drawPoint(xb,yb-1,couleur);
+                    matrix.drawPoint(xb+1,yb,couleur);
+                    matrix.drawPoint(xb,yb+1,couleur);
+                    }
+            
                 matrix.swap();
                 while (!matrix.synchro());
             }
-        }
-        while (1);
-    */
-     /*   while(1) {
-        if(Bluetooth.readable()) // établir la connection
+            
+          
+        if (x<=43 && x>=2 && y<=270 && y>=242 )
         {
-            carac = Bluetooth.getc(); //On stocke le caractère envoyé dans la variable qu'on tape sur l'interface
-
-            switch(carac) {
-
-            case 'A' :
+            p=0;
+            couleur = 1;
+            }
+        
+        if (x<=86 && x>=45 && y<=270 && y>=242 )
+        {
+            p=0;
+            couleur = 2;
+            }
             
-            for (i=138; i>-180; i-=2) {
-                matrix.clear();
-                matrix.drawCharString(i,5,"Le meilleur ",c,fonts[1]);
-                matrix.swap();
-                wait(0.05);
-                while (!matrix.synchro());
-                }
-            c++;
-            if (c==8) c=1;
-            break;
+        if (x<=129 && x>=88 && y<=270 && y>=242 )
+        {
+            p=0;
+            couleur = 4;
+            }
+        
+        if (x<=172 && x>=131 && y<=270 && y>=242 )
+        {
+            p=0;
+            couleur = 5;
+            }
+        
+        if (x<=215 && x>=174 && y<=270 && y>=242 )
+        {
+            p=0;
+            couleur = 6;
+            }
+        
+        if (x<=258 && x>=217 && y<=270 && y>=242 )
+        {
+            p=0;
+            couleur = 3;
+            }
             
-            case 'B' :
+        if (x<=301 && x>=260 && y<=270 && y>=242 )
+        {
+            p=0;
+            couleur = 7;
+            }
+            
+        if (x<=344 && x>=303 && y<=270 && y>=242 )
+        {
+            p=1;      
+            }
+    
+        // GOMME
+        if (x<=396 && x>=355 && y<=267 && y>=254 )
+        {
+            p=0;
+            couleur = 0;
+            }
             
-            for (i=138; i>-180; i-=2) {
-                matrix.clear();
-                matrix.drawCharString(i,5,"IUT Cachan ",c,fonts[1]);
-                matrix.swap();
-                wait(0.05);
-                while (!matrix.synchro());
-                    }
-            c++;
-            if (c==8) c=1;
-            break;
-                }
+        // EFFACE TOUT
+        if (x<=438 && x>=410 && y<=267 && y>=254 )
+        {
+            x=0;
+            y=0;
+            BSP_LCD_Clear(LCD_COLOR_WHITE);
+            matrix.clear();
+            }
+            
+         if ((x>= 458 && x<= 480) && (y>= 240 && y<= 270))
+             {
+             BSP_LCD_Clear(LCD_COLOR_WHITE);
+             matrix.clear();
+             matrix.swap();
+             while (!matrix.synchro()); 
+             x = 0;
+             y = 0;
+             page = 0;
+             }
+             
+        
+        //MULTICOLOR   
+        if (p==1)
+        {
+            
+            if (x<68 && y<91)couleur=7;
+            if (x>=68 && x<136 && y<91)couleur=6;
+            if (x>=136 && x<204 && y<91)couleur=5;
+            if (x>=204 && x<272 && y<91)couleur=3;
+            if (x>=272 && x<340 && y<91)couleur=4;
+            if (x>=340 && x<408 && y<91)couleur=2;
+            if (x>=408 && x<480 && y<91)couleur=1;   
+            
+            if (x<68   && y<91)couleur=1;
+            if (x>=68  && x<136 && y<181 && y>90)couleur=2;
+            if (x>=136 && x<204 && y<181 && y>90)couleur=3;
+            if (x>=204 && x<272 && y<181 && y>90)couleur=4;
+            if (x>=272 && x<340 && y<181 && y>90)couleur=5;
+            if (x>=340 && x<408 && y<181 && y>90)couleur=6;
+            if (x>=408 && x<480 && y<181 && y>90)couleur=7;  
+            
+            if (x<68   && y<91)couleur=5;
+            if (x>=68  && x<136 && y>180)couleur=7;
+            if (x>=136 && x<204 && y>180)couleur=2;
+            if (x>=204 && x<272 && y>180)couleur=4;
+            if (x>=272 && x<340 && y>180)couleur=1;
+            if (x>=340 && x<408 && y>180)couleur=3;
+            if (x>=408 && x<480 && y>180)couleur=6;  
+           
         }
-    } // end while */
-
-//    matrix.clear();
-
-    uint8_t count = 0;
+    }//FIN IF PAGE == 1 
+    
+    
+    
+    
+    }// FIN WHILE
+    
 
-  //France
-        matrix.drawRect(0,0,21,64,4);
-        matrix.drawRect(21,0,43,64,7);
-        matrix.drawRect(43,0,64,64,1);
-        matrix.drawCharString(78,0,"3",7,fonts[2]);       
-        matrix.swap();
-        while (!matrix.synchro());
-        wait(1);
-        matrix.clear();
-         matrix.drawRect(0,0,21,64,4);
-        matrix.drawRect(21,0,43,64,7);
-        matrix.drawRect(43,0,64,64,1);
-        matrix.drawCharString(78,0,"2",7,fonts[2]);       
-        matrix.swap();
-        while (!matrix.synchro());
-        wait(1);
-        matrix.clear();        
-         matrix.drawRect(0,0,21,64,4);
-        matrix.drawRect(21,0,43,64,7);
-        matrix.drawRect(43,0,64,64,1);
-        matrix.drawCharString(78,0,"1",7,fonts[2]);       
-        matrix.swap();
-        while (!matrix.synchro());
-        wait(1);
-        
-        
-    while (1) {
+}// FIN MAIN
+///////////////////////// FIN DU MAIN (L247-L691)////////////////////////////////////////
 
 
 
-      
-        
-         for (i=200; i>-400; i-=4) {
-                matrix.clear();
-                matrix.drawCharString(i,0,"Comment est votre blanquette ? ",c,fonts[1]);
-                matrix.drawCharString(i,32,"              ma blanquette est bonne ",c,fonts[1]);
-                matrix.swap();
-                wait(0.05);
-                while (!matrix.synchro());
-                }
-            c++;
-            if (c==8) c=1;
+
+
+
+
+
 
-      //  for (i=64; i>-192; i--) {
+//////////////////// FONCTIONS PAGES (L700-L773) ///////////////////////////////////////////////////////
+void page_accueil()
+{
+    BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
+    BSP_LCD_DrawRect(10, 10, 225, 225);   //Bouton dessin 
+    BSP_LCD_DrawRect(245, 10, 225, 225);   //Bouton drapeau
+    
+    sprintf((char*)text, "DESSIN");
+    BSP_LCD_DisplayStringAt(95, LINE(20), (uint8_t *)&text, LEFT_MODE);
+    drawImage_dessin(15,15);
+    
+    sprintf((char*)text,"DRAPEAU");
+    BSP_LCD_DisplayStringAt(120, LINE(20), (uint8_t *)&text, CENTER_MODE);    
+    drawImage_drapeau(250, 15);      
+    }
+    
     
-    // matrix.drawChar(0,0,'A',2,fonts[0]);
-    //matrix.drawChar(10,0,'A',2,fonts[1]);
-    //matrix.drawChar(20,0,'A',3,fonts[2]);
-
+void page_dessin()
+{
+    // ROUGE
+        BSP_LCD_SetTextColor(LCD_COLOR_RED);
+        BSP_LCD_FillRect(2,242,41, 28);
+        //VERT
+        BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
+        BSP_LCD_FillRect(45,242,41, 28);
+        //BLEU
+        BSP_LCD_SetTextColor(LCD_COLOR_BLUE);
+        BSP_LCD_FillRect(88,242,41, 28);
+        //VIOLET
+        BSP_LCD_SetTextColor(LCD_COLOR_MAGENTA);
+        BSP_LCD_FillRect(131,242,41, 28);
+        //CYAN
+        BSP_LCD_SetTextColor(LCD_COLOR_CYAN);
+        BSP_LCD_FillRect(174,242,41, 28);
+        //JAUNE
+        BSP_LCD_SetTextColor(LCD_COLOR_YELLOW);
+        BSP_LCD_FillRect(217,242,41, 28);
+        //BLANC
+        BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
+        BSP_LCD_DrawRect(260, 242, 41, 28);
+        //MULTICOLOR
+        BSP_LCD_SetTextColor(LCD_COLOR_RED);
+        BSP_LCD_FillRect(303,242,10, 28);
+        BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
+        BSP_LCD_FillRect(314,242,10, 28);
+        BSP_LCD_SetTextColor(LCD_COLOR_YELLOW);
+        BSP_LCD_FillRect(325,242,10, 28);
+        BSP_LCD_SetTextColor(LCD_COLOR_CYAN);
+        BSP_LCD_FillRect(336,242,10, 28);
+         
+        drawImage_gomme(355,245); //GOMME
+        drawImage_croix(410,243); //EFFACER TOUT
+        drawImage_fleche(445,245); // Retour
+                
+        BSP_LCD_SetTextColor(LCD_COLOR_BLACK);  
+        BSP_LCD_DrawHLine(0,240,480);        
     }
 
-}
+void page_drapeau()
+{          
+                                        // Au dessus 22px de la barre + 7//
+   /* 8px */ BSP_LCD_DrawRect(8, 29, 228, 74);    /* 8px */    BSP_LCD_DrawRect(244, 29, 228, 74);  /* 8px */
+             drawImage_allemagne(10,31);          /* 7px */    drawImage_belgique (246,31);
+             
+   /* 8px */ BSP_LCD_DrawRect(8, 110, 228, 74);   /* 8px */    BSP_LCD_DrawRect(244, 110, 228, 74); /* 8px */
+             drawImage_benin    (10,111);         /* 7px */    drawImage_lgbt     (246,111);
+                                                  
+   /* 8px */ BSP_LCD_DrawRect(8, 191, 228, 73);   /* 8px */    BSP_LCD_DrawRect(244, 191, 228, 73); /* 8px */
+             drawImage_france   (10,192);                      drawImage_italie   (246,192);
+                                              
+    drawImage_fleche(447,0);// RETOUR
+    
+    }
+//////////////////// FIN DES FONCTIONS PAGES (L693-L766) ///////////////////////////////////////////////////////
 
- 
\ No newline at end of file
+
+
+
+
+        
+       
+       
+
+
+
+
+
+
+
+
+
+