初中生
最后登录1970-1-1
在线时间 小时
注册时间2019-5-16
|
楼主 |
发表于 2019-5-17 08:27:34
|
显示全部楼层
[mw_shl_code=c,true]int main(void)
{
LED_GPIO_Config();
LCD_Init();
LCD_LayerInit();
LTDC_Cmd(ENABLE);
LCD_SetLayer(LCD_BACKGROUND_LAYER);
LCD_Clear(LCD_COLOR_WHITE);
LCD_SetLayer(LCD_FOREGROUND_LAYER);
LCD_SetTransparency(0xFF);
LCD_Clear(LCD_COLOR_BLACK);
LCD_SetLayer(LCD_FOREGROUND_LAYER)
Delay(0xfff);
LCD_SetLayer(LCD_FOREGROUND_LAYER);
LCD_SetTransparency(0xff);
LCD_Clear(LCD_COLOR_BLACK);
while(1)
{
LCD_DisplayPicture(100, 100, 300, 124,gImage_color);
Delay(0xFFFFFF);
}
}
void LCD_DisplayPicture(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height,const uint8_t *image)
{
DMA2D_InitTypeDef DMA2D_InitStruct;
DMA2D_FG_InitTypeDef DMA2D_FG_InitStruct;
uint32_t DMA2D_OutAdd;
/* Enable the DMA2D Clock */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2D, ENABLE);
/* DMA2D configuration */
DMA2D_DeInit();
/* Transfer mode */
DMA2D_InitStruct.DMA2D_Mode = DMA2D_M2M;
/* Color mode */
DMA2D_InitStruct.DMA2D_CMode = DMA2D_RGB888;
// DMA2D_OutAdd = CurrentFrameBuffer + 3*(Width*Ypos + Xpos);
DMA2D_OutAdd = CurrentFrameBuffer + 3*(LCD_PIXEL_WIDTH*Ypos + Xpos);
/* Output Address */
DMA2D_InitStruct.DMA2D_OutputMemoryAdd = DMA2D_OutAdd;
/* Number of lines : height */
DMA2D_InitStruct.DMA2D_NumberOfLine = Height;
/* Number of pixel per line : width */
DMA2D_InitStruct.DMA2D_PixelPerLine = Width;
/* Initialize the alpha and RGB values */
// DMA2D_InitStruct.DMA2D_OutputGreen = 0;
// DMA2D_InitStruct.DMA2D_OutputBlue = 130;
// DMA2D_InitStruct.DMA2D_OutputRed = 228;
// DMA2D_InitStruct.DMA2D_OutputAlpha = 0;
/* Initialize the output offset */
DMA2D_InitStruct.DMA2D_OutputOffset = LCD_PIXEL_WIDTH- Width;
/* Initialize DMA2D */
DMA2D_Init(&DMA2D_InitStruct);
/* Configure default values for foreground */
DMA2D_FG_StructInit(&DMA2D_FG_InitStruct);
/* Configure DMA2D foreground color mode */
DMA2D_FG_InitStruct.DMA2D_FGCM = DMA2D_RGB888;
/* Configure Input Address */
DMA2D_FG_InitStruct.DMA2D_FGMA = (uint32_t)*image;
/* Initialize foreground */
DMA2D_FGConfig(&DMA2D_FG_InitStruct);
/* Start Transfer */
DMA2D_StartTransfer();
/* Wait for CTC Flag activation */
while(DMA2D_GetFlagStatus(DMA2D_FLAG_TC) == RESET)
{
}
}
[/mw_shl_code]
|
|