Multiple Buffering slowing down button press

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

    • Multiple Buffering slowing down button press


      I got Multiple buffering to work finally from my Silicon Provider. But once I adapt multiple buffering, I see some strange things happening.
      1. Button press seems to have slowed down. When the button is CLICKED, it stays pressed for sometime and then releases.
      2. I put a flag to see what was going on and I just can't seem to understand the behavior of irregular timings.
      3. If I enable WM_MULTIBUFF_ENABLE(1), things seem to be going out of pace - I can see Multiple Buffering working but I have hardware running in the background and once I display a screen with widgets using WM, all the timings are wrong and things don't work the way they are suppose to.

      NOTE: I am using emFile to access Images for the screen through SD Card.

      Are there any modifications that should be done to the emFile or any other functions to get a faster response???

      I really appreciate if anyone here can give me any information possible.

      Thanks and regards,
    • Hi,

      I presume to draw the image you reload the image every time from your SD card? This might be what is causing the delay. With two buffers, the screen is essentially drawn twice and when the image is read from external memory before it is redrawn, you can imagine that this takes up a lot of extra time.

      To fix this, you can use a memory device as a container to store the image. Upon creation of the window/widget, you create a memory device and draw the external image in it. You can then simply copy the contents of the memory device to the screen every time a redrawing operation is done. This way, the image is only read from SD card once.

      You can find a sample for better understanding here.

      Best regards,

    • Hi Florian,

      Thank you for your response.
      I did something similar to what the example explains.
      I am writing images to cache so I this way I am reading images from SD card only once. Thereafter the images are read from cache. But this still doesn't help with the timing issue that exists.
      Any suggestions to what could be causing this?

      Thanks and regards,
    • Forian,

      Thank you trying to help me out.
      Could you please tell me if there is a sample of manual implementation of Multiple Buffering?

      I am trying to implement it manually rather than using WM_MULTIBUF_ENABLE().

      Appreciate all the help.

      Thanks and regards,
    • Hi,

      there are examples in the manual under "Multiple Buffering" on how to implement multi-buffering.

      The following code snippet can be used for a triple buffering implementation.

      C Source Code

      1. static void _ISR_EndOfFrame(void) {
      2. unsigned long Addr, BufferSize;
      3. if (_PendingBuffer >= 0) {
      4. //
      5. // Calculate address of the given buffer
      6. //
      7. BufferSize = (XSIZE * YSIZE * BITSPERPIXEL) / 8;
      8. Addr = _VRamBaseAddr + BufferSize * _PendingBuffer;
      9. //
      10. // Tell LCD controller the new frame buffer address
      11. //
      12. AT91C_LCDC_BA1 = Addr;
      13. //
      14. // Send a confirmation that the buffer is visible now
      15. //
      16. GUI_MULTIBUF_Confirm(_PendingBuffer);
      17. _PendingBuffer = -1;
      18. }
      19. }
      20. int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void * p) {
      21. LCD_X_SHOWBUFFER_INFO * pData;
      22. switch (Cmd) {
      23. ...
      24. case LCD_X_SHOWBUFFER:
      25. pData = (LCD_X_SHOWBUFFER_INFO *)p;
      26. //
      27. // Remember buffer index to be used by ISR
      28. //
      29. _PendingBuffer = pData->Index;
      30. break;
      31. }
      Display All
      Best regards,

    • Hi Florian,

      I have configured Multiple Buffering. I was referring to a sample that could help me understand how to call multiple buffering before drawing. Is there a sample to show me when to call GUI_MULTIBUF_Begin() while trying to display widgets?

      I look forward to hear from you.

      Thanks and regards,
    • Hi,

      when using the Window Manager, it does not really make sense to call Begin() and End() manually. You would have to call the two functions before/after each WM_PAINT for every window.

      It makes the most sense to just call WM_MULTIBUF_Enable() once after emWin has been initialized. From that point on, all buffer switching is done automatically.

      Best regards,