Changes

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

Navigation menu