Limit/Stabilize framerate on RaspberryPi4 + Projector

Hi,

I am trying a custom setup, where I run Psychopy on a RPi4 connected to a Projector via the GPIO pins. The stimulus I am trying to present is a simple flickering at 60Hz, see code below:

from psychopy import visual, core
import numpy as np 

# experiment duration in seconds
duration = 5 

# --- Setup the Window ---
win = visual.Window(size=(1920, 1080), units='norm', fullscr=True)
#frameRate=win.getActualFrameRate() doesnt work without monitor, fix instead
framerate = 60
frameIntervall=1.0/frameRate
#prepare screen
white=visual.Rect(win, width=2, height=2, pos=(0,0))
white.setColor([1,1,1], colorSpace='rgb')
black=visual.Rect(win, width=2, height=2, pos=(0,0))
black.setColor([-1,-1,-1], colorSpace='rgb')
win.recordFrameIntervals = True   
current_frame=0

trialClock=core.Clock()
while current_frame < frameRate*duration:
    t=trialClock.getTime()
    if t // frameIntervall % 2 ==1:
        black.draw()
    else:
        white.draw()
    win.flip()
    current_frame+=1

win.close()
avg_frameDuration=np.sum(win.frameIntervals)/len(win.frameIntervals)*1000
print("Average Frame Duration: ", avg_frameDuration)
print(win.frameIntervals)
core.quit()

When using getActualFrameRate(), this works well on a regular PC monitor at very constant 1920x1080p @ 60Hz. The Projector supports 1920x1080p @ 60Hz. However, with the projector and no monitor attached, print(win.frameIntervals) outputs frame durations between 10ms and 50ms.

As a first step, I would like to “limit” the refresh rate to be not faster than something like 16.67ms. This usually happens when the window checks the refresh rate of the attached screen, right? But in my case there is non, so I would like to do this manually.

Any ideas?