Code projet_gestion_de_commande_en_ligne
Dependencies: TS_DISCO_F746NG LCD_DISCO_F746NG BSP_DISCO_F746NG BUTTON_GROUP
main.cpp@0:735dae6ecacf, 2020-06-18 (annotated)
- Committer:
- darkseb
- Date:
- Thu Jun 18 14:45:26 2020 +0000
- Revision:
- 0:735dae6ecacf
- Child:
- 1:7e34491bfd01
test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
darkseb | 0:735dae6ecacf | 1 | #include "mbed.h" |
darkseb | 0:735dae6ecacf | 2 | #include "stm32746g_discovery_lcd.h" |
darkseb | 0:735dae6ecacf | 3 | #include "stm32746g_discovery_ts.h" |
darkseb | 0:735dae6ecacf | 4 | #include "button_group.hpp" |
darkseb | 0:735dae6ecacf | 5 | |
darkseb | 0:735dae6ecacf | 6 | Serial pc(USBTX, USBRX); // tx, rx |
darkseb | 0:735dae6ecacf | 7 | |
darkseb | 0:735dae6ecacf | 8 | using namespace Mikami; |
darkseb | 0:735dae6ecacf | 9 | TS_DISCO_F746NG ts_; |
darkseb | 0:735dae6ecacf | 10 | LCD_DISCO_F746NG lcd_; |
darkseb | 0:735dae6ecacf | 11 | |
darkseb | 0:735dae6ecacf | 12 | int main() |
darkseb | 0:735dae6ecacf | 13 | { |
darkseb | 0:735dae6ecacf | 14 | unsigned int boutton_commande = 0; |
darkseb | 0:735dae6ecacf | 15 | unsigned int boutton_retour = 0; |
darkseb | 0:735dae6ecacf | 16 | unsigned int boutton_scanner = 0; |
darkseb | 0:735dae6ecacf | 17 | unsigned int boutton_panier = 0; |
darkseb | 0:735dae6ecacf | 18 | unsigned int boutton_acceuil = 0; |
darkseb | 0:735dae6ecacf | 19 | unsigned int boutton_valider = 0; |
darkseb | 0:735dae6ecacf | 20 | |
darkseb | 0:735dae6ecacf | 21 | BSP_LCD_Init(); |
darkseb | 0:735dae6ecacf | 22 | BSP_LCD_LayerDefaultInit(LTDC_ACTIVE_LAYER, LCD_FB_START_ADDRESS); |
darkseb | 0:735dae6ecacf | 23 | BSP_LCD_SelectLayer(LTDC_ACTIVE_LAYER); |
darkseb | 0:735dae6ecacf | 24 | |
darkseb | 0:735dae6ecacf | 25 | while(1) |
darkseb | 0:735dae6ecacf | 26 | { |
darkseb | 0:735dae6ecacf | 27 | //Ecran d'acceuil |
darkseb | 0:735dae6ecacf | 28 | BSP_LCD_Clear(LCD_COLOR_WHITE); |
darkseb | 0:735dae6ecacf | 29 | BSP_LCD_SetFont(&LCD_DEFAULT_FONT); |
darkseb | 0:735dae6ecacf | 30 | BSP_LCD_SetBackColor(LCD_COLOR_ORANGE); |
darkseb | 0:735dae6ecacf | 31 | BSP_LCD_SetTextColor(LCD_COLOR_BLACK); |
darkseb | 0:735dae6ecacf | 32 | HAL_Delay(1000); |
darkseb | 0:735dae6ecacf | 33 | |
darkseb | 0:735dae6ecacf | 34 | BSP_LCD_DisplayStringAt(0, 70, (uint8_t *)"BIENVENUE SUR CEL", CENTER_MODE); |
darkseb | 0:735dae6ecacf | 35 | HAL_Delay(1000); |
darkseb | 0:735dae6ecacf | 36 | |
darkseb | 0:735dae6ecacf | 37 | //Bouton faire une commande |
darkseb | 0:735dae6ecacf | 38 | Button commande(lcd_, ts_, 88, 160, 300, 50, |
darkseb | 0:735dae6ecacf | 39 | LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Faire une commande", Font20); |
darkseb | 0:735dae6ecacf | 40 | commande.Draw(LCD_COLOR_GRAY, LCD_COLOR_BLACK); |
darkseb | 0:735dae6ecacf | 41 | |
darkseb | 0:735dae6ecacf | 42 | while(boutton_commande == 0) |
darkseb | 0:735dae6ecacf | 43 | { |
darkseb | 0:735dae6ecacf | 44 | if(commande.Touched()) |
darkseb | 0:735dae6ecacf | 45 | { |
darkseb | 0:735dae6ecacf | 46 | boutton_commande = 1; |
darkseb | 0:735dae6ecacf | 47 | } |
darkseb | 0:735dae6ecacf | 48 | } |
darkseb | 0:735dae6ecacf | 49 | boutton_commande = 0; |
darkseb | 0:735dae6ecacf | 50 | |
darkseb | 0:735dae6ecacf | 51 | |
darkseb | 0:735dae6ecacf | 52 | //Ecran produits |
darkseb | 0:735dae6ecacf | 53 | BSP_LCD_Clear(LCD_COLOR_WHITE); |
darkseb | 0:735dae6ecacf | 54 | HAL_Delay(1000); |
darkseb | 0:735dae6ecacf | 55 | |
darkseb | 0:735dae6ecacf | 56 | //Bouton retour |
darkseb | 0:735dae6ecacf | 57 | Button retour(lcd_, ts_, 10, 5, 60, 40, |
darkseb | 0:735dae6ecacf | 58 | LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Retour", Font12); |
darkseb | 0:735dae6ecacf | 59 | retour.Draw(LCD_COLOR_GRAY, LCD_COLOR_BLACK); |
darkseb | 0:735dae6ecacf | 60 | |
darkseb | 0:735dae6ecacf | 61 | //Bouton scanner |
darkseb | 0:735dae6ecacf | 62 | Button scanner(lcd_, ts_, 200, 5, 60, 40, |
darkseb | 0:735dae6ecacf | 63 | LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Scanner", Font12); |
darkseb | 0:735dae6ecacf | 64 | scanner.Draw(LCD_COLOR_GRAY, LCD_COLOR_BLACK); |
darkseb | 0:735dae6ecacf | 65 | |
darkseb | 0:735dae6ecacf | 66 | //Bouton panier |
darkseb | 0:735dae6ecacf | 67 | Button panier(lcd_, ts_, 410, 5, 60, 40, |
darkseb | 0:735dae6ecacf | 68 | LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Panier", Font12); |
darkseb | 0:735dae6ecacf | 69 | panier.Draw(LCD_COLOR_GRAY, LCD_COLOR_BLACK); |
darkseb | 0:735dae6ecacf | 70 | |
darkseb | 0:735dae6ecacf | 71 | while(boutton_retour == 0 && boutton_scanner == 0 && boutton_panier == 0) |
darkseb | 0:735dae6ecacf | 72 | { |
darkseb | 0:735dae6ecacf | 73 | if(retour.Touched()) |
darkseb | 0:735dae6ecacf | 74 | { |
darkseb | 0:735dae6ecacf | 75 | boutton_retour = 1; |
darkseb | 0:735dae6ecacf | 76 | } |
darkseb | 0:735dae6ecacf | 77 | |
darkseb | 0:735dae6ecacf | 78 | else if(scanner.Touched()) |
darkseb | 0:735dae6ecacf | 79 | { |
darkseb | 0:735dae6ecacf | 80 | boutton_scanner = 1; |
darkseb | 0:735dae6ecacf | 81 | |
darkseb | 0:735dae6ecacf | 82 | //Ecran scanner |
darkseb | 0:735dae6ecacf | 83 | BSP_LCD_Clear(LCD_COLOR_WHITE); |
darkseb | 0:735dae6ecacf | 84 | BSP_LCD_SetFont(&Font20); |
darkseb | 0:735dae6ecacf | 85 | BSP_LCD_SetBackColor(LCD_COLOR_ORANGE); |
darkseb | 0:735dae6ecacf | 86 | BSP_LCD_SetTextColor(LCD_COLOR_BLACK); |
darkseb | 0:735dae6ecacf | 87 | HAL_Delay(1000); |
darkseb | 0:735dae6ecacf | 88 | |
darkseb | 0:735dae6ecacf | 89 | BSP_LCD_DisplayStringAt(0, 40, (uint8_t *)"Scanner le code barre", CENTER_MODE); |
darkseb | 0:735dae6ecacf | 90 | BSP_LCD_DisplayStringAt(0, 60, (uint8_t *)"du produit", CENTER_MODE); |
darkseb | 0:735dae6ecacf | 91 | HAL_Delay(1000); |
darkseb | 0:735dae6ecacf | 92 | |
darkseb | 0:735dae6ecacf | 93 | BSP_LCD_SetBackColor(LCD_COLOR_RED); |
darkseb | 0:735dae6ecacf | 94 | BSP_LCD_DisplayStringAt(0, 100, (uint8_t *)"Le produit est :", CENTER_MODE); |
darkseb | 0:735dae6ecacf | 95 | HAL_Delay(1000); |
darkseb | 0:735dae6ecacf | 96 | |
darkseb | 0:735dae6ecacf | 97 | //Bouton retour vers la page d'acceuil |
darkseb | 0:735dae6ecacf | 98 | Button acceuil(lcd_, ts_, 68, 215, 350, 40, |
darkseb | 0:735dae6ecacf | 99 | LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Retour vers la page d'acceuil", Font16); |
darkseb | 0:735dae6ecacf | 100 | acceuil.Draw(LCD_COLOR_GRAY, LCD_COLOR_BLACK); |
darkseb | 0:735dae6ecacf | 101 | |
darkseb | 0:735dae6ecacf | 102 | while(boutton_acceuil == 0) |
darkseb | 0:735dae6ecacf | 103 | { |
darkseb | 0:735dae6ecacf | 104 | if(acceuil.Touched()) |
darkseb | 0:735dae6ecacf | 105 | { |
darkseb | 0:735dae6ecacf | 106 | boutton_acceuil = 1; |
darkseb | 0:735dae6ecacf | 107 | } |
darkseb | 0:735dae6ecacf | 108 | } |
darkseb | 0:735dae6ecacf | 109 | boutton_acceuil = 0; |
darkseb | 0:735dae6ecacf | 110 | } |
darkseb | 0:735dae6ecacf | 111 | |
darkseb | 0:735dae6ecacf | 112 | else if(panier.Touched()) |
darkseb | 0:735dae6ecacf | 113 | { |
darkseb | 0:735dae6ecacf | 114 | boutton_panier = 1; |
darkseb | 0:735dae6ecacf | 115 | |
darkseb | 0:735dae6ecacf | 116 | //Ecran panier |
darkseb | 0:735dae6ecacf | 117 | BSP_LCD_Clear(LCD_COLOR_WHITE); |
darkseb | 0:735dae6ecacf | 118 | HAL_Delay(1000); |
darkseb | 0:735dae6ecacf | 119 | |
darkseb | 0:735dae6ecacf | 120 | //Bouton valider la commande |
darkseb | 0:735dae6ecacf | 121 | Button valider(lcd_, ts_, 88, 215, 300, 40, |
darkseb | 0:735dae6ecacf | 122 | LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Valider la commande", Font16); |
darkseb | 0:735dae6ecacf | 123 | valider.Draw(LCD_COLOR_GRAY, LCD_COLOR_BLACK); |
darkseb | 0:735dae6ecacf | 124 | |
darkseb | 0:735dae6ecacf | 125 | while(boutton_valider == 0) |
darkseb | 0:735dae6ecacf | 126 | { |
darkseb | 0:735dae6ecacf | 127 | if(valider.Touched()) |
darkseb | 0:735dae6ecacf | 128 | { |
darkseb | 0:735dae6ecacf | 129 | boutton_valider = 1; |
darkseb | 0:735dae6ecacf | 130 | } |
darkseb | 0:735dae6ecacf | 131 | } |
darkseb | 0:735dae6ecacf | 132 | boutton_valider = 0; |
darkseb | 0:735dae6ecacf | 133 | |
darkseb | 0:735dae6ecacf | 134 | |
darkseb | 0:735dae6ecacf | 135 | //Ecran prix total |
darkseb | 0:735dae6ecacf | 136 | BSP_LCD_Clear(LCD_COLOR_WHITE); |
darkseb | 0:735dae6ecacf | 137 | BSP_LCD_SetFont(&LCD_DEFAULT_FONT); |
darkseb | 0:735dae6ecacf | 138 | BSP_LCD_SetBackColor(LCD_COLOR_ORANGE); |
darkseb | 0:735dae6ecacf | 139 | BSP_LCD_SetTextColor(LCD_COLOR_BLACK); |
darkseb | 0:735dae6ecacf | 140 | HAL_Delay(1000); |
darkseb | 0:735dae6ecacf | 141 | |
darkseb | 0:735dae6ecacf | 142 | BSP_LCD_DisplayStringAt(0, 70, (uint8_t *)"Prix total", CENTER_MODE); |
darkseb | 0:735dae6ecacf | 143 | HAL_Delay(1000); |
darkseb | 0:735dae6ecacf | 144 | |
darkseb | 0:735dae6ecacf | 145 | BSP_LCD_SetFont(&Font20); |
darkseb | 0:735dae6ecacf | 146 | BSP_LCD_SetBackColor(LCD_COLOR_RED); |
darkseb | 0:735dae6ecacf | 147 | BSP_LCD_DisplayStringAt(0, 120, (uint8_t *)"100,00 Euros", CENTER_MODE); |
darkseb | 0:735dae6ecacf | 148 | HAL_Delay(1000); |
darkseb | 0:735dae6ecacf | 149 | |
darkseb | 0:735dae6ecacf | 150 | //Bouton retour vers la page d'acceuil |
darkseb | 0:735dae6ecacf | 151 | Button acceuil(lcd_, ts_, 68, 215, 350, 40, |
darkseb | 0:735dae6ecacf | 152 | LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Retour vers la page d'acceuil", Font16); |
darkseb | 0:735dae6ecacf | 153 | acceuil.Draw(LCD_COLOR_GRAY, LCD_COLOR_BLACK); |
darkseb | 0:735dae6ecacf | 154 | |
darkseb | 0:735dae6ecacf | 155 | while(boutton_acceuil == 0) |
darkseb | 0:735dae6ecacf | 156 | { |
darkseb | 0:735dae6ecacf | 157 | if(acceuil.Touched()) |
darkseb | 0:735dae6ecacf | 158 | { |
darkseb | 0:735dae6ecacf | 159 | boutton_acceuil = 1; |
darkseb | 0:735dae6ecacf | 160 | } |
darkseb | 0:735dae6ecacf | 161 | } |
darkseb | 0:735dae6ecacf | 162 | boutton_acceuil = 0; |
darkseb | 0:735dae6ecacf | 163 | } |
darkseb | 0:735dae6ecacf | 164 | } |
darkseb | 0:735dae6ecacf | 165 | boutton_retour = 0; |
darkseb | 0:735dae6ecacf | 166 | boutton_scanner = 0; |
darkseb | 0:735dae6ecacf | 167 | boutton_panier = 0; |
darkseb | 0:735dae6ecacf | 168 | } |
darkseb | 0:735dae6ecacf | 169 | } |