1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
26
27
31
32
35
38
39
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
67
68
69
70
71
72
73
74
75
76
77
80
81
82
83
84
85
86
87
88
91
92
93
96
99
100
101
104
105
106
107
108
109
115
116
119
120
123
124
125
126
127
128
129
130
131
132
133
136
137
140
145
149
152
153
154
155
156
157
158
159
160
165
166
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
279
280
281
282
283
284
285
286
287
288
289
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
326
332
333
334
335
336
337
338
339
340
345
346
347
348
349
350
357
358
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
430
435
439
443
447
451
463
470
477
481
492
493
494
495
496
497
498
499
500
501
503
504
505
506
507
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
542
543
544
545
550
551
552
553
554
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
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
607
608
609
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
680
681
682
683
688
695
696
703
704
705
706
707
708
709
710
711
712
713
714
715
716
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
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
/* ... */
#include "LCDConf.h"
#include "GUI_Private.h"
/* ... */
/* ... */
/* ... */
/* ... */
/* ... */
#undef LCD_SWAP_XY
#undef LCD_MIRROR_Y
#define LCD_SWAP_XY 1
#define LCD_MIRROR_Y 1
#define XSIZE_PHYS 240
#define YSIZE_PHYS 320
#define NUM_BUFFERS 3
#define NUM_VSCREENS 1
#define BK_COLOR GUI_DARKBLUE
7 defines
#undef GUI_NUM_LAYERS
#define GUI_NUM_LAYERS 1
#define COLOR_CONVERSION_0 GUICC_M8888I
#define DISPLAY_DRIVER_0 GUIDRV_LIN_32
#if (GUI_NUM_LAYERS > 1)
#define COLOR_CONVERSION_1 GUICC_M8888I
#define DISPLAY_DRIVER_1 GUIDRV_LIN_32
/* ... */#endif
#ifndef XSIZE_PHYS
#error Physical X size of display is not defined!
#endif
#ifndef YSIZE_PHYS
#error Physical Y size of display is not defined!
#endif
#ifndef NUM_VSCREENS
#define NUM_VSCREENS 1
#else
#if (NUM_VSCREENS <= 0)
#error At least one screeen needs to be defined!
#endif/* ... */
#endif
#if (NUM_VSCREENS > 1) && (NUM_BUFFERS > 1)
#error Virtual screens and multiple buffers are not allowed!
#endif
#define LCD_LAYER0_FRAME_BUFFER ((uint32_t)0xD0200000)
#define LCD_LAYER1_FRAME_BUFFER ((uint32_t)0xD0400000)
/* ... */
/* ... */
/* ... */
/* ... */
LTDC_HandleTypeDef hltdc;
static DMA2D_HandleTypeDef hdma2d;
static LCD_LayerPropTypedef layer_prop[GUI_NUM_LAYERS];
static const LCD_API_COLOR_CONV * apColorConvAPI[] =
{
COLOR_CONVERSION_0,
#if GUI_NUM_LAYERS > 1
COLOR_CONVERSION_1,
#endif
...};
/* ... */
/* ... */
static void DMA2D_CopyBuffer (U32 LayerIndex, void * pSrc, void * pDst, U32 xSize, U32 ySize, U32 OffLineSrc, U32 OffLineDst);
static void DMA2D_FillBuffer(U32 LayerIndex, void * pDst, U32 xSize, U32 ySize, U32 OffLine, U32 ColorIndex);
static void LCD_LL_Init(void);
static void LCD_LL_LayerInit(U32 LayerIndex);
static void CUSTOM_CopyBuffer(int LayerIndex, int IndexSrc, int IndexDst);
static void CUSTOM_CopyRect(int LayerIndex, int x0, int y0, int x1, int y1, int xSize, int ySize);
static void CUSTOM_FillRect(int LayerIndex, int x0, int y0, int x1, int y1, U32 PixelIndex);
static void CUSTOM_DrawBitmap32bpp(int LayerIndex, int x, int y, U8 const * p, int xSize, int ySize, int BytesPerLine);
static U32 GetBufferSize(U32 LayerIndex);
/* ... */
/* ... */
/* ... */
static inline U32 LCD_LL_GetPixelformat(U32 LayerIndex)
{
return LTDC_PIXEL_FORMAT_ARGB8888;
}{ ... }
/* ... */
/* ... */
void HAL_DMA2D_MspInit(DMA2D_HandleTypeDef *hdma2d)
{
__HAL_RCC_DMA2D_CLK_ENABLE();
}{ ... }
/* ... */
void HAL_DMA2D_MspDeInit(DMA2D_HandleTypeDef *hdma2d)
{
__HAL_RCC_DMA2D_FORCE_RESET();
__HAL_RCC_DMA2D_RELEASE_RESET();
}{ ... }
/* ... */
void HAL_LTDC_MspInit(LTDC_HandleTypeDef *hltdc)
{
GPIO_InitTypeDef GPIO_Init_Structure;
__HAL_RCC_LTDC_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
__HAL_RCC_GPIOF_CLK_ENABLE();
__HAL_RCC_GPIOG_CLK_ENABLE();
/* ... */
GPIO_Init_Structure.Pin = GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_6 |
GPIO_PIN_11 | GPIO_PIN_12;
GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP;
GPIO_Init_Structure.Pull = GPIO_NOPULL;
GPIO_Init_Structure.Speed = GPIO_SPEED_FAST;
GPIO_Init_Structure.Alternate= GPIO_AF14_LTDC;
HAL_GPIO_Init(GPIOA, &GPIO_Init_Structure);
GPIO_Init_Structure.Pin = GPIO_PIN_8 | \
GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11;
HAL_GPIO_Init(GPIOB, &GPIO_Init_Structure);
GPIO_Init_Structure.Pin = GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_10;
HAL_GPIO_Init(GPIOC, &GPIO_Init_Structure);
GPIO_Init_Structure.Pin = GPIO_PIN_3 | GPIO_PIN_6;
HAL_GPIO_Init(GPIOD, &GPIO_Init_Structure);
GPIO_Init_Structure.Pin = GPIO_PIN_10;
HAL_GPIO_Init(GPIOF, &GPIO_Init_Structure);
GPIO_Init_Structure.Pin = GPIO_PIN_6 | GPIO_PIN_7 | \
GPIO_PIN_11;
HAL_GPIO_Init(GPIOG, &GPIO_Init_Structure);
GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1;
GPIO_Init_Structure.Alternate= GPIO_AF9_LTDC;
HAL_GPIO_Init(GPIOB, &GPIO_Init_Structure);
GPIO_Init_Structure.Pin = GPIO_PIN_10 | GPIO_PIN_12;
HAL_GPIO_Init(GPIOG, &GPIO_Init_Structure);
HAL_NVIC_SetPriority(LTDC_IRQn, 0xE, 0);
HAL_NVIC_EnableIRQ(LTDC_IRQn);
}{ ... }
/* ... */
void HAL_LTDC_MspDeInit(LTDC_HandleTypeDef *hltdc)
{
__HAL_RCC_LTDC_FORCE_RESET();
__HAL_RCC_LTDC_RELEASE_RESET();
}{ ... }
/* ... */
void HAL_LTDC_LineEvenCallback(LTDC_HandleTypeDef *hltdc)
{
U32 Addr;
U32 layer;
for (layer = 0; layer < GUI_NUM_LAYERS; layer++)
{
if (layer_prop[layer].pending_buffer >= 0)
{
Addr = layer_prop[layer].address + \
layer_prop[layer].xSize * layer_prop[layer].ySize * layer_prop[layer].pending_buffer * layer_prop[layer].BytesPerPixel;
__HAL_LTDC_LAYER(hltdc, layer)->CFBAR = Addr;
__HAL_LTDC_RELOAD_CONFIG(hltdc);
GUI_MULTIBUF_ConfirmEx(layer, layer_prop[layer].pending_buffer);
layer_prop[layer].pending_buffer = -1;
}if (layer_prop[layer].pending_buffer >= 0) { ... }
}for (layer = 0; layer < GUI_NUM_LAYERS; layer++) { ... }
HAL_LTDC_ProgramLineEvent(hltdc, 0);
}{ ... }
/* ... */
/* ... */
void LCD_X_Config(void)
{
U32 i;
LCD_LL_Init ();
#if (NUM_BUFFERS > 1)
for (i = 0; i < GUI_NUM_LAYERS; i++)
{
GUI_MULTIBUF_ConfigEx(i, NUM_BUFFERS);
}for (i = 0; i < GUI_NUM_LAYERS; i++) { ... }
/* ... */#endif
GUI_DEVICE_CreateAndLink(DISPLAY_DRIVER_0, COLOR_CONVERSION_0, 0, 0);
if (LCD_GetSwapXYEx(0)) {
LCD_SetSizeEx (0, YSIZE_PHYS, XSIZE_PHYS);
LCD_SetVSizeEx(0, YSIZE_PHYS * NUM_VSCREENS, XSIZE_PHYS);
}if (LCD_GetSwapXYEx(0)) { ... } else {
LCD_SetSizeEx (0, XSIZE_PHYS, YSIZE_PHYS);
LCD_SetVSizeEx(0, XSIZE_PHYS, YSIZE_PHYS * NUM_VSCREENS);
}else { ... }
#if (GUI_NUM_LAYERS > 1)
GUI_DEVICE_CreateAndLink(DISPLAY_DRIVER_1, COLOR_CONVERSION_1, 0, 1);
if (LCD_GetSwapXYEx(1)) {
LCD_SetSizeEx (1, YSIZE_PHYS, XSIZE_PHYS);
LCD_SetVSizeEx(1, YSIZE_PHYS * NUM_VSCREENS, XSIZE_PHYS);
}if (LCD_GetSwapXYEx(1)) { ... } else {
LCD_SetSizeEx (1, XSIZE_PHYS, YSIZE_PHYS);
LCD_SetVSizeEx(1, XSIZE_PHYS, YSIZE_PHYS * NUM_VSCREENS);
}else { ... }
/* ... */ #endif
layer_prop[0].address = LCD_LAYER0_FRAME_BUFFER;
#if (GUI_NUM_LAYERS > 1)
layer_prop[1].address = LCD_LAYER1_FRAME_BUFFER;
#endif
for (i = 0; i < GUI_NUM_LAYERS; i++)
{
layer_prop[i].pColorConvAPI = (LCD_API_COLOR_CONV *)apColorConvAPI[i];
layer_prop[i].pending_buffer = -1;
LCD_SetVRAMAddrEx(i, (void *)(layer_prop[i].address));
layer_prop[i].BytesPerPixel = LCD_GetBitsPerPixelEx(i) >> 3;
LCD_SetDevFunc(i, LCD_DEVFUNC_COPYBUFFER, (void(*)(void))CUSTOM_CopyBuffer);
LCD_SetDevFunc(i, LCD_DEVFUNC_COPYRECT, (void(*)(void))CUSTOM_CopyRect);
LCD_SetDevFunc(i, LCD_DEVFUNC_FILLRECT, (void(*)(void))CUSTOM_FillRect);
if (LCD_LL_GetPixelformat(i) == LTDC_PIXEL_FORMAT_ARGB8888) {
LCD_SetDevFunc(i, LCD_DEVFUNC_DRAWBMP_32BPP, (void(*)(void))CUSTOM_DrawBitmap32bpp);
}if (LCD_LL_GetPixelformat(i) == LTDC_PIXEL_FORMAT_ARGB8888) { ... }
}for (i = 0; i < GUI_NUM_LAYERS; i++) { ... }
}{ ... }
/* ... */
int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void * pData)
{
int r = 0;
U32 addr;
int xPos, yPos;
U32 Color;
switch (Cmd)
{
case LCD_X_INITCONTROLLER:
LCD_LL_LayerInit(LayerIndex);
break;
case LCD_X_INITCONTROLLER:
case LCD_X_SETORG:
addr = layer_prop[LayerIndex].address + ((LCD_X_SETORG_INFO *)pData)->yPos * layer_prop[LayerIndex].xSize * layer_prop[LayerIndex].BytesPerPixel;
HAL_LTDC_SetAddress(&hltdc, addr, LayerIndex);
break;
case LCD_X_SETORG:
case LCD_X_SHOWBUFFER:
layer_prop[LayerIndex].pending_buffer = ((LCD_X_SHOWBUFFER_INFO *)pData)->Index;
break;
case LCD_X_SHOWBUFFER:
case LCD_X_SETLUTENTRY:
HAL_LTDC_ConfigCLUT(&hltdc, (uint32_t *)&(((LCD_X_SETLUTENTRY_INFO *)pData)->Color), 1, LayerIndex);
break;
case LCD_X_SETLUTENTRY:
case LCD_X_ON:
__HAL_LTDC_ENABLE(&hltdc);
break;
case LCD_X_ON:
case LCD_X_OFF:
__HAL_LTDC_DISABLE(&hltdc);
break;
case LCD_X_OFF:
case LCD_X_SETVIS:
if(((LCD_X_SETVIS_INFO *)pData)->OnOff == ENABLE )
{
__HAL_LTDC_LAYER_ENABLE(&hltdc, LayerIndex);
}if (((LCD_X_SETVIS_INFO *)pData)->OnOff == ENABLE) { ... }
else
{
__HAL_LTDC_LAYER_DISABLE(&hltdc, LayerIndex);
}else { ... }
__HAL_LTDC_RELOAD_CONFIG(&hltdc);
break;
case LCD_X_SETVIS:
case LCD_X_SETPOS:
HAL_LTDC_SetWindowPosition(&hltdc,
((LCD_X_SETPOS_INFO *)pData)->xPos,
((LCD_X_SETPOS_INFO *)pData)->yPos,
LayerIndex);
break;
case LCD_X_SETPOS:
case LCD_X_SETSIZE:
GUI_GetLayerPosEx(LayerIndex, &xPos, &yPos);
layer_prop[LayerIndex].xSize = ((LCD_X_SETSIZE_INFO *)pData)->xSize;
layer_prop[LayerIndex].ySize = ((LCD_X_SETSIZE_INFO *)pData)->ySize;
HAL_LTDC_SetWindowPosition(&hltdc, xPos, yPos, LayerIndex);
break;
case LCD_X_SETSIZE:
case LCD_X_SETALPHA:
HAL_LTDC_SetAlpha(&hltdc, ((LCD_X_SETALPHA_INFO *)pData)->Alpha, LayerIndex);
break;
case LCD_X_SETALPHA:
case LCD_X_SETCHROMAMODE:
if(((LCD_X_SETCHROMAMODE_INFO *)pData)->ChromaMode != 0)
{
HAL_LTDC_EnableColorKeying(&hltdc, LayerIndex);
}if (((LCD_X_SETCHROMAMODE_INFO *)pData)->ChromaMode != 0) { ... }
else
{
HAL_LTDC_DisableColorKeying(&hltdc, LayerIndex);
}else { ... }
break;
case LCD_X_SETCHROMAMODE:
case LCD_X_SETCHROMA:
Color = ((((LCD_X_SETCHROMA_INFO *)pData)->ChromaMin & 0xFF0000) >> 16) |\
(((LCD_X_SETCHROMA_INFO *)pData)->ChromaMin & 0x00FF00) |\
((((LCD_X_SETCHROMA_INFO *)pData)->ChromaMin & 0x0000FF) << 16);
HAL_LTDC_ConfigColorKeying(&hltdc, Color, LayerIndex);
break;
case LCD_X_SETCHROMA:
default:
r = -1;default
}switch (Cmd) { ... }
return r;
}{ ... }
/* ... */
static void LCD_LL_LayerInit(U32 LayerIndex)
{
LTDC_LayerCfgTypeDef layer_cfg;
if (LayerIndex < GUI_NUM_LAYERS)
{
layer_cfg.WindowX0 = 0;
layer_cfg.WindowX1 = XSIZE_PHYS;
layer_cfg.WindowY0 = 0;
layer_cfg.WindowY1 = YSIZE_PHYS;
layer_cfg.PixelFormat = LCD_LL_GetPixelformat(LayerIndex);
layer_cfg.FBStartAdress = layer_prop[LayerIndex].address;
layer_cfg.Alpha = 255;
layer_cfg.Alpha0 = 0;
layer_cfg.Backcolor.Blue = 0;
layer_cfg.Backcolor.Green = 0;
layer_cfg.Backcolor.Red = 0;
layer_cfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA;
layer_cfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA;
layer_cfg.ImageWidth = XSIZE_PHYS;
layer_cfg.ImageHeight = YSIZE_PHYS;
HAL_LTDC_ConfigLayer(&hltdc, &layer_cfg, LayerIndex);
if (LCD_GetBitsPerPixelEx(LayerIndex) <= 8)
{
HAL_LTDC_EnableCLUT(&hltdc, LayerIndex);
}if (LCD_GetBitsPerPixelEx(LayerIndex) <= 8) { ... }
}if (LayerIndex < GUI_NUM_LAYERS) { ... }
}{ ... }
/* ... */
static void LCD_LL_Init(void)
{
static RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
hltdc.Instance = LTDC;
HAL_LTDC_DeInit(&hltdc);
ili9341_Init();
hltdc.Init.HorizontalSync = 9;
hltdc.Init.VerticalSync = 1;
hltdc.Init.AccumulatedHBP = 29;
hltdc.Init.AccumulatedVBP = 3;
hltdc.Init.AccumulatedActiveH = 323;
hltdc.Init.AccumulatedActiveW = 269;
hltdc.Init.TotalHeigh = 327;
hltdc.Init.TotalWidth = 279;
hltdc.Init.Backcolor.Blue = 0;
hltdc.Init.Backcolor.Green = 0;
hltdc.Init.Backcolor.Red = 0;
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC;
PeriphClkInitStruct.PLLSAI.PLLSAIN = 192;
PeriphClkInitStruct.PLLSAI.PLLSAIR = 4;
PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_8;
HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
hltdc.Init.HSPolarity = LTDC_HSPOLARITY_AL;
hltdc.Init.VSPolarity = LTDC_VSPOLARITY_AL;
hltdc.Init.DEPolarity = LTDC_DEPOLARITY_AL;
hltdc.Init.PCPolarity = LTDC_PCPOLARITY_IPC;
hltdc.Instance = LTDC;
HAL_LTDC_Init(&hltdc);
HAL_LTDC_ProgramLineEvent(&hltdc, 0);
hdma2d.Init.Mode = DMA2D_R2M;
hdma2d.Init.ColorMode = DMA2D_ARGB8888;
hdma2d.Init.OutputOffset = 0x0;
hdma2d.Instance = DMA2D;
if(HAL_DMA2D_Init(&hdma2d) != HAL_OK)
{
while (1);
}if (HAL_DMA2D_Init(&hdma2d) != HAL_OK) { ... }
}{ ... }
/* ... */
static void DMA2D_CopyBuffer(U32 LayerIndex, void * pSrc, void * pDst, U32 xSize, U32 ySize, U32 OffLineSrc, U32 OffLineDst)
{
U32 PixelFormat;
PixelFormat = LCD_LL_GetPixelformat(LayerIndex);
DMA2D->CR = 0x00000000UL | (1 << 9);
DMA2D->FGMAR = (U32)pSrc;
DMA2D->OMAR = (U32)pDst;
DMA2D->FGOR = OffLineSrc;
DMA2D->OOR = OffLineDst;
DMA2D->FGPFCCR = PixelFormat;
DMA2D->NLR = (U32)(xSize << 16) | (U16)ySize;
DMA2D->CR |= DMA2D_CR_START;
while (DMA2D->CR & DMA2D_CR_START)
{
}while (DMA2D->CR & DMA2D_CR_START) { ... }
}{ ... }
/* ... */
static void DMA2D_FillBuffer(U32 LayerIndex, void * pDst, U32 xSize, U32 ySize, U32 OffLine, U32 ColorIndex)
{
U32 PixelFormat;
PixelFormat = LCD_LL_GetPixelformat(LayerIndex);
DMA2D->CR = 0x00030000UL | (1 << 9);
DMA2D->OCOLR = ColorIndex;
DMA2D->OMAR = (U32)pDst;
DMA2D->OOR = OffLine;
DMA2D->OPFCCR = PixelFormat;
DMA2D->NLR = (U32)(xSize << 16) | (U16)ySize;
DMA2D->CR |= DMA2D_CR_START;
while (DMA2D->CR & DMA2D_CR_START)
{
}while (DMA2D->CR & DMA2D_CR_START) { ... }
}{ ... }
/* ... */
static U32 GetBufferSize(U32 LayerIndex)
{
U32 BufferSize;
BufferSize = layer_prop[LayerIndex].xSize * layer_prop[LayerIndex].ySize * layer_prop[LayerIndex].BytesPerPixel;
return BufferSize;
}{ ... }
/* ... */
static void CUSTOM_CopyBuffer(int LayerIndex, int IndexSrc, int IndexDst) {
U32 BufferSize, AddrSrc, AddrDst;
BufferSize = GetBufferSize(LayerIndex);
AddrSrc = layer_prop[LayerIndex].address + BufferSize * IndexSrc;
AddrDst = layer_prop[LayerIndex].address + BufferSize * IndexDst;
DMA2D_CopyBuffer(LayerIndex, (void *)AddrSrc, (void *)AddrDst, layer_prop[LayerIndex].xSize, layer_prop[LayerIndex].ySize, 0, 0);
layer_prop[LayerIndex].buffer_index = IndexDst;
}{ ... }
/* ... */
static void CUSTOM_CopyRect(int LayerIndex, int x0, int y0, int x1, int y1, int xSize, int ySize)
{
U32 AddrSrc, AddrDst;
AddrSrc = layer_prop[LayerIndex].address + (y0 * layer_prop[LayerIndex].xSize + x0) * layer_prop[LayerIndex].BytesPerPixel;
AddrDst = layer_prop[LayerIndex].address + (y1 * layer_prop[LayerIndex].xSize + x1) * layer_prop[LayerIndex].BytesPerPixel;
DMA2D_CopyBuffer(LayerIndex, (void *)AddrSrc, (void *)AddrDst, xSize, ySize, layer_prop[LayerIndex].xSize - xSize, layer_prop[LayerIndex].xSize - xSize);
}{ ... }
/* ... */
static void CUSTOM_FillRect(int LayerIndex, int x0, int y0, int x1, int y1, U32 PixelIndex)
{
U32 BufferSize, AddrDst;
int xSize, ySize;
if (GUI_GetDrawMode() == GUI_DM_XOR)
{
LCD_SetDevFunc(LayerIndex, LCD_DEVFUNC_FILLRECT, NULL);
LCD_FillRect(x0, y0, x1, y1);
LCD_SetDevFunc(LayerIndex, LCD_DEVFUNC_FILLRECT, (void(*)(void))CUSTOM_FillRect);
}if (GUI_GetDrawMode() == GUI_DM_XOR) { ... }
else
{
xSize = x1 - x0 + 1;
ySize = y1 - y0 + 1;
BufferSize = GetBufferSize(LayerIndex);
AddrDst = layer_prop[LayerIndex].address + BufferSize * layer_prop[LayerIndex].buffer_index + (y0 * layer_prop[LayerIndex].xSize + x0) * layer_prop[LayerIndex].BytesPerPixel;
DMA2D_FillBuffer(LayerIndex, (void *)AddrDst, xSize, ySize, layer_prop[LayerIndex].xSize - xSize, PixelIndex);
}else { ... }
}{ ... }
/* ... */
static void CUSTOM_DrawBitmap32bpp(int LayerIndex, int x, int y, U8 const * p, int xSize, int ySize, int BytesPerLine)
{
U32 BufferSize, AddrDst;
int OffLineSrc, OffLineDst;
BufferSize = GetBufferSize(LayerIndex);
AddrDst = layer_prop[LayerIndex].address + BufferSize * layer_prop[LayerIndex].buffer_index + (y * layer_prop[LayerIndex].xSize + x) * layer_prop[LayerIndex].BytesPerPixel;
OffLineSrc = (BytesPerLine / 4) - xSize;
OffLineDst = layer_prop[LayerIndex].xSize - xSize;
DMA2D_CopyBuffer(LayerIndex, (void *)p, (void *)AddrDst, xSize, ySize, OffLineSrc, OffLineDst);
}{ ... }