2525
2626MDT_DRAWING_CONTEXT main_ctx ;
2727
28- uint8_t usingDMA2D = 0 , disableDMA2D = 0 ;
28+ static uint8_t usingDMA2D = 0 ;
2929
3030static MDT_GRAPHICS_InitTypeDef graphicsConfig ;
3131
@@ -34,18 +34,13 @@ static bool graphicsInitialized = false;
3434
3535bool MDT_GRAPHICS_DMA2D_IsAvailable () {
3636
37- return !usingDMA2D && ! disableDMA2D ;
37+ return !usingDMA2D ;
3838
3939}
4040
4141
4242static void MDT_GRAPHICS_DMA2D_ClearBitmap (MDT_BITMAP * bmp , uint8_t color ) {
4343
44- if (disableDMA2D ) {
45- //MDT_GRAPHICS_ClearBitmap(bmp, color);
46- return ;
47- }
48-
4944 usingDMA2D = 1 ;
5045
5146 LL_DMA2D_DeInit (DMA2D );
@@ -57,7 +52,7 @@ static void MDT_GRAPHICS_DMA2D_ClearBitmap(MDT_BITMAP* bmp, uint8_t color) {
5752 .OutputBlue = color ,// Blue_Value;
5853 .OutputRed = color ,// Red_Value;
5954 .OutputAlpha = color ,
60- .OutputMemoryAddress = (uint32_t )(bmp -> buff ),
55+ .OutputMemoryAddress = (uint32_t ) (bmp -> buff ),
6156 .LineOffset = 0 ,
6257 .NbrOfLines = bmp -> height ,
6358 .NbrOfPixelsPerLines = bmp -> width / 4 ,
@@ -66,7 +61,7 @@ static void MDT_GRAPHICS_DMA2D_ClearBitmap(MDT_BITMAP* bmp, uint8_t color) {
6661 LL_DMA2D_Init (DMA2D , & DMA2D_InitStruct );
6762 LL_DMA2D_Start (DMA2D );
6863
69- while ( !LL_DMA2D_IsActiveFlag_TC (DMA2D ) || disableDMA2D );
64+ while (!LL_DMA2D_IsActiveFlag_TC (DMA2D ));
7065
7166 usingDMA2D = 0 ;
7267
@@ -227,8 +222,8 @@ static void MDT_GRAPHICS_HW_DrawBitmap(MDT_BITMAP* bmpdst, MDT_BITMAP* bmpsrc, i
227222 };
228223
229224 for (uint16_t j = 0 ; j < bmpsrc -> height ; j ++ ) {
230- DMA_InitStruct .PeriphOrM2MSrcAddress = (uint32_t )(bmpsrc -> buff ) + j * bmpsrc -> width ;//srcAddress;
231- DMA_InitStruct .MemoryOrM2MDstAddress = (uint32_t )(bmpdst -> buff ) + x + (j + y ) * bmpdst -> width ;//destAddress;
225+ DMA_InitStruct .PeriphOrM2MSrcAddress = (uint32_t ) (bmpsrc -> buff ) + j * bmpsrc -> width ;//srcAddress;
226+ DMA_InitStruct .MemoryOrM2MDstAddress = (uint32_t ) (bmpdst -> buff ) + x + (j + y ) * bmpdst -> width ;//destAddress;
232227 LL_DMA_Init (DMA1 , DMA_STREAM , & DMA_InitStruct );
233228 LL_DMA_EnableStream (DMA1 , DMA_STREAM );
234229 while (!LL_DMA_IsActiveFlag_TC2 (DMA1 ));
@@ -373,9 +368,12 @@ void MDT_GRAPHICS_DestroyContext(MDT_DRAWING_CONTEXT* ctx) {
373368void MDT_GRAPHICS_ClearBitmap (MDT_BITMAP * bmp , uint8_t color ) {
374369
375370 if (graphicsConfig .useHardwareAcceleration ) {
376- //MDT_GRAPHICS_HW_ClearBitmap(bmp, color);
377- MDT_GRAPHICS_DMA2D_ClearBitmap (bmp , color );
371+
372+ //if (dma2dAvailable)
373+ MDT_GRAPHICS_DMA2D_ClearBitmap (bmp , color );
374+ //else MDT_GRAPHICS_HW_ClearBitmap(bmp, color);
378375 return ;
376+
379377 }
380378
381379 uint32_t i , j ;
0 commit comments