Skip to content

Commit 8ddab41

Browse files
committed
BF: fix to new timing mechanism for first frame of a routine
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
1 parent 9132bc3 commit 8ddab41

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

psychopy/visual/window.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
from psychopy.contrib.lazy_import import lazy_import
2626
from psychopy import colors
27+
import math
2728
from psychopy.clock import monotonicClock
2829

2930
# try to find avbin (we'll overload pyglet's load_library tool and then
@@ -816,16 +817,15 @@ def getFutureFlipTime(self, targetTime=0, clock=None):
816817
timeNext = lastFlip + self.monitorFramePeriod
817818
now = baseClock.getTime()
818819
if (now + targetTime) > timeNext: # target is more than 1 frame in future
819-
extraFrames = round((now + targetTime - timeNext)/self.monitorFramePeriod)
820+
extraFrames = math.ceil((now + targetTime - timeNext)/self.monitorFramePeriod)
820821
thisT = timeNext + extraFrames*self.monitorFramePeriod
821822
else:
822823
thisT = timeNext
823-
824824
# convert back to target clock timebase
825825
if clock=='ptb': # add back the lastResetTime (that's the clock difference)
826826
output = thisT + baseClock.getLastResetTime()
827827
elif clock=='now': # time from now is easy!
828-
output = timeNext - now
828+
output = thisT - now
829829
elif clock:
830830
output = thisT + baseClock.getLastResetTime() - clock.getLastResetTime()
831831
else:

0 commit comments

Comments
 (0)