We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Forcing screen updates
Page Index Toggle Pages: 1
Forcing screen updates (Read 2542 times)
Forcing screen updates
Jun 16th, 2010, 11:56pm
I know from the helpfiles that the screen is only updated at the end of the draw() function, but is there actually a way of forcing a screen update at a particular time of the sketch, e.g. just before putting a delay?
Re: Forcing screen updates
Reply #1 - Jun 17th, 2010, 4:47am
That's a FAQ.
Basically, just don't use delay()...
Use millis() instead.
I should really take time to write a full article on the topic for our brand new wiki.
Re: Forcing screen updates
Reply #2 - Jun 18th, 2010, 12:24am
Yes, this sounds like a good idea.
However, I'm not sure how to use millis() correctly for my needs.
Keeping it in a loop until some time elapses? But how does this help me update the screen? I do not want to execute draw every x-th time only, but rather more complicated have some objects which on conditions draw something or not, and while in general this should be "as fast as possible" there are certain times I want the algorithm to "to freeze" after the incident. (mainly for debugging.)
Well, I maybe "could" make a boolean and exit all loops and then use the millis() and boolean in the main-draw functions, but it seem really not very elegant to me. In particular, as I want to "hack it in & out" at several positions mainly during debugging.
That's why I would need a "stop here. Update Screen. Then pause" kind of functionality. Suggestions?
Re: Forcing screen updates
Reply #3 - Jun 18th, 2010, 1:19am
As PhiLho says, this is a FAQ, which might have prompted you to search the forum...

Entering into a loop within draw will cause the same problems as using delay(): all you'll see drawn to the screen is the result of the last iteration of the loop.

The answer is to use conditions within draw to determine what state something is in and change the result of these conditions using the value of millis() compared to a stored start time + some arbitrary threshold...
Page Index Toggle Pages: 1