0
\$\begingroup\$

I'm trying to do double buffering using the hardware, STMF32492I.. so first I'm initalizing two layers in two different addresses.

Then I write to the back buffer, switch the back buffer..

But The problem I get multiple copies of the sprite that is animated, so its either I'm drawing to the front buffer multiple times, or the back buffer needs to be cleared.

Here is how I'm doing it

void main
{
 while (1) 
    {

        LTDC_switch_framebuffer();
        // draw spries
    }
}

void LTDC_switch_framebuffer(void)
{




    LTDC->SRCR = LTDC_SRCR_VBR;                     // reload shadow registers on vertical blank
  while ((LTDC->CDSR & LTDC_CDSR_VSYNCS) == 0);    // wait for reload
    ;
    flip ^= 1;
    BSP_LCD_SetLayerVisible(flip, ENABLE);
    BSP_LCD_SelectLayer(1-flip);


}
\$\endgroup\$
1
\$\begingroup\$

You shouldn't initialize the two layers of LTDC for double buffering. As I explained here (see under "Using double buffering") you only use one layer and change the base address of the layer (layer 1 in my case). What you do is the following: you set up two buffers in memory (generally external memory, in order to fit the entire display size in them), and initialize the LTDC base address with the starting address of one of them (this is your initial front buffer). The LTDC fetches data continuously from the buffer starting from the configured base address and when you're done updating the off-screen buffer you switch the addresses. So the front buffer becomes the off-screen back buffer (where you can update the scene) and the former back buffer becomes the new front buffer and is "presented" to the screen.

Using two layers is used for overlays and other effects, sice the two layers are both presented to the screen at the same time.

\$\endgroup\$
4
  • \$\begingroup\$ can you show a full pseudo code? \$\endgroup\$ Jun 16 '18 at 16:11
  • \$\begingroup\$ @AhmedSaleh in the link I provided you can find the full implementation at the end of the post (and code excerpts inside the article) \$\endgroup\$
    – Luca
    Jun 16 '18 at 17:55
  • \$\begingroup\$ The link is dead. Can you please repost \$\endgroup\$
    – Ankit
    Sep 6 '18 at 13:50
  • \$\begingroup\$ @Ankit it's up again \$\endgroup\$
    – Luca
    Sep 8 '18 at 0:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.