硬汉嵌入式论坛

 找回密码
 立即注册
查看: 2009|回复: 8
收起左侧

[emWin] 关于多缓冲

[复制链接]

2

主题

5

回帖

24

积分

新手上路

积分
24
发表于 2018-1-10 17:49:02 | 显示全部楼层 |阅读模式
现在多缓冲回调函数一直没有回调?这是配置函数

void LCD_X_Config(void) {
  //
  // At first initialize use of multiple buffers on demand
  //
  #if (NUM_BUFFERS > 1)
    GUI_MULTIBUF_Config(NUM_BUFFERS);
  #endif
  //
  // Set display driver and color conversion for 1st layer
  //
  GUI_DEVICE_CreateAndLink(DISPLAY_DRIVER, COLOR_CONVERSION, 0, 0);
  //
  // Display driver configuration, required for Lin-driver
  //
  if (LCD_GetSwapXY()) {
    LCD_SetSizeEx (0, YSIZE_PHYS, XSIZE_PHYS);
    LCD_SetVSizeEx(0, YSIZE_PHYS * NUM_VSCREENS, XSIZE_PHYS);
  } else {
    LCD_SetSizeEx (0, XSIZE_PHYS, YSIZE_PHYS);
    LCD_SetVSizeEx(0, XSIZE_PHYS, YSIZE_PHYS * NUM_VSCREENS);
  }
  LCD_SetVRAMAddrEx(0, (void *)VRAM_ADDR);
  //
  // Set user palette data (only required if no fixed palette is used)
  //
  #if defined(PALETTE)
    LCD_SetLUTEx(0, PALETTE);
  #endif

  //
  // Set custom functions for several operations to optimize native processes
  //
  /*LCD_SetDevFunc(0, LCD_DEVFUNC_COPYBUFFER, (void(*)(void))CUSTOM_LCD_CopyBuffer);
  LCD_SetDevFunc(0, LCD_DEVFUNC_COPYRECT,   (void(*)(void))CUSTOM_LCD_CopyRect);
  LCD_SetDevFunc(0, LCD_DEVFUNC_FILLRECT, (void(*)(void))CUSTOM_LCD_FillRect);
  LCD_SetDevFunc(0, LCD_DEVFUNC_DRAWBMP_8BPP, (void(*)(void))CUSTOM_LCD_DrawBitmap8bpp);
  LCD_SetDevFunc(0, LCD_DEVFUNC_DRAWBMP_16BPP, (void(*)(void))CUSTOM_LCD_DrawBitmap16bpp);*/
}


这是处理函数
int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void * pData) {
  int r;

  switch (Cmd) {
  case LCD_X_INITCONTROLLER: {
    //
    // Called during the initialization process in order to set up the
    // display controller and put it into operation. If the display
    // controller is not initialized by any external routine this needs
    // to be adapted by the customer...
    //
    // ...
    return 0;
  }
  case LCD_X_SETVRAMADDR: {
    //
    // Required for setting the address of the video RAM for drivers
    // with memory mapped video RAM which is passed in the 'pVRAM' element of p
    //
    LCD_X_SETVRAMADDR_INFO * p;
    p = (LCD_X_SETVRAMADDR_INFO *)pData;
    //...
    return 0;
  }
  case LCD_X_SETORG: {
    //
    // Required for setting the display origin which is passed in the 'xPos' and 'yPos' element of p
    //
    LCD_X_SETORG_INFO * p;
    p = (LCD_X_SETORG_INFO *)pData;
    //...
    return 0;
  }
  case LCD_X_SHOWBUFFER: {
    //
    // Required if multiple buffers are used. The 'Index' element of p contains the buffer index.
    //
    LCD_X_SHOWBUFFER_INFO * p;
    p = (LCD_X_SHOWBUFFER_INFO *)pData;
    mulbufferindex = p->Index;

    //...
    return 0;
  }
  case LCD_X_SETLUTENTRY: {
    //
    // Required for setting a lookup table entry which is passed in the 'Pos' and 'Color' element of p
    //
    LCD_X_SETLUTENTRY_INFO * p;
    p = (LCD_X_SETLUTENTRY_INFO *)pData;
    //...
    return 0;
  }
  case LCD_X_ON: {
    //
    // Required if the display controller should support switching on and off
    //
    return 0;
  }
  case LCD_X_OFF: {
    //
    // Required if the display controller should support switching on and off
    //
    // ...
    return 0;
  }
  default:
    r = -1;
  }
  return r;
}


初始化之后调用
GUI_Init();
WM_MULTIBUF_Enable(1);

在窗口回调函数中,调用如下GUI_MULTIBUF_End后,LCD_X_DisplayDriver并没有被同步调用?哪里出问题了?
case WM_PRE_PAINT:
      GUI_MULTIBUF_Begin();
      break;

  case WM_POST_PAINT:
      GUI_MULTIBUF_End();
      break;


