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
44
45
48
49
50
51
55
56
57
73
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
104
105
108
109
110
111
112
115
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
173
174
175
176
177
178
179
180
193
194
195
208
209
210
211
212
213
214
215
216
217
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
269
270
271
272
273
274
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
303
304
/* ... */
#include "main.h"
#include "anime.h"
#include "battery_20x35.h"
#include "logo_compo_134x124.h"
#include "icon_camera_60x60.h"
#include "clouds1_124x44.h"
#include "clouds2_124x44.h"
#include "clouds3_124x44.h"
#include "drop_29x35.h"
#include "gauge1_128x126.h"
#include "gauge2_128x126.h"
#include "gauge3_128x126.h"
#include "gyro_36x36.h"
#include "thermo_25x35.h"
#include "bluetooth_30x35.h"
#include "drop_29x35.h"
16 includes
/* ... */
/* ... */
Includes
#define ANIMATION_STATUS_TEXT_POS 30
Private define
static anime_object_t anime_lcd_frame_buffer =
{
(uint32_t *)LCD_FB_START_ADDRESS,
BPP_ARGB8888,
800,
480,
0x00000000,
0,
0
...};
extern DMA2D_HandleTypeDef hdma2d_eval;
Private variables
static void Animation_SetHint(void);
static void anime_draw_object(anime_object_t object, uint16_t pos_x, uint16_t pos_y, uint8_t transparency, anime_object_t buffer);
static void anime_draw_scene(anime_object_t object);
Private function prototypes
/* ... */
static void anime_draw_object(anime_object_t object,
uint16_t pos_x,
uint16_t pos_y,
uint8_t transparency,
anime_object_t buffer)
{
uint32_t bytePerPixel = 0;
if(buffer.bpp == BPP_ARGB8888)
{
bytePerPixel = 4;
}if (buffer.bpp == BPP_ARGB8888) { ... }
else if(buffer.bpp == BPP_RGB888)
{
bytePerPixel = 3;
...}
else if ((buffer.bpp == BPP_RGB565) ||
(buffer.bpp == BPP_ARGB1555) ||
(buffer.bpp == BPP_ARGB4444) ||
(buffer.bpp == BPP_AL88))
{
bytePerPixel = 2;
...}
else if ((buffer.bpp == BPP_L8) ||
(buffer.bpp == BPP_AL44) ||
(buffer.bpp == BPP_A8))
{
bytePerPixel = 1;
}else if ((buffer.bpp == BPP_L8) || (buffer.bpp == BPP_AL44) || (buffer.bpp == BPP_A8)) { ... }
DMA2D->FGMAR = (uint32_t)(object.address);
DMA2D->FGOR = 0x00000000;
if((object.bpp == BPP_ARGB8888) ||
(object.bpp == BPP_ARGB1555) ||
(object.bpp == BPP_ARGB4444) ||
(object.bpp == BPP_AL44) ||
(object.bpp == BPP_AL88) ||
(object.bpp == BPP_A8) ||
(object.bpp == BPP_A4))
{
DMA2D->FGPFCCR = (transparency << 24) + (0x2 << 16) + object.bpp;
}if ((object.bpp == BPP_ARGB8888) || (object.bpp == BPP_ARGB1555) || (object.bpp == BPP_ARGB4444) || (object.bpp == BPP_AL44) || (object.bpp == BPP_AL88) || (object.bpp == BPP_A8) || (object.bpp == BPP_A4)) { ... }
else
{
DMA2D->FGPFCCR = (transparency << 24) + (0x1 << 16) + object.bpp;
}else { ... }
DMA2D->NLR = (object.size_x << 16) + object.size_y;
DMA2D->BGMAR = (uint32_t)buffer.address + (bytePerPixel * ((pos_y * buffer.size_x) + pos_x));
DMA2D->BGOR = buffer.size_x - object.size_x;
DMA2D->BGPFCCR = buffer.bpp;
DMA2D->OMAR = DMA2D->BGMAR;
DMA2D->OOR = DMA2D->BGOR;
DMA2D->OPFCCR = DMA2D->BGPFCCR;
DMA2D->IFCR = 0x3F;
DMA2D->CR = 0x00020001;
while (!DMA2D->ISR);
DMA2D->IFCR = 0x02;
}{ ... }
/* ... */
static void anime_draw_scene(anime_object_t object)
{
anime_draw_object(battery_20x35, 50, 50, 0xFF, object);
anime_draw_object(logo_compo_134x124, 666, 356, 0xFF, object);
anime_draw_object(icon_camera_60x60, 209, 159, 0xFF, object);
gauge1_128x126.animation++;
switch(gauge1_128x126.animation)
{
case 1 :
anime_draw_object(gauge1_128x126, 336, 177, 0xFF, object);
break;case 1 :
case 2 :
anime_draw_object(gauge2_128x126, 336, 177, 0xFF, object);
break;case 2 :
default :
anime_draw_object(gauge3_128x126, 336, 177, 0xFF, object);
gauge1_128x126.animation = 0;
break;default
}switch (gauge1_128x126.animation) { ... }
clouds1_124x44.animation++;
switch(clouds1_124x44.animation)
{
case 1 :
anime_draw_object(clouds1_124x44, 600, 50, 0xFF, object);
break;case 1 :
case 2 :
anime_draw_object(clouds2_124x44, 600, 50, 0xFF, object);
break;case 2 :
default :
anime_draw_object(clouds3_124x44, 600, 50, 0xFF, object);
clouds1_124x44.animation = 0;
break;default
}switch (clouds1_124x44.animation) { ... }
anime_draw_object(drop_29x35, 300, 400, 0xFF, object);
anime_draw_object(thermo_25x35, 340, 400, 0xFF, object);
anime_draw_object(gyro_36x36, 370, 400, 0xFF, object);
anime_draw_object(bluetooth_30x35, 415, 400, 0xFF, object);
}{ ... }
Private functions
/* ... */
void Animation_demo (void)
{
uint32_t exit = 0;
uint32_t entry = 1;
uint32_t initialState = 0;
Animation_SetHint();
while (exit == 0)
{
if(entry == 1)
{
entry = 0;
BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
BSP_LCD_SetTextColor(LCD_COLOR_BLUE);
BSP_LCD_Clear(LCD_COLOR_WHITE);
...}
initialState = BSP_PB_GetState(BUTTON_USER);
BSP_LED_Toggle(LED4);
HAL_Delay(100);
BSP_LED_Toggle(LED2);
HAL_Delay(400);
anime_draw_scene(anime_lcd_frame_buffer);
if(BSP_PB_GetState(BUTTON_USER) != initialState)
{
exit = 1;
}if (BSP_PB_GetState(BUTTON_USER) != initialState) { ... }
}while (exit == 0) { ... }
}{ ... }
/* ... */
static void Animation_SetHint(void)
{
BSP_LCD_Clear(LCD_COLOR_WHITE);
BSP_LCD_SetTextColor(LCD_COLOR_BLUE);
BSP_LCD_FillRect(0, 0, BSP_LCD_GetXSize(), 90);
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
BSP_LCD_SetBackColor(LCD_COLOR_BLUE);
BSP_LCD_SetFont(&Font24);
BSP_LCD_DisplayStringAt(0, 0, (uint8_t *)"ANIMATION EXAMPLE", CENTER_MODE);
BSP_LCD_SetFont(&Font12);
BSP_LCD_DisplayStringAt(0, 30, (uint8_t *)" Press USER button to exit ", CENTER_MODE);
BSP_LCD_SetTextColor(LCD_COLOR_BLUE);
BSP_LCD_DrawRect(10, 100, BSP_LCD_GetXSize() - 20, BSP_LCD_GetYSize() - 110);
BSP_LCD_DrawRect(11, 101, BSP_LCD_GetXSize() - 22, BSP_LCD_GetYSize() - 112);
}{ ... }
/* ... */
/* ... */