Code projet_gestion_de_commande_en_ligne

Dependencies:   TS_DISCO_F746NG LCD_DISCO_F746NG BSP_DISCO_F746NG BUTTON_GROUP

Committer:
darkseb
Date:
Mon Jun 22 15:41:23 2020 +0000
Revision:
2:e007f6b6e145
Parent:
1:7e34491bfd01
Child:
3:5b6f580d3f3a
Code_STM32_projet_gestion_de_commande_en_ligne_V2

Who changed what in which revision?

UserRevisionLine numberNew 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"
azerty000 1:7e34491bfd01 5 #include "pomme.h"
azerty000 1:7e34491bfd01 6 #include "poire.h"
azerty000 1:7e34491bfd01 7 #include "orange.h"
azerty000 1:7e34491bfd01 8 #include "banane.h"
azerty000 1:7e34491bfd01 9 #include "tomate.h"
azerty000 1:7e34491bfd01 10 #include "fraise.h"
azerty000 1:7e34491bfd01 11 #include "raisin.h"
azerty000 1:7e34491bfd01 12 #include "kiwi.h"
azerty000 1:7e34491bfd01 13 #include "haricot.h"
azerty000 1:7e34491bfd01 14
azerty000 1:7e34491bfd01 15
darkseb 0:735dae6ecacf 16 Serial pc(USBTX, USBRX); // tx, rx
darkseb 0:735dae6ecacf 17
darkseb 0:735dae6ecacf 18 using namespace Mikami;
darkseb 0:735dae6ecacf 19 TS_DISCO_F746NG ts_;
darkseb 0:735dae6ecacf 20 LCD_DISCO_F746NG lcd_;
darkseb 0:735dae6ecacf 21
azerty000 1:7e34491bfd01 22
azerty000 1:7e34491bfd01 23 //Pomme
azerty000 1:7e34491bfd01 24 void drawImage_pomme(int offsetX, int offsetY)
azerty000 1:7e34491bfd01 25 {
azerty000 1:7e34491bfd01 26 int x = 0;
azerty000 1:7e34491bfd01 27 int y = 0;
azerty000 1:7e34491bfd01 28 uint32_t* dataPtr = (uint32_t*)pomme.data;
azerty000 1:7e34491bfd01 29 while(y < pomme.height)
azerty000 1:7e34491bfd01 30 {
azerty000 1:7e34491bfd01 31 while(x < pomme.width)
azerty000 1:7e34491bfd01 32 {
azerty000 1:7e34491bfd01 33 BSP_LCD_DrawPixel(x + offsetX, y + offsetY, *dataPtr);
azerty000 1:7e34491bfd01 34 dataPtr++;
azerty000 1:7e34491bfd01 35 x++;
azerty000 1:7e34491bfd01 36 }
azerty000 1:7e34491bfd01 37 x = 0;
azerty000 1:7e34491bfd01 38 y++;
azerty000 1:7e34491bfd01 39 }
azerty000 1:7e34491bfd01 40 }
azerty000 1:7e34491bfd01 41
azerty000 1:7e34491bfd01 42
azerty000 1:7e34491bfd01 43 //Poire
azerty000 1:7e34491bfd01 44 void drawImage_poire(int offsetX, int offsetY)
azerty000 1:7e34491bfd01 45 {
azerty000 1:7e34491bfd01 46 int x = 0;
azerty000 1:7e34491bfd01 47 int y = 0;
azerty000 1:7e34491bfd01 48 uint32_t* dataPtr = (uint32_t*)poire.data;
azerty000 1:7e34491bfd01 49 while(y < poire.height)
azerty000 1:7e34491bfd01 50 {
azerty000 1:7e34491bfd01 51 while(x < poire.width)
azerty000 1:7e34491bfd01 52 {
azerty000 1:7e34491bfd01 53 BSP_LCD_DrawPixel(x + offsetX, y + offsetY, *dataPtr);
azerty000 1:7e34491bfd01 54 dataPtr++;
azerty000 1:7e34491bfd01 55 x++;
azerty000 1:7e34491bfd01 56 }
azerty000 1:7e34491bfd01 57 x = 0;
azerty000 1:7e34491bfd01 58 y++;
azerty000 1:7e34491bfd01 59 }
azerty000 1:7e34491bfd01 60 }
azerty000 1:7e34491bfd01 61
azerty000 1:7e34491bfd01 62 //Orange
azerty000 1:7e34491bfd01 63 void drawImage_orange(int offsetX, int offsetY)
azerty000 1:7e34491bfd01 64 {
azerty000 1:7e34491bfd01 65 int x = 0;
azerty000 1:7e34491bfd01 66 int y = 0;
azerty000 1:7e34491bfd01 67 uint32_t* dataPtr = (uint32_t*)orange.data;
azerty000 1:7e34491bfd01 68 while(y < orange.height)
azerty000 1:7e34491bfd01 69 {
azerty000 1:7e34491bfd01 70 while(x < orange.width)
azerty000 1:7e34491bfd01 71 {
azerty000 1:7e34491bfd01 72 BSP_LCD_DrawPixel(x + offsetX, y + offsetY, *dataPtr);
azerty000 1:7e34491bfd01 73 dataPtr++;
azerty000 1:7e34491bfd01 74 x++;
azerty000 1:7e34491bfd01 75 }
azerty000 1:7e34491bfd01 76 x = 0;
azerty000 1:7e34491bfd01 77 y++;
azerty000 1:7e34491bfd01 78 }
azerty000 1:7e34491bfd01 79 }
azerty000 1:7e34491bfd01 80
azerty000 1:7e34491bfd01 81 //Banane
azerty000 1:7e34491bfd01 82 void drawImage_banane(int offsetX, int offsetY)
azerty000 1:7e34491bfd01 83 {
azerty000 1:7e34491bfd01 84 int x = 0;
azerty000 1:7e34491bfd01 85 int y = 0;
azerty000 1:7e34491bfd01 86 uint32_t* dataPtr = (uint32_t*)banane.data;
azerty000 1:7e34491bfd01 87 while(y < banane.height)
azerty000 1:7e34491bfd01 88 {
azerty000 1:7e34491bfd01 89 while(x < banane.width)
azerty000 1:7e34491bfd01 90 {
azerty000 1:7e34491bfd01 91 BSP_LCD_DrawPixel(x + offsetX, y + offsetY, *dataPtr);
azerty000 1:7e34491bfd01 92 dataPtr++;
azerty000 1:7e34491bfd01 93 x++;
azerty000 1:7e34491bfd01 94 }
azerty000 1:7e34491bfd01 95 x = 0;
azerty000 1:7e34491bfd01 96 y++;
azerty000 1:7e34491bfd01 97 }
azerty000 1:7e34491bfd01 98 }
azerty000 1:7e34491bfd01 99
azerty000 1:7e34491bfd01 100 //Tomate
azerty000 1:7e34491bfd01 101 void drawImage_tomate(int offsetX, int offsetY)
azerty000 1:7e34491bfd01 102 {
azerty000 1:7e34491bfd01 103 int x = 0;
azerty000 1:7e34491bfd01 104 int y = 0;
azerty000 1:7e34491bfd01 105 uint32_t* dataPtr = (uint32_t*)tomate.data;
azerty000 1:7e34491bfd01 106 while(y < tomate.height)
azerty000 1:7e34491bfd01 107 {
azerty000 1:7e34491bfd01 108 while(x < tomate.width)
azerty000 1:7e34491bfd01 109 {
azerty000 1:7e34491bfd01 110 BSP_LCD_DrawPixel(x + offsetX, y + offsetY, *dataPtr);
azerty000 1:7e34491bfd01 111 dataPtr++;
azerty000 1:7e34491bfd01 112 x++;
azerty000 1:7e34491bfd01 113 }
azerty000 1:7e34491bfd01 114 x = 0;
azerty000 1:7e34491bfd01 115 y++;
azerty000 1:7e34491bfd01 116 }
azerty000 1:7e34491bfd01 117 }
azerty000 1:7e34491bfd01 118
azerty000 1:7e34491bfd01 119 //Fraise
azerty000 1:7e34491bfd01 120 void drawImage_fraise(int offsetX, int offsetY)
azerty000 1:7e34491bfd01 121 {
azerty000 1:7e34491bfd01 122 int x = 0;
azerty000 1:7e34491bfd01 123 int y = 0;
azerty000 1:7e34491bfd01 124 uint32_t* dataPtr = (uint32_t*)fraise.data;
azerty000 1:7e34491bfd01 125 while(y < fraise.height)
azerty000 1:7e34491bfd01 126 {
azerty000 1:7e34491bfd01 127 while(x < fraise.width)
azerty000 1:7e34491bfd01 128 {
azerty000 1:7e34491bfd01 129 BSP_LCD_DrawPixel(x + offsetX, y + offsetY, *dataPtr);
azerty000 1:7e34491bfd01 130 dataPtr++;
azerty000 1:7e34491bfd01 131 x++;
azerty000 1:7e34491bfd01 132 }
azerty000 1:7e34491bfd01 133 x = 0;
azerty000 1:7e34491bfd01 134 y++;
azerty000 1:7e34491bfd01 135 }
azerty000 1:7e34491bfd01 136 }
azerty000 1:7e34491bfd01 137
azerty000 1:7e34491bfd01 138 //Raisin
azerty000 1:7e34491bfd01 139 void drawImage_raisin(int offsetX, int offsetY)
azerty000 1:7e34491bfd01 140 {
azerty000 1:7e34491bfd01 141 int x = 0;
azerty000 1:7e34491bfd01 142 int y = 0;
azerty000 1:7e34491bfd01 143 uint32_t* dataPtr = (uint32_t*)raisin.data;
azerty000 1:7e34491bfd01 144 while(y < raisin.height)
azerty000 1:7e34491bfd01 145 {
azerty000 1:7e34491bfd01 146 while(x < raisin.width)
azerty000 1:7e34491bfd01 147 {
azerty000 1:7e34491bfd01 148 BSP_LCD_DrawPixel(x + offsetX, y + offsetY, *dataPtr);
azerty000 1:7e34491bfd01 149 dataPtr++;
azerty000 1:7e34491bfd01 150 x++;
azerty000 1:7e34491bfd01 151 }
azerty000 1:7e34491bfd01 152 x = 0;
azerty000 1:7e34491bfd01 153 y++;
azerty000 1:7e34491bfd01 154 }
azerty000 1:7e34491bfd01 155 }
azerty000 1:7e34491bfd01 156
azerty000 1:7e34491bfd01 157 //Kiwi
azerty000 1:7e34491bfd01 158 void drawImage_kiwi(int offsetX, int offsetY)
azerty000 1:7e34491bfd01 159 {
azerty000 1:7e34491bfd01 160 int x = 0;
azerty000 1:7e34491bfd01 161 int y = 0;
azerty000 1:7e34491bfd01 162 uint32_t* dataPtr = (uint32_t*)kiwi.data;
azerty000 1:7e34491bfd01 163 while(y < kiwi.height)
azerty000 1:7e34491bfd01 164 {
azerty000 1:7e34491bfd01 165 while(x < kiwi.width)
azerty000 1:7e34491bfd01 166 {
azerty000 1:7e34491bfd01 167 BSP_LCD_DrawPixel(x + offsetX, y + offsetY, *dataPtr);
azerty000 1:7e34491bfd01 168 dataPtr++;
azerty000 1:7e34491bfd01 169 x++;
azerty000 1:7e34491bfd01 170 }
azerty000 1:7e34491bfd01 171 x = 0;
azerty000 1:7e34491bfd01 172 y++;
azerty000 1:7e34491bfd01 173 }
azerty000 1:7e34491bfd01 174 }
azerty000 1:7e34491bfd01 175
azerty000 1:7e34491bfd01 176 //Haricot
azerty000 1:7e34491bfd01 177 void drawImage_haricot(int offsetX, int offsetY)
azerty000 1:7e34491bfd01 178 {
azerty000 1:7e34491bfd01 179 int x = 0;
azerty000 1:7e34491bfd01 180 int y = 0;
azerty000 1:7e34491bfd01 181 uint32_t* dataPtr = (uint32_t*)haricot.data;
azerty000 1:7e34491bfd01 182 while(y < haricot.height)
azerty000 1:7e34491bfd01 183 {
azerty000 1:7e34491bfd01 184 while(x < haricot.width)
azerty000 1:7e34491bfd01 185 {
azerty000 1:7e34491bfd01 186 BSP_LCD_DrawPixel(x + offsetX, y + offsetY, *dataPtr);
azerty000 1:7e34491bfd01 187 dataPtr++;
azerty000 1:7e34491bfd01 188 x++;
azerty000 1:7e34491bfd01 189 }
azerty000 1:7e34491bfd01 190 x = 0;
azerty000 1:7e34491bfd01 191 y++;
azerty000 1:7e34491bfd01 192 }
azerty000 1:7e34491bfd01 193 }
azerty000 1:7e34491bfd01 194
azerty000 1:7e34491bfd01 195
darkseb 0:735dae6ecacf 196 int main()
darkseb 0:735dae6ecacf 197 {
darkseb 0:735dae6ecacf 198 unsigned int boutton_commande = 0;
darkseb 0:735dae6ecacf 199 unsigned int boutton_retour = 0;
darkseb 0:735dae6ecacf 200 unsigned int boutton_scanner = 0;
darkseb 0:735dae6ecacf 201 unsigned int boutton_panier = 0;
darkseb 0:735dae6ecacf 202 unsigned int boutton_acceuil = 0;
darkseb 0:735dae6ecacf 203 unsigned int boutton_valider = 0;
darkseb 0:735dae6ecacf 204
darkseb 2:e007f6b6e145 205 unsigned int nb_pommes = 0;
darkseb 2:e007f6b6e145 206 unsigned int nb_poires = 0;
darkseb 2:e007f6b6e145 207 unsigned int nb_oranges = 0;
darkseb 2:e007f6b6e145 208 unsigned int nb_bananes = 0;
darkseb 2:e007f6b6e145 209 unsigned int nb_tomates = 0;
darkseb 2:e007f6b6e145 210 unsigned int nb_fraises = 0;
darkseb 2:e007f6b6e145 211 unsigned int nb_raisins = 0;
darkseb 2:e007f6b6e145 212 unsigned int nb_kiwis = 0;
darkseb 2:e007f6b6e145 213 unsigned int nb_haricots = 0;
darkseb 2:e007f6b6e145 214
darkseb 2:e007f6b6e145 215 char buffer [50] ;
darkseb 2:e007f6b6e145 216
darkseb 0:735dae6ecacf 217 BSP_LCD_Init();
darkseb 0:735dae6ecacf 218 BSP_LCD_LayerDefaultInit(LTDC_ACTIVE_LAYER, LCD_FB_START_ADDRESS);
darkseb 0:735dae6ecacf 219 BSP_LCD_SelectLayer(LTDC_ACTIVE_LAYER);
darkseb 0:735dae6ecacf 220
darkseb 0:735dae6ecacf 221 while(1)
azerty000 1:7e34491bfd01 222 {
azerty000 1:7e34491bfd01 223 //Ecran d'acceuil
darkseb 0:735dae6ecacf 224 BSP_LCD_Clear(LCD_COLOR_WHITE);
darkseb 0:735dae6ecacf 225 BSP_LCD_SetFont(&LCD_DEFAULT_FONT);
darkseb 0:735dae6ecacf 226 BSP_LCD_SetBackColor(LCD_COLOR_ORANGE);
darkseb 0:735dae6ecacf 227 BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
darkseb 0:735dae6ecacf 228 HAL_Delay(1000);
darkseb 0:735dae6ecacf 229
darkseb 0:735dae6ecacf 230 BSP_LCD_DisplayStringAt(0, 70, (uint8_t *)"BIENVENUE SUR CEL", CENTER_MODE);
darkseb 0:735dae6ecacf 231 HAL_Delay(1000);
darkseb 0:735dae6ecacf 232
darkseb 0:735dae6ecacf 233 //Bouton faire une commande
darkseb 0:735dae6ecacf 234 Button commande(lcd_, ts_, 88, 160, 300, 50,
darkseb 0:735dae6ecacf 235 LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Faire une commande", Font20);
darkseb 0:735dae6ecacf 236 commande.Draw(LCD_COLOR_GRAY, LCD_COLOR_BLACK);
darkseb 0:735dae6ecacf 237
darkseb 0:735dae6ecacf 238 while(boutton_commande == 0)
darkseb 0:735dae6ecacf 239 {
darkseb 0:735dae6ecacf 240 if(commande.Touched())
darkseb 0:735dae6ecacf 241 {
darkseb 0:735dae6ecacf 242 boutton_commande = 1;
darkseb 0:735dae6ecacf 243 }
darkseb 0:735dae6ecacf 244 }
darkseb 0:735dae6ecacf 245 boutton_commande = 0;
darkseb 0:735dae6ecacf 246
darkseb 0:735dae6ecacf 247
darkseb 0:735dae6ecacf 248 //Ecran produits
darkseb 0:735dae6ecacf 249 BSP_LCD_Clear(LCD_COLOR_WHITE);
darkseb 0:735dae6ecacf 250 HAL_Delay(1000);
darkseb 0:735dae6ecacf 251
darkseb 2:e007f6b6e145 252 //Images produits
darkseb 2:e007f6b6e145 253 drawImage_pomme (10,45) ;
darkseb 2:e007f6b6e145 254 drawImage_poire (10,130) ;
darkseb 2:e007f6b6e145 255 drawImage_orange (10,200) ;
darkseb 2:e007f6b6e145 256 drawImage_banane (165,35) ;
darkseb 2:e007f6b6e145 257 drawImage_tomate (165,122) ;
darkseb 2:e007f6b6e145 258 drawImage_fraise (165,200) ;
darkseb 2:e007f6b6e145 259 drawImage_raisin (320,35) ;
darkseb 2:e007f6b6e145 260 drawImage_kiwi (330,125) ;
darkseb 2:e007f6b6e145 261 drawImage_haricot (330,205) ;
darkseb 2:e007f6b6e145 262 HAL_Delay(1000);
darkseb 2:e007f6b6e145 263
darkseb 2:e007f6b6e145 264 BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
darkseb 2:e007f6b6e145 265 BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
darkseb 2:e007f6b6e145 266
darkseb 2:e007f6b6e145 267 //Noms produits
darkseb 2:e007f6b6e145 268 BSP_LCD_SetFont(&Font12);
darkseb 2:e007f6b6e145 269 BSP_LCD_DisplayStringAt(350, 55, (uint8_t *)"Pommes", CENTER_MODE);
darkseb 2:e007f6b6e145 270 BSP_LCD_DisplayStringAt(350, 140, (uint8_t *)"Poires", CENTER_MODE);
darkseb 2:e007f6b6e145 271 BSP_LCD_DisplayStringAt(350, 210, (uint8_t *)"Oranges", CENTER_MODE);
darkseb 2:e007f6b6e145 272 BSP_LCD_DisplayStringAt(30, 55, (uint8_t *)"Bananes", CENTER_MODE);
darkseb 2:e007f6b6e145 273 BSP_LCD_DisplayStringAt(30, 140, (uint8_t *)"Tomates", CENTER_MODE);
darkseb 2:e007f6b6e145 274 BSP_LCD_DisplayStringAt(30, 210, (uint8_t *)"Fraises", CENTER_MODE);
darkseb 2:e007f6b6e145 275 BSP_LCD_DisplayStringAt(190, 55, (uint8_t *)"Raisins", CENTER_MODE);
darkseb 2:e007f6b6e145 276 BSP_LCD_DisplayStringAt(190, 140, (uint8_t *)"Kiwis", CENTER_MODE);
darkseb 2:e007f6b6e145 277 BSP_LCD_DisplayStringAt(190, 210, (uint8_t *)"Haricots", CENTER_MODE);
darkseb 2:e007f6b6e145 278 HAL_Delay(1000);
darkseb 2:e007f6b6e145 279
darkseb 2:e007f6b6e145 280 //Prix produits
darkseb 2:e007f6b6e145 281 BSP_LCD_SetFont(&Font8);
darkseb 2:e007f6b6e145 282 BSP_LCD_DisplayStringAt(350, 75, (uint8_t *)"2,20 Euros/kg", CENTER_MODE);
darkseb 2:e007f6b6e145 283 BSP_LCD_DisplayStringAt(350, 160, (uint8_t *)"3,50 Euros/kg", CENTER_MODE);
darkseb 2:e007f6b6e145 284 BSP_LCD_DisplayStringAt(350, 230, (uint8_t *)"2,00 Euros/kg", CENTER_MODE);
darkseb 2:e007f6b6e145 285 BSP_LCD_DisplayStringAt(30, 75, (uint8_t *)"3,00 Euros/kg", CENTER_MODE);
darkseb 2:e007f6b6e145 286 BSP_LCD_DisplayStringAt(30, 160, (uint8_t *)"1,00 Euros/kg", CENTER_MODE);
darkseb 2:e007f6b6e145 287 BSP_LCD_DisplayStringAt(30, 230, (uint8_t *)"4,00 Euros/kg", CENTER_MODE);
darkseb 2:e007f6b6e145 288 BSP_LCD_DisplayStringAt(190, 75, (uint8_t *)"4,20 Euros/kg", CENTER_MODE);
darkseb 2:e007f6b6e145 289 BSP_LCD_DisplayStringAt(190, 160, (uint8_t *)"2,99 Euros/kg", CENTER_MODE);
darkseb 2:e007f6b6e145 290 BSP_LCD_DisplayStringAt(190, 230, (uint8_t *)"1,50 Euros/kg", CENTER_MODE);
darkseb 2:e007f6b6e145 291 HAL_Delay(1000);
darkseb 2:e007f6b6e145 292
darkseb 2:e007f6b6e145 293 //Boutons produits
darkseb 2:e007f6b6e145 294 Button pommes(lcd_, ts_, 15, 93, 130, 20,
darkseb 2:e007f6b6e145 295 LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Ajouter au panier", Font12);
darkseb 2:e007f6b6e145 296 pommes.Draw(LCD_COLOR_ORANGE, LCD_COLOR_BLACK);
darkseb 2:e007f6b6e145 297
darkseb 2:e007f6b6e145 298 Button poires(lcd_, ts_, 15, 175, 130, 20,
darkseb 2:e007f6b6e145 299 LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Ajouter au panier", Font12);
darkseb 2:e007f6b6e145 300 poires.Draw(LCD_COLOR_ORANGE, LCD_COLOR_BLACK);
darkseb 2:e007f6b6e145 301
darkseb 2:e007f6b6e145 302 Button oranges(lcd_, ts_, 15, 248, 130, 20,
darkseb 2:e007f6b6e145 303 LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Ajouter au panier", Font12);
darkseb 2:e007f6b6e145 304 oranges.Draw(LCD_COLOR_ORANGE, LCD_COLOR_BLACK);
darkseb 2:e007f6b6e145 305
darkseb 2:e007f6b6e145 306 Button bananes(lcd_, ts_, 175, 93, 130, 20,
darkseb 2:e007f6b6e145 307 LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Ajouter au panier", Font12);
darkseb 2:e007f6b6e145 308 bananes.Draw(LCD_COLOR_ORANGE, LCD_COLOR_BLACK);
darkseb 2:e007f6b6e145 309
darkseb 2:e007f6b6e145 310 Button tomates(lcd_, ts_, 175, 175, 130, 20,
darkseb 2:e007f6b6e145 311 LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Ajouter au panier", Font12);
darkseb 2:e007f6b6e145 312 tomates.Draw(LCD_COLOR_ORANGE, LCD_COLOR_BLACK);
darkseb 2:e007f6b6e145 313
darkseb 2:e007f6b6e145 314 Button fraises(lcd_, ts_, 175, 248, 130, 20,
darkseb 2:e007f6b6e145 315 LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Ajouter au panier", Font12);
darkseb 2:e007f6b6e145 316 fraises.Draw(LCD_COLOR_ORANGE, LCD_COLOR_BLACK);
darkseb 2:e007f6b6e145 317
darkseb 2:e007f6b6e145 318 Button raisins(lcd_, ts_, 335, 93, 130, 20,
darkseb 2:e007f6b6e145 319 LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Ajouter au panier", Font12);
darkseb 2:e007f6b6e145 320 raisins.Draw(LCD_COLOR_ORANGE, LCD_COLOR_BLACK);
darkseb 2:e007f6b6e145 321
darkseb 2:e007f6b6e145 322 Button kiwis(lcd_, ts_, 335, 175, 130, 20,
darkseb 2:e007f6b6e145 323 LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Ajouter au panier", Font12);
darkseb 2:e007f6b6e145 324 kiwis.Draw(LCD_COLOR_ORANGE, LCD_COLOR_BLACK);
darkseb 2:e007f6b6e145 325
darkseb 2:e007f6b6e145 326 Button haricots(lcd_, ts_, 335, 248, 130, 20,
darkseb 2:e007f6b6e145 327 LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Ajouter au panier", Font12);
darkseb 2:e007f6b6e145 328 haricots.Draw(LCD_COLOR_ORANGE, LCD_COLOR_BLACK);
darkseb 2:e007f6b6e145 329 HAL_Delay(1000);
azerty000 1:7e34491bfd01 330
darkseb 0:735dae6ecacf 331 //Bouton retour
darkseb 2:e007f6b6e145 332 Button retour(lcd_, ts_, 33, 5, 90, 30,
darkseb 2:e007f6b6e145 333 LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Retour", Font16);
darkseb 0:735dae6ecacf 334 retour.Draw(LCD_COLOR_GRAY, LCD_COLOR_BLACK);
darkseb 0:735dae6ecacf 335
darkseb 0:735dae6ecacf 336 //Bouton scanner
darkseb 2:e007f6b6e145 337 Button scanner(lcd_, ts_, 198, 5, 90, 30,
darkseb 2:e007f6b6e145 338 LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Scanner", Font16);
darkseb 0:735dae6ecacf 339 scanner.Draw(LCD_COLOR_GRAY, LCD_COLOR_BLACK);
darkseb 0:735dae6ecacf 340
darkseb 0:735dae6ecacf 341 //Bouton panier
darkseb 2:e007f6b6e145 342 Button panier(lcd_, ts_, 360, 5, 90, 30,
darkseb 2:e007f6b6e145 343 LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Panier", Font16);
darkseb 0:735dae6ecacf 344 panier.Draw(LCD_COLOR_GRAY, LCD_COLOR_BLACK);
darkseb 0:735dae6ecacf 345
darkseb 0:735dae6ecacf 346 while(boutton_retour == 0 && boutton_scanner == 0 && boutton_panier == 0)
darkseb 0:735dae6ecacf 347 {
darkseb 0:735dae6ecacf 348 if(retour.Touched())
darkseb 0:735dae6ecacf 349 {
darkseb 0:735dae6ecacf 350 boutton_retour = 1;
darkseb 2:e007f6b6e145 351 nb_pommes = 0;
darkseb 2:e007f6b6e145 352 nb_poires = 0;
darkseb 2:e007f6b6e145 353 nb_oranges = 0;
darkseb 2:e007f6b6e145 354 nb_bananes = 0;
darkseb 2:e007f6b6e145 355 nb_tomates = 0;
darkseb 2:e007f6b6e145 356 nb_fraises = 0;
darkseb 2:e007f6b6e145 357 nb_raisins = 0;
darkseb 2:e007f6b6e145 358 nb_kiwis = 0;
darkseb 2:e007f6b6e145 359 nb_haricots = 0;
darkseb 0:735dae6ecacf 360 }
darkseb 0:735dae6ecacf 361
darkseb 0:735dae6ecacf 362 else if(scanner.Touched())
darkseb 0:735dae6ecacf 363 {
darkseb 0:735dae6ecacf 364 boutton_scanner = 1;
darkseb 0:735dae6ecacf 365
darkseb 0:735dae6ecacf 366 //Ecran scanner
darkseb 0:735dae6ecacf 367 BSP_LCD_Clear(LCD_COLOR_WHITE);
darkseb 0:735dae6ecacf 368 BSP_LCD_SetFont(&Font20);
darkseb 0:735dae6ecacf 369 BSP_LCD_SetBackColor(LCD_COLOR_ORANGE);
darkseb 0:735dae6ecacf 370 BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
darkseb 0:735dae6ecacf 371 HAL_Delay(1000);
darkseb 0:735dae6ecacf 372
darkseb 0:735dae6ecacf 373 BSP_LCD_DisplayStringAt(0, 40, (uint8_t *)"Scanner le code barre", CENTER_MODE);
darkseb 0:735dae6ecacf 374 BSP_LCD_DisplayStringAt(0, 60, (uint8_t *)"du produit", CENTER_MODE);
darkseb 0:735dae6ecacf 375 HAL_Delay(1000);
darkseb 0:735dae6ecacf 376
darkseb 0:735dae6ecacf 377 BSP_LCD_SetBackColor(LCD_COLOR_RED);
darkseb 0:735dae6ecacf 378 BSP_LCD_DisplayStringAt(0, 100, (uint8_t *)"Le produit est :", CENTER_MODE);
darkseb 0:735dae6ecacf 379 HAL_Delay(1000);
darkseb 0:735dae6ecacf 380
darkseb 0:735dae6ecacf 381 //Bouton retour vers la page d'acceuil
darkseb 0:735dae6ecacf 382 Button acceuil(lcd_, ts_, 68, 215, 350, 40,
darkseb 0:735dae6ecacf 383 LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Retour vers la page d'acceuil", Font16);
darkseb 0:735dae6ecacf 384 acceuil.Draw(LCD_COLOR_GRAY, LCD_COLOR_BLACK);
darkseb 0:735dae6ecacf 385
darkseb 0:735dae6ecacf 386 while(boutton_acceuil == 0)
darkseb 0:735dae6ecacf 387 {
darkseb 0:735dae6ecacf 388 if(acceuil.Touched())
darkseb 0:735dae6ecacf 389 {
darkseb 0:735dae6ecacf 390 boutton_acceuil = 1;
darkseb 0:735dae6ecacf 391 }
darkseb 0:735dae6ecacf 392 }
darkseb 0:735dae6ecacf 393 boutton_acceuil = 0;
darkseb 0:735dae6ecacf 394 }
darkseb 0:735dae6ecacf 395
darkseb 0:735dae6ecacf 396 else if(panier.Touched())
darkseb 0:735dae6ecacf 397 {
darkseb 0:735dae6ecacf 398 boutton_panier = 1;
darkseb 0:735dae6ecacf 399
darkseb 0:735dae6ecacf 400 //Ecran panier
darkseb 0:735dae6ecacf 401 BSP_LCD_Clear(LCD_COLOR_WHITE);
darkseb 0:735dae6ecacf 402 HAL_Delay(1000);
darkseb 0:735dae6ecacf 403
darkseb 2:e007f6b6e145 404 //Images produits
darkseb 2:e007f6b6e145 405 drawImage_pomme (10,15) ;
darkseb 2:e007f6b6e145 406 drawImage_poire (10,100) ;
darkseb 2:e007f6b6e145 407 drawImage_orange (10,170) ;
darkseb 2:e007f6b6e145 408 drawImage_banane (165,5) ;
darkseb 2:e007f6b6e145 409 drawImage_tomate (165,92) ;
darkseb 2:e007f6b6e145 410 drawImage_fraise (165,170) ;
darkseb 2:e007f6b6e145 411 drawImage_raisin (320,5) ;
darkseb 2:e007f6b6e145 412 drawImage_kiwi (330,95) ;
darkseb 2:e007f6b6e145 413 drawImage_haricot (330,175) ;
darkseb 2:e007f6b6e145 414 HAL_Delay(1000);
darkseb 2:e007f6b6e145 415
darkseb 2:e007f6b6e145 416 BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
darkseb 2:e007f6b6e145 417 BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
darkseb 2:e007f6b6e145 418
darkseb 2:e007f6b6e145 419 //Noms produits
darkseb 2:e007f6b6e145 420 BSP_LCD_SetFont(&Font12);
darkseb 2:e007f6b6e145 421 BSP_LCD_DisplayStringAt(350, 25, (uint8_t *)"Pommes", CENTER_MODE);
darkseb 2:e007f6b6e145 422 BSP_LCD_DisplayStringAt(350, 110, (uint8_t *)"Poires", CENTER_MODE);
darkseb 2:e007f6b6e145 423 BSP_LCD_DisplayStringAt(350, 180, (uint8_t *)"Oranges", CENTER_MODE);
darkseb 2:e007f6b6e145 424 BSP_LCD_DisplayStringAt(30, 25, (uint8_t *)"Bananes", CENTER_MODE);
darkseb 2:e007f6b6e145 425 BSP_LCD_DisplayStringAt(30, 110, (uint8_t *)"Tomates", CENTER_MODE);
darkseb 2:e007f6b6e145 426 BSP_LCD_DisplayStringAt(30, 180, (uint8_t *)"Fraises", CENTER_MODE);
darkseb 2:e007f6b6e145 427 BSP_LCD_DisplayStringAt(190, 25, (uint8_t *)"Raisins", CENTER_MODE);
darkseb 2:e007f6b6e145 428 BSP_LCD_DisplayStringAt(190, 110, (uint8_t *)"Kiwis", CENTER_MODE);
darkseb 2:e007f6b6e145 429 BSP_LCD_DisplayStringAt(190, 180, (uint8_t *)"Haricots", CENTER_MODE);
darkseb 2:e007f6b6e145 430 HAL_Delay(1000);
darkseb 2:e007f6b6e145 431
darkseb 2:e007f6b6e145 432 //Prix produits
darkseb 2:e007f6b6e145 433 BSP_LCD_SetFont(&Font8);
darkseb 2:e007f6b6e145 434 BSP_LCD_DisplayStringAt(350, 45, (uint8_t *)"2,20 Euros/kg", CENTER_MODE);
darkseb 2:e007f6b6e145 435 BSP_LCD_DisplayStringAt(350, 130, (uint8_t *)"3,50 Euros/kg", CENTER_MODE);
darkseb 2:e007f6b6e145 436 BSP_LCD_DisplayStringAt(350, 200, (uint8_t *)"2,00 Euros/kg", CENTER_MODE);
darkseb 2:e007f6b6e145 437 BSP_LCD_DisplayStringAt(30, 45, (uint8_t *)"3,00 Euros/kg", CENTER_MODE);
darkseb 2:e007f6b6e145 438 BSP_LCD_DisplayStringAt(30, 130, (uint8_t *)"1,00 Euros/kg", CENTER_MODE);
darkseb 2:e007f6b6e145 439 BSP_LCD_DisplayStringAt(30, 200, (uint8_t *)"4,00 Euros/kg", CENTER_MODE);
darkseb 2:e007f6b6e145 440 BSP_LCD_DisplayStringAt(190, 45, (uint8_t *)"4,20 Euros/kg", CENTER_MODE);
darkseb 2:e007f6b6e145 441 BSP_LCD_DisplayStringAt(190, 130, (uint8_t *)"2,99 Euros/kg", CENTER_MODE);
darkseb 2:e007f6b6e145 442 BSP_LCD_DisplayStringAt(190, 200, (uint8_t *)"1,50 Euros/kg", CENTER_MODE);
darkseb 2:e007f6b6e145 443 HAL_Delay(1000);
darkseb 2:e007f6b6e145 444
darkseb 2:e007f6b6e145 445 //Nombres produits dans panier
darkseb 2:e007f6b6e145 446 BSP_LCD_SetFont(&Font12);
darkseb 2:e007f6b6e145 447 sprintf(buffer, "Nombre : %d", nb_pommes);
darkseb 2:e007f6b6e145 448 BSP_LCD_DisplayStringAt(350, 55, (uint8_t *)buffer, CENTER_MODE);
darkseb 2:e007f6b6e145 449 sprintf(buffer, "Nombre : %d", nb_poires);
darkseb 2:e007f6b6e145 450 BSP_LCD_DisplayStringAt(350, 140, (uint8_t *)buffer, CENTER_MODE);
darkseb 2:e007f6b6e145 451 sprintf(buffer, "Nombre : %d", nb_oranges);
darkseb 2:e007f6b6e145 452 BSP_LCD_DisplayStringAt(350, 210, (uint8_t *)buffer, CENTER_MODE);
darkseb 2:e007f6b6e145 453 sprintf(buffer, "Nombre : %d", nb_bananes);
darkseb 2:e007f6b6e145 454 BSP_LCD_DisplayStringAt(30, 55, (uint8_t *)buffer, CENTER_MODE);
darkseb 2:e007f6b6e145 455 sprintf(buffer, "Nombre : %d", nb_tomates);
darkseb 2:e007f6b6e145 456 BSP_LCD_DisplayStringAt(30, 140, (uint8_t *)buffer, CENTER_MODE);
darkseb 2:e007f6b6e145 457 sprintf(buffer, "Nombre : %d", nb_fraises);
darkseb 2:e007f6b6e145 458 BSP_LCD_DisplayStringAt(30, 210, (uint8_t *)buffer, CENTER_MODE);
darkseb 2:e007f6b6e145 459 sprintf(buffer, "Nombre : %d", nb_raisins);
darkseb 2:e007f6b6e145 460 BSP_LCD_DisplayStringAt(190, 55, (uint8_t *)buffer, CENTER_MODE);
darkseb 2:e007f6b6e145 461 sprintf(buffer, "Nombre : %d", nb_kiwis);
darkseb 2:e007f6b6e145 462 BSP_LCD_DisplayStringAt(190, 140, (uint8_t *)buffer, CENTER_MODE);
darkseb 2:e007f6b6e145 463 sprintf(buffer, "Nombre : %d", nb_haricots);
darkseb 2:e007f6b6e145 464 BSP_LCD_DisplayStringAt(190, 210, (uint8_t *)buffer, CENTER_MODE);
darkseb 2:e007f6b6e145 465 HAL_Delay(1000);
darkseb 2:e007f6b6e145 466
darkseb 0:735dae6ecacf 467 //Bouton valider la commande
darkseb 2:e007f6b6e145 468 Button valider(lcd_, ts_, 88, 225, 300, 40,
darkseb 0:735dae6ecacf 469 LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Valider la commande", Font16);
darkseb 0:735dae6ecacf 470 valider.Draw(LCD_COLOR_GRAY, LCD_COLOR_BLACK);
darkseb 0:735dae6ecacf 471
darkseb 0:735dae6ecacf 472 while(boutton_valider == 0)
darkseb 0:735dae6ecacf 473 {
darkseb 0:735dae6ecacf 474 if(valider.Touched())
darkseb 0:735dae6ecacf 475 {
darkseb 0:735dae6ecacf 476 boutton_valider = 1;
darkseb 0:735dae6ecacf 477 }
darkseb 0:735dae6ecacf 478 }
darkseb 0:735dae6ecacf 479 boutton_valider = 0;
darkseb 0:735dae6ecacf 480
darkseb 0:735dae6ecacf 481
darkseb 0:735dae6ecacf 482 //Ecran prix total
darkseb 0:735dae6ecacf 483 BSP_LCD_Clear(LCD_COLOR_WHITE);
darkseb 0:735dae6ecacf 484 BSP_LCD_SetFont(&LCD_DEFAULT_FONT);
darkseb 0:735dae6ecacf 485 BSP_LCD_SetBackColor(LCD_COLOR_ORANGE);
darkseb 0:735dae6ecacf 486 BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
darkseb 0:735dae6ecacf 487 HAL_Delay(1000);
darkseb 0:735dae6ecacf 488
darkseb 0:735dae6ecacf 489 BSP_LCD_DisplayStringAt(0, 70, (uint8_t *)"Prix total", CENTER_MODE);
darkseb 0:735dae6ecacf 490 HAL_Delay(1000);
darkseb 0:735dae6ecacf 491
darkseb 0:735dae6ecacf 492 BSP_LCD_SetFont(&Font20);
darkseb 0:735dae6ecacf 493 BSP_LCD_SetBackColor(LCD_COLOR_RED);
darkseb 0:735dae6ecacf 494 BSP_LCD_DisplayStringAt(0, 120, (uint8_t *)"100,00 Euros", CENTER_MODE);
darkseb 0:735dae6ecacf 495 HAL_Delay(1000);
darkseb 0:735dae6ecacf 496
darkseb 0:735dae6ecacf 497 //Bouton retour vers la page d'acceuil
darkseb 0:735dae6ecacf 498 Button acceuil(lcd_, ts_, 68, 215, 350, 40,
darkseb 0:735dae6ecacf 499 LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Retour vers la page d'acceuil", Font16);
darkseb 0:735dae6ecacf 500 acceuil.Draw(LCD_COLOR_GRAY, LCD_COLOR_BLACK);
darkseb 0:735dae6ecacf 501
darkseb 0:735dae6ecacf 502 while(boutton_acceuil == 0)
darkseb 0:735dae6ecacf 503 {
darkseb 0:735dae6ecacf 504 if(acceuil.Touched())
darkseb 0:735dae6ecacf 505 {
darkseb 0:735dae6ecacf 506 boutton_acceuil = 1;
darkseb 2:e007f6b6e145 507 nb_pommes = 0;
darkseb 2:e007f6b6e145 508 nb_poires = 0;
darkseb 2:e007f6b6e145 509 nb_oranges = 0;
darkseb 2:e007f6b6e145 510 nb_bananes = 0;
darkseb 2:e007f6b6e145 511 nb_tomates = 0;
darkseb 2:e007f6b6e145 512 nb_fraises = 0;
darkseb 2:e007f6b6e145 513 nb_raisins = 0;
darkseb 2:e007f6b6e145 514 nb_kiwis = 0;
darkseb 2:e007f6b6e145 515 nb_haricots = 0;
darkseb 0:735dae6ecacf 516 }
darkseb 0:735dae6ecacf 517 }
darkseb 0:735dae6ecacf 518 boutton_acceuil = 0;
darkseb 0:735dae6ecacf 519 }
darkseb 2:e007f6b6e145 520
darkseb 2:e007f6b6e145 521 else if(pommes.Touched())
darkseb 2:e007f6b6e145 522 {
darkseb 2:e007f6b6e145 523 nb_pommes = nb_pommes + 1;
darkseb 2:e007f6b6e145 524 }
darkseb 2:e007f6b6e145 525
darkseb 2:e007f6b6e145 526 else if(poires.Touched())
darkseb 2:e007f6b6e145 527 {
darkseb 2:e007f6b6e145 528 nb_poires = nb_poires + 1;
darkseb 2:e007f6b6e145 529 }
darkseb 2:e007f6b6e145 530
darkseb 2:e007f6b6e145 531 else if(oranges.Touched())
darkseb 2:e007f6b6e145 532 {
darkseb 2:e007f6b6e145 533 nb_oranges = nb_oranges + 1;
darkseb 2:e007f6b6e145 534 }
darkseb 2:e007f6b6e145 535
darkseb 2:e007f6b6e145 536 else if(bananes.Touched())
darkseb 2:e007f6b6e145 537 {
darkseb 2:e007f6b6e145 538 nb_bananes = nb_bananes + 1;
darkseb 2:e007f6b6e145 539 }
darkseb 2:e007f6b6e145 540
darkseb 2:e007f6b6e145 541 else if(tomates.Touched())
darkseb 2:e007f6b6e145 542 {
darkseb 2:e007f6b6e145 543 nb_tomates = nb_tomates + 1;
darkseb 2:e007f6b6e145 544 }
darkseb 2:e007f6b6e145 545
darkseb 2:e007f6b6e145 546 else if(fraises.Touched())
darkseb 2:e007f6b6e145 547 {
darkseb 2:e007f6b6e145 548 nb_fraises = nb_fraises + 1;
darkseb 2:e007f6b6e145 549 }
darkseb 2:e007f6b6e145 550
darkseb 2:e007f6b6e145 551 else if(raisins.Touched())
darkseb 2:e007f6b6e145 552 {
darkseb 2:e007f6b6e145 553 nb_raisins = nb_raisins + 1;
darkseb 2:e007f6b6e145 554 }
darkseb 2:e007f6b6e145 555
darkseb 2:e007f6b6e145 556 else if(kiwis.Touched())
darkseb 2:e007f6b6e145 557 {
darkseb 2:e007f6b6e145 558 nb_kiwis = nb_kiwis + 1;
darkseb 2:e007f6b6e145 559 }
darkseb 2:e007f6b6e145 560
darkseb 2:e007f6b6e145 561 else if(haricots.Touched())
darkseb 2:e007f6b6e145 562 {
darkseb 2:e007f6b6e145 563 nb_haricots = nb_haricots + 1;
darkseb 2:e007f6b6e145 564 }
darkseb 0:735dae6ecacf 565 }
darkseb 0:735dae6ecacf 566 boutton_retour = 0;
darkseb 0:735dae6ecacf 567 boutton_scanner = 0;
darkseb 0:735dae6ecacf 568 boutton_panier = 0;
darkseb 0:735dae6ecacf 569 }
darkseb 0:735dae6ecacf 570 }