回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
117635
QQ
发表于 2018-1-11 02:06:23 | 显示全部楼层
任意下载我们新版emWin教程的一个例子,除了你上面写的,还有LTDC中断,在里面要切换缓冲地址。https://forum.anfulai.cn/forum.p ... &extra=page%3D1
回复

使用道具 举报

2

主题

5

回帖

24

积分

新手上路

积分
24
 楼主| 发表于 2018-1-11 12:13:51 | 显示全部楼层
void HAL_LTDC_LineEventCallback(LTDC_HandleTypeDef *hltdc)
{
    if (mulbufferindex >= 0)
    {
        //计算显示的帧地址
        uint Addr = 0XC0000000 + mulbufferindex * 480 * 272 * 2;
        HAL_LTDC_SetAddress(hltdc, Addr, 0);//设置地址
        __HAL_LTDC_RELOAD_CONFIG(hltdc);
        GUI_MULTIBUF_ConfirmEx(0, mulbufferindex);
        mulbufferindex = -1;
    }
    HAL_LTDC_ProgramLineEvent(hltdc, 0);

}

没有问题,关键是mulbufferindex 没有被赋值,在多缓冲的回调函数里


case LCD_X_SHOWBUFFER: {
    //
    // Required if multiple buffers are used. The 'Index' element of p contains the buffer index.
    //
    LCD_X_SHOWBUFFER_INFO * p;
    p = (LCD_X_SHOWBUFFER_INFO *)pData;
    mulbufferindex = p->Index;

    //...
    return 0;
  }
回复

使用道具 举报

2

主题

5

回帖

24

积分

新手上路

积分
24
 楼主| 发表于 2018-1-11 12:16:24 | 显示全部楼层
硬汉,我看了多缓冲的例子。现在我是LCD_X_SHOWBUFFER 没有触发,配置就是上面的哪里还有问题?
回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
117635
QQ
发表于 2018-1-11 12:17:41 | 显示全部楼层
vircun 发表于 2018-1-11 12:13
void HAL_LTDC_LineEventCallback(LTDC_HandleTypeDef *hltdc)
{
    if (mulbufferindex >= 0)

HAL库的话,你多试试吧。如果是标准库,直接复制粘贴我们的驱动即可,用户仅需修改下bsp_tft_429.C文件末尾的最后一个函数。
回复

使用道具 举报

2

主题

5

回帖

24

积分

新手上路

积分
24
 楼主| 发表于 2018-1-11 14:30:07 | 显示全部楼层
硬汉,谢了。565格式的流位图显示不出来,其他的格式都有拉窗帘的现象。看到多缓冲例子有如下解释,如何处理

#if 1 /* 将此函数加入,测试发现不加入此函数,BMP565格式的位图无法正常显示 */
static int _GetBitsPerPixel(int Pixelformat)
{
        switch (Pixelformat)
        {
                case LTDC_Pixelformat_ARGB8888:
                        return 32;
                case LTDC_Pixelformat_RGB888:
                        return 24;
                case LTDC_Pixelformat_RGB565:
                        return 16;
                case LTDC_Pixelformat_ARGB1555:
                        return 16;
                case LTDC_Pixelformat_ARGB4444:
                        return 16;
                case LTDC_Pixelformat_L8:
                        return 8;
                case LTDC_Pixelformat_AL44:
                        return 8;
                case LTDC_Pixelformat_AL88:
                        return 16;
        }
        return 0;
}
#endif
回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
117635
QQ
发表于 2018-1-12 12:41:47 | 显示全部楼层
vircun 发表于 2018-1-11 14:30
硬汉,谢了。565格式的流位图显示不出来,其他的格式都有拉窗帘的现象。看到多缓冲例子有如下解释,如何处理 ...

不显示流位图,显示位图是否有问题。
这个一定要加上,否则的确显示不正常。
回复

使用道具 举报

2

主题

5

回帖

24

积分

新手上路

积分
24
 楼主| 发表于 2018-1-13 17:37:11 | 显示全部楼层
位图可以正常显示,流位图显示不出来.     我现在不知道把这个函数放到哪里?从哪里入手
回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
117635
QQ
发表于 2018-1-15 00:46:47 | 显示全部楼层
vircun 发表于 2018-1-13 17:37
位图可以正常显示,流位图显示不出来.     我现在不知道把这个函数放到哪里?从哪里入手

使用我们新版emWin教程中流位图的测试方法,测试下是否正常:
https://forum.anfulai.cn/forum.p ... &extra=page%3D1
回复

使用道具 举报

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

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2025-8-20 05:21 , Processed in 0.045480 second(s), 24 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

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