cancel
Showing results for 
Search instead for 
Did you mean: 

screen tearing when using .invalidate on the STM32H735G-DK

tmehok
Associate II

PROBLEM:

I do not believe this is a bug. I am doing everything I can to read into this issue it seems like I am either not enabling all the correct options or I am using .invalidate wrong.

This is what my GUI looks like from a basic design.

Basic_SIM_Picture.PNG

This is what it looks like when I run the TouchGFX simulator(the right image is gone because I initialize it as false until it receives a signal)

Basic_SIM_Picture.PNG

This is the tearing image I am having trouble with(currently no inputs).

board_tearing.png

I am basing this example on a set of tutorials I found online, https://www.youtube.com/watch?v=Y7d6-59YQu8&t=525s.

At my current level of C programming he seems to provide a good amount of details. Where I fall short is once I start to run it on the board. 

CODE IN QUESTION:

 

#include <gui/screen1_screen/Screen1View.hpp>

Screen1View::Screen1View()
{
}

void Screen1View::setupScreen()
{
    Screen1ViewBase::setupScreen();
}

void Screen1View::tearDownScreen()
{
    Screen1ViewBase::tearDownScreen();
}

void Screen1View::setLight(bool state)
{
    Light_ON.setVisible(state);
    Light_OFF.setVisible(!state);
    Light_ON.invalidate();
    Light_OFF.invalidate();
}

 

 

WHAT I HAVE TRIED:

-> My first impression was that I was refreshing my screen to fast. I took out the .invalidate line, the gentlemen in the tutorials described it as a way to let the system know the widgets graphical representation needs to be reset. If I did that it would stop "tearing" and stay still, no matter what input I gave in D6(PD15) which I set as my GPIO Input. 

-> I created a timer which would only call .invalidate every second. This partially worked! it correctly showed my inputs were working  and the images changed but alas every second before the new image showed up it would "tear". All other examples I saw of the STM32H735G-DK did not do this.

-> I looked more into invalidate. The closest I got to a proper explanation was that some boards use "Double buffer". Double buffer seems to be a way to ensure the board will not try to clear and write to the screen at the same time. I am unsure of how to find the option to start double buffering.

ENDING:

Although double buffering may not be the issue, it is my best first steps. If this does not seem plausible and you guys have other ideas on what could be causing this issue please let me know. Thank you for all of your help.

 

 

NOTE: it says "your post has changed because of invalid HTML" I apologize if the grammar is strange or missing in any areas I missed.

13 REPLIES 13
SofLit
ST Employee

Hello @tmehok ,

Please review these recommendations on how to post a thread on this community especially how to share a code source.

Thank you for your understanding.

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
ALAMI_Othmane
Associate III

Maybe you need to invalidate the cache in the flushing operation, to force the LTDC to use the hole frame buffer instead of some cached data

void TouchGFXGeneratedHAL::flushFrameBuffer(const touchgfx::Rect& rect)

{

// invalidate the cache before flushing

SCB_CleanInvalidateDCache();

SCB_InvalidateICache();

HAL::flushFrameBuffer(rect);

}

ALAMI_Othmane
Associate III

Or your frame buffer is located in the same area where your instructions are, some times access priority between CPU and LTDC to the RAM ( internal or external)  create that starving issue

 

tmehok
Associate II

These few lines of code definitely changed what was happening with the display but did not fix it. I read through your second post; I am not to that knowledge level yet to hone in on where I can access and edit that code where access to the CPU and the LTDC can be found. Do you have any other ideas or resources I could look at. In the mean time I will search through the documentation for this board.

 

New_board_tearing.png

Thank you for your time.

ALAMI_Othmane
Associate III

share the hole project or the .map file so I can help

tmehok
Associate II

I zipped the file, let me know if this is accessible to you or if you would like the whole project in a different format.

I see that you invalidate the cache after flushing, it's incorrect ALAMI_Othmane_0-1719851608244.png

need to add :

SCB_CleanInvalidateDCache();

    SCB_InvalidateICache();
 
before calling :
TouchGFXGeneratedHAL::flushFrameBuffer(rect);
 
without recalling: 
HAL::flushFrameBuffer(rect);
 
like :
ALAMI_Othmane_1-1719851901700.png

 

 

 

 

tmehok
Associate II

This has not seemed to change the current view on the screen, I waited a while to respond so I could test a few basic things to make sure I didn't have anything going on over at my side, here is the new zip.

Thank you for your time.

I was using CHAT GPT to better understand the lines you gave me for the code. The line "HAL::flushFrameBuffer(rect)"  is used to "flush" a certain rectangular part of the screen to my understanding. Does this mean I should be setting rect somewhere?