Code projet_gestion_de_commande_en_ligne
Dependencies: TS_DISCO_F746NG LCD_DISCO_F746NG BSP_DISCO_F746NG BUTTON_GROUP
Diff: main.cpp
- Revision:
- 0:735dae6ecacf
- Child:
- 1:7e34491bfd01
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Jun 18 14:45:26 2020 +0000 @@ -0,0 +1,169 @@ +#include "mbed.h" +#include "stm32746g_discovery_lcd.h" +#include "stm32746g_discovery_ts.h" +#include "button_group.hpp" + +Serial pc(USBTX, USBRX); // tx, rx + +using namespace Mikami; +TS_DISCO_F746NG ts_; +LCD_DISCO_F746NG lcd_; + +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); + + //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; + } +}