Multibuffer and WM_MULTIBUF_ENABLE

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • Multibuffer and WM_MULTIBUF_ENABLE

    Hi,
    I am using double buffering with the GUIDRV_LIN_16 display driver. I would like to use WM_MULTIBUF_ENABLE but are not sure what "automatic use of multiple buffers" mean. Is there an example of how WM_MULTIBUF_ENABLE is used? Other than seting the NUM_BUFFER to 2, and define my VRAM_ADDR, what else do I need to do? Do I need to add functions to ShowBuffer, CopyBuffer to my display drivers?
    Thank you for your help.
  • Hello Andrian,
    Thank you for your help. My confusion is that I am not sure what automatic means? Does that mean if I enable WM_MULTIBUF_ENABLE(1), then I don't need to use any of the GUI_MULITBUF APIs? What about configurations for LCD_X_Config() and LCD_X_DisplayDriver, does these need to be configure if I enable WM_MULTIBUF_ENABLE?
    The configuration example for LCD_X_DisplayDriver() show code to make the given buffer visible by setting the address and then call the GUI_MULTIBUF_Confirm(). If WM is doing this automatically, how does my display driver know which buffer to display and when?
    I am using GUIDRV_LIN_16, what do I need to do to ensure that this driver supports multi buffer in order to use WM_MULTIBUF_ENABLE?
    Could you please explain it in more details? I have read the chapter for Multiple buffering and still have questions.
    Thank you,
    Nosreme ?( ?(
  • Hello nosreme,

    If the function WM_MULTIBUF_Enable() is used to enable automatic Multiple Buffering the Window Manager uses the MULTIBUF functionality to switch buffers. The actual switching of the buffers still needs to be implemented as described in the section "Multiple buffering" -> "Configuration" in the emWin user manual.

    Best regards,
    Adrian
  • Hello Adrian,
    I have implement the double buffer just as described in "Multiple buffering" -> "Configuration" and I have also enabled WM_MULTIBUF_Enable() in my MainTask() right after GUI_Init().
    I started with single buffer so I know my program works with single buffer. When I turn the double buffer implementation on and with the WM_MULTIBUF_Enable(1), it switch the buffer only once. I notice that LCD_X_SHOWBUFFER cmd/msg is only execute once.
    I am using mostly WM widgets with callback functions. I then tested by adding some GUI_MULTIBUF_BEGIN() and GUI_MULTIBUF_END() and I see LCD_X_SHOWBUFFER cmd being execute more. However, where I added these GUI_MULTIBUF_BEGIN() and END() must not be right, because the program becames very slow and unresponsive.
    I thought if I enable WM_MULTIBUF_Enable(), I didn't have to worry about GUI_MULTIBUF_BEGIN() / _END(). Is my assumption wrong? Is there something I need to add to WM_PAINT message for LCD_X_HOWBUFFER to be excuted more than once? Or is there something I forget to do?
    Thank you very much for your help,
    nosreme
  • Hello nosreme,

    A single call of WM_MULTIBUF_Enable() should be sufficient. The Window Manager switches buffers every time drawing of windows is processed / finished using GUI_MULTIBUF_Begin() and GUI_MULTIBUF_End(). If for some reason your windows invalidate each other while WM_PAINT is processed, the Window Manager never comes to the state of being "done". In such a scenario GUI_MULTIBUF_End() is never called.

    Please use the WM_PAINT message for drawing operations only.

    Best regards,
    Adrian
  • Hello Adrian,
    Thank you for the explaination and you have been very helpful. My program are stup very much like the example in WidgeMidScheme provided with the source (with the exception of the "AutoMode" in the mainloop where it going through the loop and modify the widges). The main dialog are created with a call to GUI_CreateDialogBox and the callback have more initialization in WM_INIT_DIALOG, I have almost nothing in WM_PAINT message (or it is processed as WM_DefaultProc). I only have 1 main dialog window. Does WM multibuf support only applies to drawing operations done in WM_PAINT message? Any suggestions?
    FYI, While debugging, I added GUI_MULTIBUF_Begin() and GUI_MULTIBUF_End() at the beginnning/end of my WM_INIT_DIALOG. I see the buffer being switched but it is very very slow, my mouse can bearly move, but the buffer did switched.
    Thanks,
    nosreme
  • Hello nosreme,

    Multiple Buffering is not limited at all, but when using WM_MULTIBUF_Enable() switching of frame buffers is done only when messages are processed by the Window Manager.

    I would recommend you to request support at your emWin supplier. They should be able to find the reason for your implementation to work slowly.

    Best regards,
    Adrian