Skip to content

Commit

Permalink
BF: fix to new timing mechanism for first frame of a routine
Browse files Browse the repository at this point in the history
For clock='now' we weren't taking into account the fact that the time
could have gone BEYOND the next refresh already and ended up adding in
that as an effective gap before presenting
  • Loading branch information
peircej committed Sep 6, 2019
1 parent 9132bc3 commit 8ddab41
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions psychopy/visual/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

from psychopy.contrib.lazy_import import lazy_import
from psychopy import colors
import math
from psychopy.clock import monotonicClock

# try to find avbin (we'll overload pyglet's load_library tool and then
Expand Down Expand Up @@ -816,16 +817,15 @@ def getFutureFlipTime(self, targetTime=0, clock=None):
timeNext = lastFlip + self.monitorFramePeriod
now = baseClock.getTime()
if (now + targetTime) > timeNext: # target is more than 1 frame in future
extraFrames = round((now + targetTime - timeNext)/self.monitorFramePeriod)
extraFrames = math.ceil((now + targetTime - timeNext)/self.monitorFramePeriod)
thisT = timeNext + extraFrames*self.monitorFramePeriod
else:
thisT = timeNext

# convert back to target clock timebase
if clock=='ptb': # add back the lastResetTime (that's the clock difference)
output = thisT + baseClock.getLastResetTime()
elif clock=='now': # time from now is easy!
output = timeNext - now
output = thisT - now
elif clock:
output = thisT + baseClock.getLastResetTime() - clock.getLastResetTime()
else:
Expand Down

0 comments on commit 8ddab41

Please sign in to comment.