TA的每日心情 | 奋斗 2023-7-6 08:48 |
---|
签到天数: 169 天 连续签到: 1 天 [LV.7]常住居民III
|
这里有一个层可编程参数。
最多可单独使能、禁止和配置两个层。层显示顺序固定,即自下而上。如果使能两个层,则层 2 为顶部显示窗口。
可为每个层定位和调整窗口大小,各个层必须位于有效显示区域内。使用到的是LTDC_LxWHPCR 和 LTDC_WVPCR寄存器
两层可按照 LTDC_LxBFCR寄存器中配置的混合系数进行混合。
混合顺序固定,即由下至上。如果使能了两层,首先第 1 层将与背景色混合,随后第 2 层与
第 1 层和背景的混合颜色结果再次混合。
两层时的配置与一层时的配置很类似。
第一图层配置
位置从(0,0)到(320,240)
图像地址为L8_320x240
图像大小为320*240
pLayerCfg.WindowX0 = 0; pLayerCfg.WindowX1 = 320; pLayerCfg.WindowY0 = 0; pLayerCfg.WindowY1 = 240; /* Pixel Format configuration*/ pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_L8; /* Start Address configuration : frame buffer is located at FLASH memory */ pLayerCfg.FBStartAdress = (uint32_t)&L8_320x240; /* Alpha constant (255 totally opaque) */ pLayerCfg.Alpha = 255; /* Default Color configuration (configure A,R,G,B component values) */ pLayerCfg.Alpha0 = 0; pLayerCfg.Backcolor.Blue = 0; pLayerCfg.Backcolor.Green = 0; pLayerCfg.Backcolor.Red = 0; /* Configure blending factors */ pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA; pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA; /* Configure the number of lines and number of pixels per line */ pLayerCfg.ImageWidth = 320; pLayerCfg.ImageHeight = 240;第一图层配置
位置从(160,32)到(480,272)
图像地址为RGB565_320x240
图像大小为320*240
pLayerCfg1.WindowX0 = 160; pLayerCfg1.WindowX1 = 480; pLayerCfg1.WindowY0 = 32; pLayerCfg1.WindowY1 = 272; /* Pixel Format configuration*/ pLayerCfg1.PixelFormat = LTDC_PIXEL_FORMAT_RGB565; /* Start Address configuration : frame buffer is located at FLASH memory */ pLayerCfg1.FBStartAdress = (uint32_t)&RGB565_320x240; /* Alpha constant (255 totally opaque) */ pLayerCfg1.Alpha = 200; /* Default Color configuration (configure A,R,G,B component values) */ pLayerCfg1.Alpha0 = 0; pLayerCfg1.Backcolor.Blue = 0; pLayerCfg1.Backcolor.Green = 0; pLayerCfg1.Backcolor.Red = 0; /* Configure blending factors */ pLayerCfg1.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA; pLayerCfg1.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA; /* Configure the number of lines and number of pixels per line */ pLayerCfg1.ImageWidth = 320; pLayerCfg1.ImageHeight = 240; 以下程序,将图层1移动到图层2的位置,简单的动画
for (index = 0; index < 32; index++) { /* calculate new picture position */ PicturesPosition(&Xpos1, &Ypos1, &Xpos2, &Ypos2, (index+1)); /* reconfigure the layer1 position without Reloading*/ HAL_LTDC_SetWindowPosition_NoReload(&LtdcHandle, Xpos1, Ypos1, 0); /* reconfigure the layer2 position without Reloading*/ HAL_LTDC_SetWindowPosition_NoReload(&LtdcHandle, Xpos2, Ypos2, 1); /*Ask for LTDC reload within next vertical blanking*/ ReloadFlag = 0; HAL_LTDC_Reload(&LtdcHandle,LTDC_RELOAD_VERTICAL_BLANKING); while(ReloadFlag == 0) { /* wait till reload takes effect (in the next vertical blanking period) */ } }以下程序,还原两个图层的位置。最后的运行结果就是两个图层上的两个图像反复变换位置。
for (index = 0; index < 32; index++) { /* calculate new picture position */ PicturesPosition(&Xpos2, &Ypos2, &Xpos1, &Ypos1, (index+1)); /* reconfigure the layer1 position without Reloading*/ HAL_LTDC_SetWindowPosition_NoReload(&LtdcHandle, Xpos1, Ypos1, 0); /* reconfigure the layer2 position without Reloading*/ HAL_LTDC_SetWindowPosition_NoReload(&LtdcHandle, Xpos2, Ypos2, 1); /*Ask for LTDC reload within next vertical blanking*/ ReloadFlag = 0; HAL_LTDC_Reload(&LtdcHandle,LTDC_RELOAD_VERTICAL_BLANKING); while(ReloadFlag == 0) { /* wait till reload takes effect (in the next vertical blanking period) */ } }
|
|