| Line 22: |
Line 22: |
| | | | |
| | == Psychopy Settings == | | == Psychopy Settings == |
| | + | <nowiki> |
| | + | #!/usr/bin/env python |
| | | | |
| | + | from psychopy import core, visual, event from rusocsci import buttonbox import logging, time |
| | | | |
| − | #!/usr/bin/env python
| + | ##Setup Section |
| − | from psychopy import core, visual, event
| |
| − | from rusocsci import buttonbox
| |
| − | import logging, time
| |
| − |
| |
| − | ## Setup Section | |
| | #logging.getLogger().setLevel(logging.DEBUG) # use this for debug info | | #logging.getLogger().setLevel(logging.DEBUG) # use this for debug info |
| − | win = visual.Window([400,300], monitor="testMonitor") | + | |
| − | bb = buttonbox.Buttonbox() | + | win = visual.Window([400,300], monitor="testMonitor") bb = buttonbox.Buttonbox() |
| − |
| + | |
| − | ## Experiment Section | + | ##Experiment Section |
| − | b = bb.waitButtons(maxWait = 10.0, buttonList=['A']) | + | |
| − | print("b: {}".format(b)) | + | b = bb.waitButtons(maxWait = 10.0, buttonList=['A']) print("b: {}".format(b)) |
| − |
| + | |
| − | ## Cleanup Section | + | ##Cleanup Section |
| − | core.quit() | + | |
| − | The following script lights the LEDs under the buttons pressed. | + | core.quit() The following script lights the LEDs under the buttons pressed. |
| | | | |
| | #!/usr/bin/env python | | #!/usr/bin/env python |
| | #from __future__ import print_function | | #from __future__ import print_function |
| − | import logging, time, sys | + | |
| − | from rusocsci import buttonbox | + | import logging, time, sys from rusocsci import buttonbox |
| − |
| + | |
| − | ## Setup Section | + | ##Setup Section |
| | + | |
| | led = [False]*8 | | led = [False]*8 |
| − |
| + | |
| − | ## Experiment Section | + | ##Experiment Section |
| − | bb = buttonbox.Buttonbox() | + | |
| − | while True: | + | bb = buttonbox.Buttonbox() while True: |
| | + | |
| | buttons = bb.getButtons() | | buttons = bb.getButtons() |
| − | if len(buttons):
| + | if len(buttons): |
| − | for c in buttons:
| + | for c in buttons: |
| − | if ord(c) >= ord('a') and ord(c) < ord('a')+8:
| + | if ord(c) >= ord('a') and ord(c) < ord('a')+8: |
| − | led[ord(c) - ord('a')] = False
| + | led[ord(c) - ord('a')] = False |
| − | elif ord(c) >= ord('A') and ord(c) < ord('A')+8:
| + | elif ord(c) >= ord('A') and ord(c) < ord('A')+8: |
| − | led[ord(c) - ord('A')] = True
| + | led[ord(c) - ord('A')] = True |
| − | bb.setLeds(led)
| + | bb.setLeds(led) |
| − | #print("buttons ({:3d}): {}{}".format(len(buttons), buttons, " "*50), end="\r")
| + | #print("buttons ({:3d}): {}{}".format(len(buttons), buttons, " "*50), end="\r") |
| − | #sys.stdout.flush()
| + | #sys.stdout.flush()</nowiki> |
| | | | |
| | == Matlab Settings == | | == Matlab Settings == |