Skip to content

Commit

Permalink
Merge pull request #10 from TEParsons/enh-await-dispatch
Browse files Browse the repository at this point in the history
ENH: Wait longer for messages when dispatching outside a frame loop
  • Loading branch information
TEParsons authored May 22, 2024
2 parents 3633df3 + a1839ce commit 14a448d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions psychopy_bbtk/tpad.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def _setThreshold(self, threshold, channel):
self.parent.setMode(0)
# send command to set threshold
self.parent.sendMessage(f"AAO{channel+1} {threshold}")
resp = self.parent.awaitResponse()
resp = self.parent.awaitResponse(timeout=0.1)
# with this threshold, is the photodiode returning True?
measurement = None
if resp is not None:
Expand Down Expand Up @@ -170,14 +170,14 @@ def parseMessage(self, message):

return resp

def findPhotodiode(self, win, channel):
def findPhotodiode(self, win, channel=None):
# set mode to 3
self.parent.setMode(3)
self.parent.pause()
# continue as normal
return photodiode.BasePhotodiodeGroup.findPhotodiode(self, win, channel)

def findThreshold(self, win, channel):
def findThreshold(self, win, channel=None):
# set mode to 0 and lock it so mode doesn't change during setThreshold calls
self.parent.setMode(0)
self.parent.lockMode()
Expand Down Expand Up @@ -328,6 +328,9 @@ def __init__(
)
# reset timer
self.resetTimer()

def __del__(self):
self.close()

def close(self):
# set mode to 0 on exit
Expand Down

0 comments on commit 14a448d

Please sign in to comment.