LTDC reading from double buffer

683 views
asked Jan 31, 2017 in System Integration by Kotula
Hello Embedded-Wizard Team!

I got my Embedded Wizard GUI up and running on a third party STM32F4-Board. Debugging with eclipse now works too! It really makes fun working with your tool :-)

The goal is now to show a camera-stream inside the UI. I've read from another thread to use a rectangle in toplayer, where we can look through. Setting up the rectangle worked perfectly.

Now I am wondering where to write the video data from the camera into the buffers so that it is displayed within the rectangle area. I use double buffer mode and offscreen buffer is turned off. My problem is that I couldn't understand how the LTDC (LCD TFT Controller) and the double buffer work together. Does the LTDC get switched to the buffer that is not being accessed by the processor? How can I find out to which of the two buffers I should write the video data?

Is the whole UI data loaded from flash to the framebuffer during initialisation?

Thanks!

Best regards,

Markus

1 Answer

+1 vote
answered Feb 1, 2017 by Manfred Schweyer
Hi Markus,

first of all, thanks a lot for the positive feedback! :-)

In principle there are two possibilities to combine the camera image with the user interface:

1.) Using a separate hardware layer - The LTDC module is able to read two different framebuffers and to combine them together. This means, the foreground buffer contains the user interface, the background buffer contains the camera image. In order to make the camera image visible, it is necessary to place a transparent rectangle within the UI application to let the video "shine through".

The advantage of this approach: Simple solution. Each software part (camera / Embedded Wizard UI application) can update its framebuffer independently. The disadvantage of this solution: The LTDC has to read two framebuffers permanently from the SDRAM (e.g. 60 times per second), which costs a certain amount of memory bandwidth.

2.) Drawing the camera image directly into the framebuffer of the UI application.

Of course, you can overwrite the framebuffer content (backbuffer) that is previously prepared by Embedded Wizard. In case you are using the mode EW_USE_DOUBLE_BUFFER the LTDC will get an notification about the new framebuffer address directly after the graphics composition is done (see function EwSetFramebufferAddress() within the file BoardConfig.c or function EwBspSetFramebufferAddress() within the file ew_bsp_display.c). You can hook into this function and overwrite the framebuffer content.

The advantage: Simple solution, fast, efficient. The disadvantage: You have to know what you do, otherwise you will overwrite the UI content. And: You can not combine the video image with the user interface, e.g. you cannot place a button over the camera image.

3.) Usage of Views::Applet

Another possible approach is to use the class Views::Applet in order to display external decoded content within an Embedded Wizard UI application. As example please have a look into the installed example 'Applet'.
The usage of Views::Applet is recommended in cases you want to integrate an external application into the graphics composition of your Embedded Wizard UI application.

This infrastructure is a generic approach to include external content into the composition of the UI application - but this is much more work than (1) or (2).

I hope this answers your question...

Let us know the result!
commented Feb 2, 2017 by Kotula
Thanks for your good answer!

For others who are reading this, keep in mind that solution 1 only works when using RGBA8888! I spent a couple hours wondering why this just doesn't work until I realised that this cannot work with RGB888 :-D

I will now proceed with solution 2 :-)
commented Feb 2, 2017 by Manfred Schweyer
Yes, of course!

Sorry that I did not metion this explicitly - in case of solution (1) the framebuffer of the UI application has to contain an alpha channel, otherwise you cannot draw a transparent rectangle...

This means, RGB888 and RGB565 will not be suitable for this approach.

Thanks for your comment.

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...