学前班
最后登录1970-1-1
在线时间 小时
注册时间2016-8-16
|
void LCD_WriteBMP(uint32_t BmpAddress)
{
uint32_t index = 0, size = 0, width = 0, height = 0, bit_pixel = 0;
uint32_t Address;
uint32_t currentline = 0, linenumber = 0;
uint32_t offset;
Address = CurrentFrameBuffer;
/* Read bitmap size */
size = *(__IO uint16_t *) (BmpAddress + 2);
size |= (*(__IO uint16_t *) (BmpAddress + 4)) << 16;
/* Get bitmap data address offset */
index = *(__IO uint16_t *) (BmpAddress + 10);
index |= (*(__IO uint16_t *) (BmpAddress + 12)) << 16;
/* Read bitmap width */
width = *(uint16_t *) (BmpAddress + 18);
width |= (*(uint16_t *) (BmpAddress + 20)) << 16;
/* Read bitmap height */
height = *(uint16_t *) (BmpAddress + 22);
height |= (*(uint16_t *) (BmpAddress + 24)) << 16;
/* Read bit/pixel */
bit_pixel = *(uint16_t *) (BmpAddress + 28);
if (CurrentLayer == LCD_BACKGROUND_LAYER)
{
/* reconfigure layer size in accordance with the picture */
LTDC_LayerSize(LTDC_Layer1, width, height);
LTDC_ReloadConfig(LTDC_VBReload);
/* Reconfigure the Layer pixel format in accordance with the picture */
if ((bit_pixel/8) == 4)
{
LTDC_LayerPixelFormat(LTDC_Layer1, LTDC_Pixelformat_ARGB8888);
LTDC_ReloadConfig(LTDC_VBReload);
}
else if ((bit_pixel/8) == 2)
{
LTDC_LayerPixelFormat(LTDC_Layer1, LTDC_Pixelformat_RGB565);
LTDC_ReloadConfig(LTDC_VBReload);
}
else
{
LTDC_LayerPixelFormat(LTDC_Layer1, LTDC_Pixelformat_RGB888);
LTDC_ReloadConfig(LTDC_VBReload);
}
}
else
{
/* reconfigure layer size in accordance with the picture */
LTDC_LayerSize(LTDC_Layer2, width, height);
LTDC_ReloadConfig(LTDC_VBReload);
/* Reconfigure the Layer pixel format in accordance with the picture */
if ((bit_pixel/8) == 4)
{
LTDC_LayerPixelFormat(LTDC_Layer2, LTDC_Pixelformat_ARGB8888);
LTDC_ReloadConfig(LTDC_VBReload);
}
else if ((bit_pixel/8) == 2)
{
LTDC_LayerPixelFormat(LTDC_Layer2, LTDC_Pixelformat_RGB565);
LTDC_ReloadConfig(LTDC_VBReload);
}
else
{
LTDC_LayerPixelFormat(LTDC_Layer2, LTDC_Pixelformat_RGB888);
LTDC_ReloadConfig(LTDC_VBReload);
}
}
/* compute the real size of the picture (without the header)) */
size = (size - index);
/* bypass the bitmap header */
BmpAddress += index;
/* start copie image from the bottom */
Address += width*(height-1)*(bit_pixel/8);
offset=(2*width*(bit_pixel/8));
//LED1_OFF;
//LED2_OFF;
for(index = 0; index < size; index++)
{
*(__IO uint8_t*) (Address) = *(__IO uint8_t *)BmpAddress;
// *(__IO uint8_t*) (Address)=0xff;
/*jump on next byte */
BmpAddress++;
Address++;
currentline++;
if((currentline/(bit_pixel/8)) == width)
{
if(linenumber < height)
{
linenumber++;
Address -=offset;//(2*width*(bit_pixel/8));
currentline = 0;
}
}
}
// LED1_ON;
//LED2_ON;
}
主频180m, 屏为480*272 ,移动一帧为120ms, 若把上面的程序*(__IO uint8_t*) (Address) = *(__IO uint8_t *)BmpAddress;改为 *(__IO uint8_t*) (Address)=0xff;
需要30ms, 说明从sdram拷贝到sdram非常耗时, 我觉得即使是30ms也是慢的。
|
|