1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
31
32
33
34
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
95
96
97
98
99
100
101
102
108
109
110
111
112
113
114
115
116
117
118
119
120
121
125
126
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
150
151
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
177
178
179
185
186
191
192
193
194
195
196
201
202
203
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
229
230
231
236
241
246
251
256
261
266
271
276
281
286
291
292
293
294
295
296
297
298
299
300
305
306
307
312
317
322
327
331
332
333
334
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
544
545
546
547
548
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
586
597
598
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
636
640
641
642
643
644
646
647
648
653
654
655
656
657
658
659
660
661
662
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
709
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
769
770
771
772
776
777
778
779
780
781
782
783
784
785
789
790
791
792
793
794
795
796
797
798
799
809
810
811
/* ... */
#include "main.h"
#include "color.h"
#include "save.h"
/* ... */
/* ... */
Includes
typedef struct
{
uint16_t bfType;
uint32_t bfSize;
uint16_t bfReserved1;
uint16_t bfReserved2;
uint32_t bOffBits;
uint16_t Padding;
...} BitMapFileHeader_Typedef;
typedef struct
{
uint32_t biSize;
uint32_t biWidth;
uint32_t biHeight;
uint16_t biPlanes;
uint16_t biBitCount;
uint32_t biCompression;
uint32_t biSizeImage;
uint32_t biXPelsPerMeter;
uint32_t biYPelsPerMeter;
uint32_t biClrUsed;
uint32_t biClrImportant;
...} BitMapFileInfoHeader_Typedef;
Private typedef
FATFS SDFatFs;
FIL MyFile;
char SDPath[4];
static uint8_t buffer[_MAX_SS];
static BitMapFileHeader_Typedef bmpFileHeader;
static BitMapFileInfoHeader_Typedef bmpFileInfoHeader;
static uint8_t * p_bmp_converted_pixel_data = (uint8_t *)CONVERTED_FRAME_BUFFER;
static uint32_t Radius = 10;
TS_StateTypeDef TS_State = {0};
extern LTDC_HandleTypeDef hltdc_eval;Private variables
static void Draw_Menu(void);
static void GetPosition(void);
static void SystemClock_Config(void);
static void Error_Handler(void);
static void Save_Picture(void);
static void LTDC_Operation(uint32_t Enable_LTDC);
static void Prepare_Picture(void);
static void Update_Color(void);
static void Update_Size(uint8_t size);
Private function prototypes
/* ... */
int main(void)
{
uint8_t lcd_status = LCD_OK;
uint32_t ts_status = TS_OK;
p_bmp_converted_pixel_data = (uint8_t *)CONVERTED_FRAME_BUFFER;
/* ... */
HAL_Init();
SystemClock_Config();
BSP_IO_Init();
BSP_LED_Init(LED1);
BSP_LED_Init(LED3);
/* ... */
/* ... */
BSP_LCD_Init();
while(lcd_status != LCD_OK);
BSP_LCD_LayerDefaultInit(0, LCD_FB_START_ADDRESS);
BSP_LCD_Clear(LCD_COLOR_WHITE);
BSP_TS_ResetTouchData(&TS_State);
if(TouchScreen_IsCalibrationDone() == 0)
{
ts_status = Touchscreen_Calibration();
if(ts_status == TS_OK)
{
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 65, (uint8_t *)"Touchscreen calibration success.", CENTER_MODE);
}if (ts_status == TS_OK) { ... }
}if (TouchScreen_IsCalibrationDone() == 0) { ... }
/* ... */
BSP_CAMERA_PwrDown();
BSP_LCD_Clear(LCD_COLOR_WHITE);
BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
BSP_LCD_SetFont(&Font12);
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize()/2 - 27, (uint8_t*)"Please WAIT few seconds", CENTER_MODE);
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize()/2 - 12, (uint8_t*)"Creating FAT file system on SD card", CENTER_MODE);
if(FATFS_LinkDriver(&SD_Driver, SDPath) != 0)
{
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize()/2 + 3, (uint8_t*)"FAT FS Error !!", CENTER_MODE);
Error_Handler();
}if (FATFS_LinkDriver(&SD_Driver, SDPath) != 0) { ... }
if(f_mount(&SDFatFs, (TCHAR const*)SDPath, 0) != FR_OK)
{
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize()/2 + 3, (uint8_t*)"FAT FS Error !!", CENTER_MODE);
Error_Handler();
}if (f_mount(&SDFatFs, (TCHAR const*)SDPath, 0) != FR_OK) { ... }
if(f_mkfs((TCHAR const*)SDPath, FM_ANY, 0, buffer, sizeof(buffer)) != FR_OK)
{
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize()/2 + 3, (uint8_t*)"FAT FS Error !!", CENTER_MODE);
Error_Handler();
}if (f_mkfs((TCHAR const*)SDPath, FM_ANY, 0, buffer, sizeof(buffer)) != FR_OK) { ... }
Draw_Menu();
while (1)
{
GetPosition();
}while (1) { ... }
}{ ... }
/* ... */
static void GetPosition(void)
{
static uint32_t color_width;
static uint32_t color;
uint16_t x, y;
color_width = 35;
BSP_TS_GetState(&TS_State);
if(TS_State.touchDetected)
{
x = TouchScreen_Get_Calibrated_X(TS_State.touchX[0]);
y = TouchScreen_Get_Calibrated_Y(TS_State.touchY[0]);
if((x > (90 + Radius)) & (y > (7 + Radius) ) & ( x < (BSP_LCD_GetXSize() - (7 + Radius ))) & (y < (BSP_LCD_GetYSize() - (95 + Radius ))))
{
BSP_LCD_FillCircle((x), (y), Radius);
}if ((x > (90 + Radius)) & (y > (7 + Radius) ) & ( x < (BSP_LCD_GetXSize() - (7 + Radius ))) & (y < (BSP_LCD_GetYSize() - (95 + Radius )))) { ... }
else if((x > 0 ) & ( x < 90 ))
{
if((y > 0 ) & (y < color_width ))
{
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
Update_Size(Radius);
}if ((y > 0 ) & (y < color_width )) { ... }
else if((y > color_width ) & (y < (2 * color_width)))
{
BSP_LCD_SetTextColor(LCD_COLOR_YELLOW);
Update_Size(Radius);
}else if ((y > color_width ) & (y < (2 * color_width))) { ... }
else if((y > (2 * color_width)) & (y < (3 * color_width)))
{
BSP_LCD_SetTextColor(LCD_COLOR_ORANGE);
Update_Size(Radius);
}else if ((y > (2 * color_width)) & (y < (3 * color_width))) { ... }
else if((y > (3 * color_width)) & (y < (4 * color_width)))
{
BSP_LCD_SetTextColor(LCD_COLOR_LIGHTMAGENTA);
Update_Size(Radius);
}else if ((y > (3 * color_width)) & (y < (4 * color_width))) { ... }
else if((y > (4 * color_width)) & (y < (5 * color_width)))
{
BSP_LCD_SetTextColor(LCD_COLOR_DARKGREEN);
Update_Size(Radius);
}else if ((y > (4 * color_width)) & (y < (5 * color_width))) { ... }
else if((y > (5 * color_width)) &(y < (6 * color_width)))
{
BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
Update_Size(Radius);
}else if ((y > (5 * color_width)) &(y < (6 * color_width))) { ... }
else if((y > (6 * color_width)) &(y < (7 * color_width)))
{
BSP_LCD_SetTextColor(LCD_COLOR_BROWN);
Update_Size(Radius);
}else if ((y > (6 * color_width)) &(y < (7 * color_width))) { ... }
else if((y > (7 * color_width)) & (y < (8 * color_width)))
{
BSP_LCD_SetTextColor(LCD_COLOR_RED);
Update_Size(Radius);
}else if ((y > (7 * color_width)) & (y < (8 * color_width))) { ... }
else if((y > (8 * color_width)) & (y < (9 * color_width)))
{
BSP_LCD_SetTextColor(LCD_COLOR_DARKMAGENTA);
Update_Size(Radius);
}else if ((y > (8 * color_width)) & (y < (9 * color_width))) { ... }
else if((y > (9 * color_width)) & (y < (10 * color_width)))
{
BSP_LCD_SetTextColor(LCD_COLOR_CYAN);
Update_Size(Radius);
}else if ((y > (9 * color_width)) & (y < (10 * color_width))) { ... }
else if((y > (10 * color_width)) & (y < (11 * color_width)))
{
BSP_LCD_SetTextColor(LCD_COLOR_DARKBLUE);
Update_Size(Radius);
}else if ((y > (10 * color_width)) & (y < (11 * color_width))) { ... }
else if((y > (11 * color_width)) & (y < (12 * color_width)))
{
BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
Update_Size(Radius);
}else if ((y > (11 * color_width)) & (y < (12 * color_width))) { ... }
else if((y > (12 * color_width)) & (y < (14 * color_width)))
{
color = BSP_LCD_GetTextColor();
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
BSP_LCD_FillRect(97, 8, 694, 374);
BSP_LCD_SetTextColor(color);
}else if ((y > (12 * color_width)) & (y < (14 * color_width))) { ... }
else
{
x = 0;
y = 0;
}else { ... }
Update_Color();
}else if ((x > 0 ) & ( x < 90 )) { ... }
else if((x > 100) & (y > (BSP_LCD_GetYSize() - 90)) & (y < (BSP_LCD_GetYSize()) ) & ( x < 170))
{
Radius = 15;
Update_Size(Radius);
}else if ((x > 100) & (y > (BSP_LCD_GetYSize() - 90)) & (y < (BSP_LCD_GetYSize()) ) & ( x < 170)) { ... }
else if((x > 170) & (y > (BSP_LCD_GetYSize() - 90)) & (y < (BSP_LCD_GetYSize()) ) & ( x < 240))
{
Radius = 10;
Update_Size(Radius);
}else if ((x > 170) & (y > (BSP_LCD_GetYSize() - 90)) & (y < (BSP_LCD_GetYSize()) ) & ( x < 240)) { ... }
else if((x > 240) & (y > (BSP_LCD_GetYSize() - 90)) & (y < (BSP_LCD_GetYSize()) ) & ( x < 310))
{
Radius = 5;
Update_Size(Radius);
}else if ((x > 240) & (y > (BSP_LCD_GetYSize() - 90)) & (y < (BSP_LCD_GetYSize()) ) & ( x < 310)) { ... }
else if(((x > (BSP_LCD_GetXSize()-5) ) & (y > (14 * color_width)) & (y < (15 * color_width))) | ((x < 90) & (y < 5)))
{
TS_State.touchX[0] = 0;
TS_State.touchY[0] = 0;
}else if (((x > (BSP_LCD_GetXSize()-5) ) & (y > (14 * color_width)) & (y < (15 * color_width))) | ((x < 90) & (y < 5))) { ... }
else if((x > 320) & (y > (BSP_LCD_GetYSize() - 90)) & (x < 410) & (y < BSP_LCD_GetYSize() - 5))
{
Save_Picture();
}else if ((x > 320) & (y > (BSP_LCD_GetYSize() - 90)) & (x < 410) & (y < BSP_LCD_GetYSize() - 5)) { ... }
}if (TS_State.touchDetected) { ... }
}{ ... }
/* ... */
static void Draw_Menu(void)
{
BSP_LCD_Clear(LCD_COLOR_WHITE);
BSP_LCD_DrawBitmap(0, 0, (uint8_t *)color);
BSP_LCD_DrawBitmap(320, (BSP_LCD_GetYSize() - 90), (uint8_t *)save);
BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
BSP_LCD_DrawRect(91, 0, (BSP_LCD_GetXSize()-91), (BSP_LCD_GetYSize()-90));
BSP_LCD_DrawRect(93, 3, (BSP_LCD_GetXSize()-96), (BSP_LCD_GetYSize()-96));
BSP_LCD_DrawRect(95, 5, (BSP_LCD_GetXSize()-100), (BSP_LCD_GetYSize()-100));
BSP_LCD_DrawRect(97, 7, (BSP_LCD_GetXSize()-104), (BSP_LCD_GetYSize()-104));
BSP_LCD_FillRect(100, (BSP_LCD_GetYSize() - 85), 210, 80);
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
BSP_LCD_FillCircle(135, (BSP_LCD_GetYSize() - 45), 15);
BSP_LCD_FillCircle(205, (BSP_LCD_GetYSize() - 45), 10);
BSP_LCD_FillCircle(275, (BSP_LCD_GetYSize() - 45), 5);
BSP_LCD_SetTextColor(LCD_COLOR_DARKRED);
BSP_LCD_SetFont(&Font8);
BSP_LCD_DisplayStringAt(430, (BSP_LCD_GetYSize() - 75), (uint8_t *)"Selected Color Size", LEFT_MODE);
BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
BSP_LCD_FillRect(450, (BSP_LCD_GetYSize() - 50), 30, 30);
BSP_LCD_FillCircle(520, (BSP_LCD_GetYSize() - 35), Radius);
}{ ... }
/* ... */
void Save_Picture(void)
{
FRESULT res1 = FR_OK;
FRESULT res2 = FR_OK;
FRESULT res3 = FR_OK;
uint32_t byteswritten = 0;
uint32_t bmpHeaderByteCnt = 0;
uint32_t bmpFileInfoHeaderByteCnt = 0;
uint32_t bmpFilePixelBytesCnt = 0;
static uint32_t counter = 0;
uint8_t str[30];
uint16_t tmp_size;
if(BSP_SD_IsDetected() != SD_PRESENT)
{
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 20, (uint8_t*)"No SD card detected !!", RIGHT_MODE);
Error_Handler();
}if (BSP_SD_IsDetected() != SD_PRESENT) { ... }
else
{
BSP_LCD_SetFont(&Font16);
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 20, (uint8_t*)"Saving BMP to SD card", RIGHT_MODE);
sprintf((char *)str, "image_%lu.bmp", counter);
bmpFileHeader.bfType = 0x4D42;
bmpFileHeader.bOffBits = sizeof(BitMapFileHeader_Typedef) +
sizeof(BitMapFileInfoHeader_Typedef) - sizeof(uint32_t) - sizeof(uint16_t);
bmpFileHeader.bfSize = ((BSP_LCD_GetXSize() - 105) * (BSP_LCD_GetYSize() - 105 + 1) * RGB888_BYTE_PER_PIXEL);
bmpFileHeader.bfSize += bmpFileHeader.bOffBits;
bmpFileHeader.bfReserved1 = 0x0000;
bmpFileHeader.bfReserved2 = 0x0000;
bmpFileInfoHeader.biSize = 40;
bmpFileInfoHeader.biWidth = (BSP_LCD_GetXSize() - 105);
bmpFileInfoHeader.biHeight = (BSP_LCD_GetYSize() - 105);
bmpFileInfoHeader.biPlanes = 1;
bmpFileInfoHeader.biBitCount = 24;
bmpFileInfoHeader.biCompression = 0;
bmpFileInfoHeader.biSizeImage = ((BSP_LCD_GetXSize() - 105) * (BSP_LCD_GetYSize() - 105 + 1) * RGB888_BYTE_PER_PIXEL);
bmpFileInfoHeader.biXPelsPerMeter = 0;
bmpFileInfoHeader.biYPelsPerMeter = 0;
bmpFileInfoHeader.biClrUsed = 0;
bmpFileInfoHeader.biClrImportant = 0;
Prepare_Picture();
LTDC_Operation(0);
if(f_open(&MyFile, (const char*)str, FA_CREATE_ALWAYS | FA_WRITE) != FR_OK)
{
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 20, (uint8_t*)" BMP File Creation Error !!", RIGHT_MODE);
Error_Handler();
}if (f_open(&MyFile, (const char*)str, FA_CREATE_ALWAYS | FA_WRITE) != FR_OK) { ... }
else
{
res1 = f_write(&MyFile, (uint16_t *)&(bmpFileHeader.bfType),
sizeof(uint16_t),
(void *)&bmpHeaderByteCnt);
byteswritten += bmpHeaderByteCnt;
tmp_size = (uint16_t)(bmpFileHeader.bfSize & 0x0000FFFF);
res1 = f_write(&MyFile, (uint16_t *)&(tmp_size),
sizeof(uint16_t),
(void *)&bmpHeaderByteCnt);
byteswritten += bmpHeaderByteCnt;
tmp_size = (uint16_t)((bmpFileHeader.bfSize & 0xFFFF0000) >> 16);
res1 = f_write(&MyFile, (uint16_t *)&(tmp_size),
sizeof(uint16_t),
(void *)&bmpHeaderByteCnt);
byteswritten += bmpHeaderByteCnt;
res1 = f_write(&MyFile, (uint16_t *)&(bmpFileHeader.bfReserved1),
sizeof(uint16_t),
(void *)&bmpHeaderByteCnt);
byteswritten += bmpHeaderByteCnt;
res1 = f_write(&MyFile, (uint16_t *)&(bmpFileHeader.bfReserved2),
sizeof(uint16_t),
(void *)&bmpHeaderByteCnt);
byteswritten += bmpHeaderByteCnt;
res1 = f_write(&MyFile, (uint32_t *)&(bmpFileHeader.bOffBits),
sizeof(uint32_t),
(void *)&bmpHeaderByteCnt);
byteswritten += bmpHeaderByteCnt;
if(res1 != FR_OK)
{
LTDC_Operation(1);
f_close(&MyFile);
BSP_LCD_ClearStringLine(BSP_LCD_GetYSize() - 20);
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 20, (uint8_t*)" BMP File Header Saving Error !!", RIGHT_MODE);
Error_Handler();
}if (res1 != FR_OK) { ... }
byteswritten += bmpHeaderByteCnt;
if(res1 == FR_OK)
{
res2 = f_write(&MyFile, (BitMapFileInfoHeader_Typedef *)&bmpFileInfoHeader,
sizeof(BitMapFileInfoHeader_Typedef),
(void *)&bmpFileInfoHeaderByteCnt);
if(res2 != FR_OK)
{
LTDC_Operation(1);
f_close(&MyFile);
BSP_LCD_ClearStringLine(BSP_LCD_GetYSize() - 20);
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 20, (uint8_t*)" BMP File Header Info Saving Error !!", RIGHT_MODE);
Error_Handler();
}if (res2 != FR_OK) { ... }
}if (res1 == FR_OK) { ... }
byteswritten += bmpFileInfoHeaderByteCnt;
if((res1 == FR_OK) && (res2 == FR_OK))
{
res3 = f_write(&MyFile, (uint8_t *)p_bmp_converted_pixel_data,
bmpFileInfoHeader.biSizeImage,
(void *)&bmpFilePixelBytesCnt);
LTDC_Operation(1);
if(res3 != FR_OK)
{
if(res3 == FR_DISK_ERR)
{
f_close(&MyFile);
BSP_LCD_ClearStringLine(BSP_LCD_GetYSize() - 20);
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 20, (uint8_t*)" File Saving Error DISKERR !!", RIGHT_MODE);
}if (res3 == FR_DISK_ERR) { ... }
Error_Handler();
}if (res3 != FR_OK) { ... }
}if ((res1 == FR_OK) && (res2 == FR_OK)) { ... }
byteswritten += bmpFilePixelBytesCnt;
if((res1 != FR_OK) || (res2 != FR_OK) || (res3 != FR_OK) || (byteswritten == 0))
{
BSP_LCD_ClearStringLine(BSP_LCD_GetYSize() - 20);
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 20, (uint8_t*)" BMP File Saving Error !!", RIGHT_MODE);
Error_Handler();
}if ((res1 != FR_OK) || (res2 != FR_OK) || (res3 != FR_OK) || (byteswritten == 0)) { ... }
else
{
f_close(&MyFile);
BSP_LED_On(LED1);
BSP_LCD_ClearStringLine(BSP_LCD_GetYSize() - 20);
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 20, (uint8_t*)" BMP File Saved.", RIGHT_MODE);
HAL_Delay(2000);
BSP_LCD_ClearStringLine(BSP_LCD_GetYSize() - 20);
BSP_LED_Off(LED1);
counter++;
}else { ... }
}else { ... }
}else { ... }
}{ ... }
/* ... */
static void LTDC_Operation(uint32_t Enable_LTDC)
{
if(Enable_LTDC == 1)
{
__HAL_LTDC_ENABLE(&(hltdc_eval));
}if (Enable_LTDC == 1) { ... }
else if (Enable_LTDC == 0)
{
__HAL_LTDC_DISABLE(&(hltdc_eval));
}else if (Enable_LTDC == 0) { ... }
}{ ... }
/* ... */
static void Prepare_Picture(void)
{
const uint32_t x0 = 98;
const uint32_t x1 = BSP_LCD_GetXSize()- 7;
const uint32_t y0 = 7;
const uint32_t y1 = BSP_LCD_GetYSize()- 98;
uint32_t addrSrc = LCD_FRAME_BUFFER;
uint32_t addrDst = CONVERTED_FRAME_BUFFER;
static DMA2D_HandleTypeDef hdma2d_eval;
uint32_t lineCnt = 0;
hdma2d_eval.Init.Mode = DMA2D_M2M_PFC;
hdma2d_eval.Init.ColorMode = DMA2D_RGB888;
hdma2d_eval.Init.OutputOffset = 0;
hdma2d_eval.LayerCfg[1].AlphaMode = DMA2D_NO_MODIF_ALPHA;
hdma2d_eval.LayerCfg[1].InputAlpha = 0xFF;
hdma2d_eval.LayerCfg[1].InputColorMode = DMA2D_INPUT_ARGB8888;
hdma2d_eval.LayerCfg[1].InputOffset = 0;
hdma2d_eval.Instance = DMA2D;
if(HAL_DMA2D_Init(&hdma2d_eval) == HAL_OK)
{
if(HAL_DMA2D_ConfigLayer(&hdma2d_eval, 1) != HAL_OK)
{
Error_Handler();
}if (HAL_DMA2D_ConfigLayer(&hdma2d_eval, 1) != HAL_OK) { ... }
}if (HAL_DMA2D_Init(&hdma2d_eval) == HAL_OK) { ... }
else
{
Error_Handler();
}else { ... }
addrSrc += (((y1 * BSP_LCD_GetXSize()) + x0) * ARGB8888_BYTE_PER_PIXEL);
/* ... */
for(lineCnt = y0; lineCnt <= y1; lineCnt++)
{
if (HAL_DMA2D_Start(&hdma2d_eval, addrSrc, addrDst, (x1 - x0), 1) == HAL_OK)
{
HAL_DMA2D_PollForTransfer(&hdma2d_eval, 20);
}if (HAL_DMA2D_Start(&hdma2d_eval, addrSrc, addrDst, (x1 - x0), 1) == HAL_OK) { ... }
addrDst += ((x1 - x0) * RGB888_BYTE_PER_PIXEL) + RGB888_BYTE_PER_PIXEL;
addrSrc -= (BSP_LCD_GetXSize() * ARGB8888_BYTE_PER_PIXEL);
}for (lineCnt = y0; lineCnt <= y1; lineCnt++) { ... }
}{ ... }
/* ... */
static void Update_Color(void)
{
static uint32_t color;
color = BSP_LCD_GetTextColor();
BSP_LCD_SetTextColor(color);
BSP_LCD_FillRect(450, (BSP_LCD_GetYSize() - 50), 30, 30);
BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
BSP_LCD_DrawRect(450, (BSP_LCD_GetYSize() - 50), 30, 30);
BSP_LCD_SetTextColor(color);
}{ ... }
/* ... */
static void Update_Size(uint8_t size)
{
static uint32_t color;
color = BSP_LCD_GetTextColor();
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
BSP_LCD_FillCircle(520, (BSP_LCD_GetYSize() - 35), 20);
BSP_LCD_SetTextColor(color);
BSP_LCD_FillCircle(520, (BSP_LCD_GetYSize() - 35), size);
BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
BSP_LCD_DrawCircle(520, (BSP_LCD_GetYSize() - 35), size);
BSP_LCD_SetTextColor(color);
}{ ... }
/* ... */
static void Error_Handler(void)
{
BSP_LED_On(LED3);
while(1)
{
}while (1) { ... }
}{ ... }
/* ... */
static void SystemClock_Config(void)
{
RCC_ClkInitTypeDef RCC_ClkInitStruct;
RCC_OscInitTypeDef RCC_OscInitStruct;
HAL_StatusTypeDef ret = HAL_OK;
__HAL_RCC_PWR_CLK_ENABLE();
/* ... */
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 25;
RCC_OscInitStruct.PLL.PLLN = 360;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = 7;
RCC_OscInitStruct.PLL.PLLR = 6;
ret = HAL_RCC_OscConfig(&RCC_OscInitStruct);
if(ret != HAL_OK)
{
while(1) { ; }
}if (ret != HAL_OK) { ... }
ret = HAL_PWREx_EnableOverDrive();
if(ret != HAL_OK)
{
while(1) { ; }
}if (ret != HAL_OK) { ... }
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
ret = HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5);
if(ret != HAL_OK)
{
while(1) { ; }
}if (ret != HAL_OK) { ... }
}{ ... }
#ifdef USE_FULL_ASSERT
/* ... */
void assert_failed(uint8_t* file, uint32_t line)
{
/* ... */
while (1)
{
}while (1) { ... }
}assert_failed (uint8_t* file, uint32_t line) { ... }
/* ... */#endif
/* ... */