Brain Screen Flashing on Clear Screen

If you clear the screen and redraw everything, there is a good chance that you will see flicker. The Brain.Screen.render() method will most likely solve this but you need to understand how it works and some of the limitations to using it.

The reason you see flicker is that we usually draw directly into the V5 screen buffer. The V5 is using the contents of the screen buffer to update the display 60 timer per second. clearing the screen, redrawing an image from a file, etc. all take quite some time and there’s a good chance the V5 screen is refreshed before that is all finished, hence the flicker.

Brain.Screen.render() puts the V5 into a special mode where an area of memory called a back buffer is used for drawing. All draw commands operate on this back buffer until render() is called (the very first call to render() sets everything up, so the first time through the drawing loop you may still see the screen update). render() will pause the current thread until an appropriate time in the display refresh cycle and then quickly copy the contents of the back buffer to the screen memory.

The downside to using render() is that it has to be called somewhere for any screen drawing to be made visible, you would usually call it once in a task dedicated to drawing. It will also slow down the thread using it as it waits for the time to be able to update the display, it can feel like adding a 16mS sleep into your drawing loop.

see the code in my stopwatch demo, I think I used it there.

best way to learn about it is to try it out and see if it helps for your code.