Select one of the symbols to view example projects that use it.
 
Outline
Includes
#include <string.h>
#include "GUI_Private.h"
#include "village.c"
#include "sun.c"
#include "sun_rain.c"
#include "moon.c"
Private define
#define FADE_PERIOD
Private variables
BITMAP_ITEM
_aBitmapItem
_PaintMemdev(int, int, int, GUI_MEMDEV_Handle, GUI_MEMDEV_Handle)
_MakeString(int, int, int, char *)
_DrawResult(int, int, int, int, int)
MainTask()
Files
loading...
SourceVuSTM32 Libraries and SamplesSTemWin_AccelerationSTemWin/App/acceleration_app.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/** ****************************************************************************** * @file acceleration_app.c * @author MCD Application Team * @brief This file provides main GUI application program functions ****************************************************************************** * @attention * * Copyright (c) 2017 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** *//* ... */ /* Includes ------------------------------------------------------------------*/ #include <string.h> #include "GUI_Private.h" /* Bitmap generated resources */ #include "village.c" #include "sun.c" #include "sun_rain.c" #include "moon.c" 6 includes Includes/* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ #define FADE_PERIOD 750 Private define /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ typedef struct { const GUI_BITMAP * pBitmap; ...} BITMAP_ITEM; static const BITMAP_ITEM _aBitmapItem[] = { {&bmsun}, {&bmsun_rain}, {&bmmoon}, ...}; Private variables /* Private function prototypes -----------------------------------------------*/ void MainTask(void); /** * @brief Function that will draw on the Memory device * @param index : Plan index * @param xSize : Plan horizontal size * @param ySize : Plan vertical size * @param hPicture: Picture memory device to use * @param hMemWork: Target memory device * @retval None *//* ... */ static void _PaintMemdev(int index, int xSize, int ySize, GUI_MEMDEV_Handle hPicture, GUI_MEMDEV_Handle hMemWork) { int Color = 0xFF3691c6; /* Select the picture memory device */ GUI_MEMDEV_Select(hPicture); /* First set a transparent Background */ GUI_SetBkColor(GUI_TRANSPARENT); GUI_Clear(); /* Then draw the picture on it */ GUI_DrawBitmap(_aBitmapItem[index].pBitmap, (_aBitmapItem[0].pBitmap->XSize - _aBitmapItem[index].pBitmap->XSize)/2, (_aBitmapItem[0].pBitmap->YSize - _aBitmapItem[index].pBitmap->YSize)/2); /* Select the memory device to be paint */ GUI_MEMDEV_Select(hMemWork); switch(index) { case 0: /* Sunny sky */ Color = 0xFF3691c6; break;case 0: case 1: /* Rainy sky */ Color = 0xFF1b558a; break;case 1: case 2: /* Night sky */ Color = 0xFF0b3153; break;case 2: default: break;default }switch (index) { ... } /* Fill the screen using the needed color */ GUI_SetColor(Color); GUI_FillRect(0, 0, (xSize - 1), (ySize - 1)); GUI_DrawBitmap(&bmvillage, 0, (ySize - bmvillage.YSize)); /* Picture to display */ GUI_MEMDEV_WriteAt(hPicture, 20, 20); /* Select the display, once all draws are done */ GUI_MEMDEV_Select(0); }{ ... } /** * @brief Function to modify a value to a given print format * @param value : value to format * @param NumDecs : Decimal part to display * @param Shift : Shifted part to display * @param acBuffer: String to be used for the display * @retval None *//* ... */ static void _MakeString(int value, int NumDecs, int Shift, char * acBuffer) { int i; int a; int s; acBuffer[NumDecs--] = '0' + (a = value) % 10; for (i = 1, s = 1; i <= NumDecs; i++) { if (i == Shift) { acBuffer[NumDecs - i + s] = '.'; s = 0; }if (i == Shift) { ... } acBuffer[NumDecs - i + s] = '0' + (a /= 10) % 10; }for (i = 1, s = 1; i <= NumDecs; i++) { ... } }{ ... } /** * @brief Function to display the performance results * @param xSize : Plan horizontal size * @param ySize : Plan vertical size * @param ResultDrawing: Drawing performance result * @param ResultFading : Fading performance result * @param ResultTotal : Total = (Drawing and Fading) performance result * @retval None *//* ... */ static void _DrawResult(int xSize, int ySize, int ResultDrawing, int ResultFading, int ResultTotal) { const char acDrawing[] = "Drawing: "; const char acFading [] = "Fading: "; const char acTotal [] = "Total: "; const char * apString[3]; char acValue[7] = {0}; int * apValues[3]; unsigned i; int xMid; int yMid; int ySizeFont; int ySizeTotal; int xPosText; int yPosText; int xSizeText; int xSizeLabel; int xSizeValue; int xSizeTotal; apString[0] = acDrawing; apString[1] = acFading; apString[2] = acTotal; apValues[0] = &ResultDrawing; apValues[1] = &ResultFading; apValues[2] = &ResultTotal; /* Set the font to be used */ GUI_SetFont(GUI_FONT_20B_ASCII); /* Calculate position on the display screen */ xMid = xSize / 2; yMid = ySize / 2; ySizeFont = GUI_GetFontSizeY(); ySizeTotal = 4 * ySizeFont + 2 * 10; yPosText = (yMid - ySizeTotal / 2) / 2; for (i = xSizeLabel = 0; i < GUI_COUNTOF(apString); i++ ) { xSizeText = GUI_GetStringDistX(apString[i]); if (xSizeLabel < xSizeText) { xSizeLabel = xSizeText; }if (xSizeLabel < xSizeText) { ... } }for (i = xSizeLabel = 0; i < GUI_COUNTOF(apString); i++) { ... } xSizeValue = GUI_GetStringDistX("00.000"); xSizeTotal = xSizeLabel + xSizeValue; xPosText = xMid - xSizeTotal / 2; /* Display the title */ GUI_SetColor(GUI_BLACK); GUI_SetTextAlign(GUI_TA_HCENTER); ySizeFont = GUI_GetFontDistY(); GUI_DispStringHCenterAt("Performance Vs Accelerations", xSize / 2, (ySize - ySizeFont * 3) / 4); /* Draw different results */ GUI_SetBkColor(0xFF3691c6); GUI_SetColor(GUI_WHITE); GUI_SetTextMode(GUI_TM_TRANS); GUI_Clear(); GUI_DispStringHCenterAt("Result [MPixels/s]:", xMid, yPosText); GUI_SetTextAlign(GUI_TA_LEFT); for (i = 0; i < GUI_COUNTOF(apString); i++ ) { GUI_DispStringAt(apString[i], xPosText, yPosText + (i + 1) * ySizeFont + 10); }for (i = 0; i < GUI_COUNTOF(apString); i++) { ... } for (i = 0; i < GUI_COUNTOF(apString); i++ ) { _MakeString(*apValues[i], 5, 3, acValue); GUI_DispStringAt(acValue, xPosText + xSizeLabel, yPosText + (i + 1) * ySizeFont + 10); }for (i = 0; i < GUI_COUNTOF(apString); i++) { ... } }{ ... } /** * @brief Main application * @param None * @retval None *//* ... */ void MainTask(void) { GUI_MEMDEV_Handle ahMem[2]; GUI_MEMDEV_Handle hPicture; int xSize; int ySize; unsigned i; int j; int TimeStart; int TimeNow; int Cnt; int ResultFading; int ResultDrawing; int ResultTotal; static int k = 0; static int f = 0; /* First get the sizes of the screen used */ xSize = LCD_GetXSize(); ySize = LCD_GetYSize(); /* Create Picture device*/ hPicture = GUI_MEMDEV_CreateFixed(0, 0, _aBitmapItem[0].pBitmap->XSize, _aBitmapItem[0].pBitmap->YSize, GUI_MEMDEV_NOTRANS, GUI_MEMDEV_APILIST_32, GUICC_M8888I); /* Exit in case of an error */ if(hPicture == 0) return; /* Create screen devices */ for(i = 0; i < GUI_COUNTOF(ahMem); i++) { ahMem[i] = GUI_MEMDEV_CreateFixed(0, 0, xSize, ySize, GUI_MEMDEV_NOTRANS, GUI_MEMDEV_APILIST_32, GUICC_M8888I); if(ahMem[i] == 0) return; else { /* Paint the needed bitmaps on the MemDevs */ _PaintMemdev(k++, xSize, ySize, hPicture, ahMem[i]); }else { ... } }for (i = 0; i < GUI_COUNTOF(ahMem); i++) { ... } /* Select the display screen */ GUI_MEMDEV_Select(0); /* Animation loop */ while (1) { /* Show fading */ for (j = 0; j < 3; j++) { for (i = 0; i < 3; i++) { /* Do the different Fades */ GUI_MEMDEV_FadeDevices(ahMem[f ^ 1], ahMem[f], FADE_PERIOD); /* Paint the needed bitmaps on the MemDevs */ _PaintMemdev((k++)%3, xSize, ySize, hPicture, ahMem[f]); f++; if(f == 2) f = 0; }for (i = 0; i < 3; i++) { ... } }for (j = 0; j < 3; j++) { ... } k = 0; /* Use the latest displayed screen */ GUI_MEMDEV_CopyFromLCD(ahMem[0]); /* Measure the drawing performance achieved */ TimeStart = GUI_GetTime(); Cnt = 0; do { GUI_MEMDEV_Write(ahMem[0]); TimeNow = GUI_GetTime(); Cnt++; ...} while (TimeNow < (TimeStart + 1000)); ResultDrawing = (xSize * ySize * Cnt) / (TimeNow - TimeStart); /* Measure the total performance */ TimeStart = GUI_GetTime(); Cnt = 0; do { GUI_MEMDEV__FadeDevice(ahMem[0], ahMem[0], ahMem[0], Cnt & 0xff); GUI_MEMDEV_Write(ahMem[1]); TimeNow = GUI_GetTime(); Cnt++; ...} while (TimeNow < (TimeStart + 1000)); ResultTotal = (xSize * ySize * Cnt) / (TimeNow - TimeStart); /* Measure the fading performance */ TimeStart = GUI_GetTime(); Cnt = 0; do { GUI_MEMDEV__FadeDevice(ahMem[0], ahMem[0], ahMem[0], Cnt & 0xff); TimeNow = GUI_GetTime(); Cnt++; ...} while (TimeNow < (TimeStart + 1000)); ResultFading = (xSize * ySize * Cnt) / (TimeNow - TimeStart); /* Draw different results */ GUI_MEMDEV_Select(ahMem[1]); _DrawResult(xSize, ySize, ResultDrawing, ResultFading, ResultTotal); GUI_MEMDEV_Select(0); GUI_MEMDEV_FadeDevices(ahMem[1], ahMem[0], FADE_PERIOD); GUI_Delay(3000); for(i = 0; i < GUI_COUNTOF(ahMem); i++) { /* Paint the needed bitmaps on the MemDevs */ _PaintMemdev(k++, xSize, ySize, hPicture, ahMem[i]); }for (i = 0; i < GUI_COUNTOF(ahMem); i++) { ... } }while (1) { ... } }{ ... }
Details