When printing something on the Brain with a live update (i.e. clear screen and draw something new on the screen at least once per every time the while(true) loop repeats). I am using this for a system where the brain draws a picture of the field, then draws where my robot will start. This is for an autonomous selector. Usually when doing this, the screen with flicker or flash because the screen is going blank for a little bit right before the new code gets read. I fixed part of this issue by only having the brain clear/redraw when what it needs to draw is different from what is currently drawn. This is great and all, but once I spin my potentiometer to change what is drawn on the screen, it flickers before the new image gets drawn. Is there any way to make it not flicker at all? does it have anything to do with Brain.Screen.Render(), and if now what does that do?
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.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.