Code projet_gestion_de_commande_en_ligne
Dependencies: TS_DISCO_F746NG LCD_DISCO_F746NG BSP_DISCO_F746NG BUTTON_GROUP
main.cpp
- Committer:
- azerty000
- Date:
- 2020-06-19
- Revision:
- 1:7e34491bfd01
- Parent:
- 0:735dae6ecacf
- Child:
- 2:e007f6b6e145
File content as of revision 1:7e34491bfd01:
#include "mbed.h" #include "stm32746g_discovery_lcd.h" #include "stm32746g_discovery_ts.h" #include "button_group.hpp" #include "pomme.h" #include "poire.h" #include "orange.h" #include "banane.h" #include "tomate.h" #include "fraise.h" #include "raisin.h" #include "kiwi.h" #include "haricot.h" Serial pc(USBTX, USBRX); // tx, rx using namespace Mikami; TS_DISCO_F746NG ts_; LCD_DISCO_F746NG lcd_; //Pomme void drawImage_pomme(int offsetX, int offsetY) { int x = 0; int y = 0; uint32_t* dataPtr = (uint32_t*)pomme.data; while(y < pomme.height) { while(x < pomme.width) { BSP_LCD_DrawPixel(x + offsetX, y + offsetY, *dataPtr); dataPtr++; x++; } x = 0; y++; } } //Poire void drawImage_poire(int offsetX, int offsetY) { int x = 0; int y = 0; uint32_t* dataPtr = (uint32_t*)poire.data; while(y < poire.height) { while(x < poire.width) { BSP_LCD_DrawPixel(x + offsetX, y + offsetY, *dataPtr); dataPtr++; x++; } x = 0; y++; } } //Orange void drawImage_orange(int offsetX, int offsetY) { int x = 0; int y = 0; uint32_t* dataPtr = (uint32_t*)orange.data; while(y < orange.height) { while(x < orange.width) { BSP_LCD_DrawPixel(x + offsetX, y + offsetY, *dataPtr); dataPtr++; x++; } x = 0; y++; } } //Banane void drawImage_banane(int offsetX, int offsetY) { int x = 0; int y = 0; uint32_t* dataPtr = (uint32_t*)banane.data; while(y < banane.height) { while(x < banane.width) { BSP_LCD_DrawPixel(x + offsetX, y + offsetY, *dataPtr); dataPtr++; x++; } x = 0; y++; } } //Tomate void drawImage_tomate(int offsetX, int offsetY) { int x = 0; int y = 0; uint32_t* dataPtr = (uint32_t*)tomate.data; while(y < tomate.height) { while(x < tomate.width) { BSP_LCD_DrawPixel(x + offsetX, y + offsetY, *dataPtr); dataPtr++; x++; } x = 0; y++; } } //Fraise void drawImage_fraise(int offsetX, int offsetY) { int x = 0; int y = 0; uint32_t* dataPtr = (uint32_t*)fraise.data; while(y < fraise.height) { while(x < fraise.width) { BSP_LCD_DrawPixel(x + offsetX, y + offsetY, *dataPtr); dataPtr++; x++; } x = 0; y++; } } //Raisin void drawImage_raisin(int offsetX, int offsetY) { int x = 0; int y = 0; uint32_t* dataPtr = (uint32_t*)raisin.data; while(y < raisin.height) { while(x < raisin.width) { BSP_LCD_DrawPixel(x + offsetX, y + offsetY, *dataPtr); dataPtr++; x++; } x = 0; y++; } } //Kiwi void drawImage_kiwi(int offsetX, int offsetY) { int x = 0; int y = 0; uint32_t* dataPtr = (uint32_t*)kiwi.data; while(y < kiwi.height) { while(x < kiwi.width) { BSP_LCD_DrawPixel(x + offsetX, y + offsetY, *dataPtr); dataPtr++; x++; } x = 0; y++; } } //Haricot void drawImage_haricot(int offsetX, int offsetY) { int x = 0; int y = 0; uint32_t* dataPtr = (uint32_t*)haricot.data; while(y < haricot.height) { while(x < haricot.width) { BSP_LCD_DrawPixel(x + offsetX, y + offsetY, *dataPtr); dataPtr++; x++; } x = 0; y++; } } int main() { unsigned int boutton_commande = 0; unsigned int boutton_retour = 0; unsigned int boutton_scanner = 0; unsigned int boutton_panier = 0; unsigned int boutton_acceuil = 0; unsigned int boutton_valider = 0; BSP_LCD_Init(); BSP_LCD_LayerDefaultInit(LTDC_ACTIVE_LAYER, LCD_FB_START_ADDRESS); BSP_LCD_SelectLayer(LTDC_ACTIVE_LAYER); while(1) { //Ecran d'acceuil BSP_LCD_Clear(LCD_COLOR_WHITE); BSP_LCD_SetFont(&LCD_DEFAULT_FONT); BSP_LCD_SetBackColor(LCD_COLOR_ORANGE); BSP_LCD_SetTextColor(LCD_COLOR_BLACK); HAL_Delay(1000); BSP_LCD_DisplayStringAt(0, 70, (uint8_t *)"BIENVENUE SUR CEL", CENTER_MODE); HAL_Delay(1000); //Bouton faire une commande Button commande(lcd_, ts_, 88, 160, 300, 50, LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Faire une commande", Font20); commande.Draw(LCD_COLOR_GRAY, LCD_COLOR_BLACK); while(boutton_commande == 0) { if(commande.Touched()) { boutton_commande = 1; } } boutton_commande = 0; //Ecran produits BSP_LCD_Clear(LCD_COLOR_WHITE); HAL_Delay(1000); drawImage_pomme (0,70) ; drawImage_poire (0,130) ; drawImage_orange (0,200) ; drawImage_banane (155,65) ; drawImage_tomate (155,130) ; drawImage_fraise (155,200) ; drawImage_raisin (310,65) ; drawImage_kiwi (317,138) ; drawImage_haricot (310,200) ; //Bouton retour Button retour(lcd_, ts_, 10, 5, 60, 40, LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Retour", Font12); retour.Draw(LCD_COLOR_GRAY, LCD_COLOR_BLACK); //Bouton scanner Button scanner(lcd_, ts_, 200, 5, 60, 40, LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Scanner", Font12); scanner.Draw(LCD_COLOR_GRAY, LCD_COLOR_BLACK); //Bouton panier Button panier(lcd_, ts_, 410, 5, 60, 40, LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Panier", Font12); panier.Draw(LCD_COLOR_GRAY, LCD_COLOR_BLACK); while(boutton_retour == 0 && boutton_scanner == 0 && boutton_panier == 0) { if(retour.Touched()) { boutton_retour = 1; } else if(scanner.Touched()) { boutton_scanner = 1; //Ecran scanner BSP_LCD_Clear(LCD_COLOR_WHITE); BSP_LCD_SetFont(&Font20); BSP_LCD_SetBackColor(LCD_COLOR_ORANGE); BSP_LCD_SetTextColor(LCD_COLOR_BLACK); HAL_Delay(1000); BSP_LCD_DisplayStringAt(0, 40, (uint8_t *)"Scanner le code barre", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 60, (uint8_t *)"du produit", CENTER_MODE); HAL_Delay(1000); BSP_LCD_SetBackColor(LCD_COLOR_RED); BSP_LCD_DisplayStringAt(0, 100, (uint8_t *)"Le produit est :", CENTER_MODE); HAL_Delay(1000); //Bouton retour vers la page d'acceuil Button acceuil(lcd_, ts_, 68, 215, 350, 40, LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Retour vers la page d'acceuil", Font16); acceuil.Draw(LCD_COLOR_GRAY, LCD_COLOR_BLACK); while(boutton_acceuil == 0) { if(acceuil.Touched()) { boutton_acceuil = 1; } } boutton_acceuil = 0; } else if(panier.Touched()) { boutton_panier = 1; //Ecran panier BSP_LCD_Clear(LCD_COLOR_WHITE); HAL_Delay(1000); //Bouton valider la commande Button valider(lcd_, ts_, 88, 215, 300, 40, LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Valider la commande", Font16); valider.Draw(LCD_COLOR_GRAY, LCD_COLOR_BLACK); while(boutton_valider == 0) { if(valider.Touched()) { boutton_valider = 1; } } boutton_valider = 0; //Ecran prix total BSP_LCD_Clear(LCD_COLOR_WHITE); BSP_LCD_SetFont(&LCD_DEFAULT_FONT); BSP_LCD_SetBackColor(LCD_COLOR_ORANGE); BSP_LCD_SetTextColor(LCD_COLOR_BLACK); HAL_Delay(1000); BSP_LCD_DisplayStringAt(0, 70, (uint8_t *)"Prix total", CENTER_MODE); HAL_Delay(1000); BSP_LCD_SetFont(&Font20); BSP_LCD_SetBackColor(LCD_COLOR_RED); BSP_LCD_DisplayStringAt(0, 120, (uint8_t *)"100,00 Euros", CENTER_MODE); HAL_Delay(1000); //Bouton retour vers la page d'acceuil Button acceuil(lcd_, ts_, 68, 215, 350, 40, LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Retour vers la page d'acceuil", Font16); acceuil.Draw(LCD_COLOR_GRAY, LCD_COLOR_BLACK); while(boutton_acceuil == 0) { if(acceuil.Touched()) { boutton_acceuil = 1; } } boutton_acceuil = 0; } } boutton_retour = 0; boutton_scanner = 0; boutton_panier = 0; } }