[visionegg] Re: using pygame.time.delay
- From: Andrew Straw <astraw@xxxxxxxxxxx>
- To: visionegg@xxxxxxxxxxxxx
- Date: Tue, 22 Mar 2005 11:20:42 -0800
Hi Darren,
I haven't used pygame.time.delay() myself, but it looks like it won't be
too different than time.sleep(). Both block (prevent execution from
continuing) until the desired duration is over. The difference between
the two seems to be that pygame.time.delay uses the CPU and thus: 1)
hopefully has a more accurate delay but also 2) preventing other threads
from running. Because the Vision Egg is totally single-threaded, I
wouldn't expect calling pygame.time.delay() to behave much differently
than time.sleep().
As far as getting events, I think it would totally block processing
until the delay was up. If this is OK with you, then go for it.
Otherwise, you'll have to resort to other methods. For example, record
the time your presentation started, periodically [like on every call to
swap_buffers()], check for keystrokes and check the current time. If
the current time is at or exceeds your duration, quit the loop.
Although this may appear less temporally accurate than
pygame.time.delay(), don't forget that the screen is only updated in
discrete temporal intervals set by the vertical refresh rate.
Hope that helped.
Cheers!
Andrew
Darren Weber wrote:
Hi,
I've got a series of visual images to present, each has a defined
duration. If each stimulus is presented in a for loop, I've found
that the duration of the stimulus can be handled by pygame.time.delay.
However, I wonder if this has any implications for event handling?
Does anyone using the visionegg know if this would be a problem? That
is, can pygame event handling work during pygame.time.delay?
If pygame.time.delay is problematic, how would you control the
stimulus duration? Do you need to setup a while loop that continues
to display a stimulus, checking for events and finally exits after a
certain time from onset? What is the best way to implement the
timing? Would you use pygame modules or something in the visionegg
itself?
Best, Darren
======================================
The Vision Egg mailing list
Archives: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html
--
Andrew D. Straw Post-doctoral scholar
,-. Dickinson Lab
\_/ California Institute of Technology
8||} Mailcode 138-78
/ \ Pasadena CA 91125, USA
`-^
email: astraw@xxxxxxxxxxx
office: +1 626 395 4396
======================================
The Vision Egg mailing list
Archives: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html
- References:
- [visionegg] using pygame.time.delay
- From: Darren Weber
Other related posts:
- » [visionegg] using pygame.time.delay
- » [visionegg] Re: using pygame.time.delay
- » [visionegg] Re: using pygame.time.delay
- » [visionegg] Re: using pygame.time.delay
- » [visionegg] Re: using pygame.time.delay
- » [visionegg] Re: using pygame.time.delay
Hi,
I've got a series of visual images to present, each has a defined
duration. If each stimulus is presented in a for loop, I've found
that the duration of the stimulus can be handled by pygame.time.delay.
However, I wonder if this has any implications for event handling? Does anyone using the visionegg know if this would be a problem? That
is, can pygame event handling work during pygame.time.delay?
If pygame.time.delay is problematic, how would you control the stimulus duration? Do you need to setup a while loop that continues to display a stimulus, checking for events and finally exits after a certain time from onset? What is the best way to implement the timing? Would you use pygame modules or something in the visionegg itself?
Best, Darren ====================================== The Vision Egg mailing list Archives: http://www.freelists.org/archives/visionegg Website: http://www.visionegg.org/mailinglist.html
====================================== The Vision Egg mailing list Archives: http://www.freelists.org/archives/visionegg Website: http://www.visionegg.org/mailinglist.html
- [visionegg] using pygame.time.delay
- From: Darren Weber