Skip to content

Instantly share code, notes, and snippets.

@smathot
Created September 2, 2012 11:59
Show Gist options
  • Select an option

  • Save smathot/3597692 to your computer and use it in GitHub Desktop.

Select an option

Save smathot/3597692 to your computer and use it in GitHub Desktop.
Trigger test
# Create a canvas to show info on screen
from openexp.canvas import canvas
canvas = canvas(self.experiment)
from ctypes import windll, c_ubyte
io = windll.dlportio # requires dlportio.dll !!!
# Define port:
port = 0x4cf8
# Execute the script below twice, once in the old way, once in the
# newly-suggested way:
for change_to_ubyte in (False, True):
# Send the trigger for all values between 0 and 255:
for trigger in range(0,256):
# In the second run, change trigger to ubyte:
if change_to_ubyte:
trigger = c_ubyte(trigger)
# Send the trigger
io.DlPortWritePortUchar(port, trigger)
# And also log the sent trigger to the OpenSesame log file:
self.experiment.log(trigger)
# Show some info
canvas.clear()
canvas.text('%s sent (ubyte = %s)' % (trigger, change_to_ubyte))
canvas.show()
# Wait a bit
self.sleep(100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment