
Fin de projet
Dependencies: mbed BSP_DISCO_F746NG
Diff: fonctions.cpp
- Revision:
- 5:50ae659e47c1
- Parent:
- 4:8f6e0ef3fffe
--- a/fonctions.cpp Wed Nov 11 15:27:24 2020 +0000 +++ b/fonctions.cpp Sun Nov 15 16:17:43 2020 +0000 @@ -1,84 +1,121 @@ #include "fonctions.h" -void Affiche_Ingredients(int TAB_ingredients[]){ +void Affiche_Ingredients(int TAB_ingredients[]) +{ int i=0; BSP_LCD_SetTextColor(LCD_COLOR_BLACK); - for(i=0; i<3; i++){ + 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++){ + } + 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; - } - return false; - } - +} -void AfficheImage(uint32_t Xpos, uint32_t Ypos, uint32_t Largeur, uint32_t Hauteur, const unsigned long *img){ - - uint8_t i=0; - uint8_t j=0; - for (i=0; i<=Hauteur; i++){ - for (j=0; j<= Largeur; j++){ - - BSP_LCD_DrawPixel(Xpos + j, Ypos + i, img[j + i*Largeur] + 0xFF000000); //j + i*Largeur - } +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; } - } - -void Page_Recette() -{ - - BSP_LCD_SetBackColor(LCD_COLOR_WHITE); - BSP_LCD_SetTextColor(LCD_COLOR_BLACK); - BSP_LCD_DisplayStringAt(0, LINE(5), (uint8_t *)"Recettes", CENTER_MODE); + return false; } +void AfficheImage(uint32_t Xpos, uint32_t Ypos, uint32_t Largeur, uint32_t Hauteur, const unsigned long *img) +{ + + uint8_t i=0; + uint8_t j=0; + for (i=0; i<=Hauteur; i++) { + for (j=0; j<= Largeur; j++) { + + BSP_LCD_DrawPixel(Xpos + j, Ypos + i, img[j + i*Largeur] + 0xFF000000); //j + i*Largeur + } + } +} + +void Page_Recette(int TAB_ingredients[]) +{ + BSP_LCD_Clear(LCD_COLOR_WHITE); + BSP_LCD_SetFont(&Font12); + AfficheImage(0,0,160,31,image10); + AfficheImage(160,0,160,31,image11); + AfficheImage(320,0,160,31,image10); + if((TAB_ingredients[0] >= 1) && (TAB_ingredients[1] >= 2) && (TAB_ingredients[3] >= 1) && (TAB_ingredients[5] >= 1)){ + AfficheImage(150,32,163,27,imageCarbo); + BSP_LCD_DisplayStringAt(0,80, (uint8_t *)"1/ Faire cuire les pates dans une grande casserole d'eau salee.", LEFT_MODE); + BSP_LCD_DisplayStringAt(0,90, (uint8_t *)"2/ Pendant ce temps, casser les oeufs dans un recipient, melanger.", LEFT_MODE); + BSP_LCD_DisplayStringAt(0,100, (uint8_t *)"3/ Faire cuire les lardons.", LEFT_MODE); + BSP_LCD_DisplayStringAt(0,110, (uint8_t *)"4/ Une fois les pates cuites, les egoutter, mais pas trop", LEFT_MODE); + BSP_LCD_DisplayStringAt(0,120, (uint8_t *)"5/ Ajouter les lardons, avec leur jus de cuisson, porter a feu doux.", LEFT_MODE); + BSP_LCD_DisplayStringAt(0,130, (uint8_t *)"6/ Ajouter la preparation (oeuf, parmesan) en remuant sans arret.", LEFT_MODE); + BSP_LCD_DisplayStringAt(0,140, (uint8_t *)"7/ Eteindre le feu avant que la preparation devienne trop seche !", LEFT_MODE); + BSP_LCD_DisplayStringAt(0,150, (uint8_t *)"8/ Servir chaud, avec un peu de parmesan rape en plus.", LEFT_MODE); + AfficheImage(150,170,190,99,Carbo); + } + else if((TAB_ingredients[2] >= 2) && (TAB_ingredients[4] >= 1) && (TAB_ingredients[0] >= 1)){ + AfficheImage(150,32,196,30,imageBolo); + BSP_LCD_DisplayStringAt(0,80, (uint8_t *)"1/ Faire cuire le boeuf dans une casserole assez grande.", LEFT_MODE); + BSP_LCD_DisplayStringAt(0,90, (uint8_t *)"2/ Remuez de facon a ce que la viande ne fasse pas de gros paquets.", LEFT_MODE); + BSP_LCD_DisplayStringAt(0,100, (uint8_t *)"3/ Ajoutez les tomates prealablement coupees assez grossierement.", LEFT_MODE); + BSP_LCD_DisplayStringAt(0,110, (uint8_t *)"4/ Laissez mijoter a couvert 1h", LEFT_MODE); + BSP_LCD_DisplayStringAt(0,120, (uint8_t *)"5/ Faites cuire les spaghettis, puis mettez-les dans un plat.", LEFT_MODE); + BSP_LCD_DisplayStringAt(0,130, (uint8_t *)"6/ Ajoutez la sauce bolognaise.", LEFT_MODE); + AfficheImage(150,150,190,99,Bolo); + } + else{ + BSP_LCD_SetFont(&Font20); + + BSP_LCD_DisplayStringAt(20,40, (uint8_t *)"Aucune recette disponible...", LEFT_MODE); + AfficheImage(20,80,160,160,imageENSEA); + AfficheImage(190,170,200,49,imageMarmiton); + } + BSP_LCD_SetFont(&Font20); +} void Page_Ingredients() { AfficheImage(0,0,160,90,image1); AfficheImage(160,0,160,90,image2); AfficheImage(320,0,160,90,image3); - + AfficheImage(0,90,160,90,image4); AfficheImage(160,90,160,90,image5); AfficheImage(320,90,160,90,image6); - + AfficheImage(0,180,160,90,image7); AfficheImage(160,180,160,90,image8); AfficheImage(320,180,160,90,image9); - - + + } -void AfficherPage(int NumeroPage) +void AfficherPage(int NumeroPage, int TAB_ingredients[]) { - if(NumeroPage==0){ + if(NumeroPage==0) { Page_Ingredients(); - } - else if(NumeroPage == 1){ - Page_Recette(); - } + } else if(NumeroPage == 1) { + Page_Recette(TAB_ingredients); + } } -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 +void Page_Acceuil(){ + BSP_LCD_Clear(0xFFc62a5b); + BSP_LCD_SetBackColor(0xFFc62a5b); + AfficheImage(20,60,160,160,imageENSEA); + int i =0; + HAL_Delay(1000); + for(i=0; i<5; i++){ + BSP_LCD_DisplayStringAt(240+i*10,60, (uint8_t *)".", LEFT_MODE); + HAL_Delay(1000); + } + BSP_LCD_DisplayStringAt(240,100, (uint8_t *)"Bienvenue.", LEFT_MODE); + HAL_Delay(2000); + }