野火电子论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 12611|回复: 1

利用火哥的LCD_WriteBMP的函数发出刷新非常的慢,求帮助!

[复制链接]
发表于 2016-8-16 10:33:25 | 显示全部楼层 |阅读模式
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也是慢的。

回复

使用道具 举报

发表于 2016-8-16 11:57:56 | 显示全部楼层
要快的话可以考虑使用DMA2D
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

联系站长|手机版|野火电子官网|野火淘宝店铺|野火电子论坛 ( 粤ICP备14069197号 ) 大学生ARM嵌入式2群

GMT+8, 2024-9-22 17:28 , Processed in 0.040365 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表