Skip to content

Commit

Permalink
ADD QR coding python util
Browse files Browse the repository at this point in the history
  • Loading branch information
andycon committed Dec 3, 2020
1 parent 02c2149 commit f06b288
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions QRCoding/QR_util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from psychopy import event, visual, core, clock
import qrcode
import time

def waitTrigger(win, runNum, acqNum, qrDur=.05, qrPos=(-.5,-.5), qrSize=.2):


data = {"acqNum": acqNum,
"runNum": runNum,
"trialStart": time.time()
}

print("Waiting for trigger pulse ... or key stroke '5'")
event.waitKeys(keyList=['5'])
clk = clock.Clock()
data["runStart"] = time.time()

qr = visual.ImageStim(win,
qrcode.make(str(data)),
pos=qrPos
)
qr.size = qr.size*qrSize
qr.draw()
win.flip()
core.wait(qrDur)
return clk

def endRun(win, qrDur=.05, qrPos=(-.5,-.5), qrSize=.2):

data = {"runEnd": time.time()}

qr = visual.ImageStim(win,
qrcode.make(str(data)),
pos=qrPos
)
qr.size = qr.size*qrSize
qr.draw()
win.flip()
core.wait(qrDur)

0 comments on commit f06b288

Please sign in to comment.