rusocsci package¶
Submodules¶
rusocsci.buttonbox module¶
RuSocSci module for the BITSI buttonbox
Copyright (C) 2013-2014 Wilbert van Ham, Radboud University Nijmegen Distributed under the terms of the GNU General Public License (GPL) version 3 or newer.
Bases:
object
Object that connects tot RuSocSci BITSI buttonbox. Typical usage:
from rusocsci import buttonbox bb = buttonbox.Buttonbox() # connect to last inserted buttonbox print("Press any key") l = bb.waitKeys(10) if l: print("key pressed: {}".format(l[0])) else: print("no key pressed.")
or for non-blocking input (using the Python 3 print function):
from __future__ import print_function from rusocsci import buttonbox import time, sys bb = buttonbox.Buttonbox() # connect to last inserted buttonbox print("Press any key") while not len(bb.getKeys()): # while there is no input print(".", end='') sys.stdout.flush() time.sleep(1)
Clear previous events that are still in the input buffer.
Returns a list of buttons that were pressed on the buttonbox.
Parameters: - buttonList : None or []
Allows the user to specify a set of keys to check for. Only keypresses from this set of keys will be removed from the keyboard buffer. If the keyList is None all keys will be checked and the key buffer will be cleared completely. NB, pygame doesn’t return timestamps (they are always 0)
- timeStamped : False or True or Clock
If True will return a list of tuples instead of a list of keynames. Each tuple has (keyname, time). If a core.Clock is given then the time will be relative to the Clock‘s last reset there is no timestamp in our buttonbox. Use buttonbox.waitkeys if you want timestamps.
Mutatis Mutandis identical to getButtons
Mutatis Mutandis identical to setLeds()
Set buttonbox LEDs to a certain pattern
Same as getButtons(), but halts everything (including drawing) while awaiting input from buttonbox. Implicitly clears buttonbox, so any preceding buttonpresses will be lost.
Parameters: - maxWait : any numeric value.
Maximum number of seconds period and which buttons to wait for. Default is float(‘inf’) which simply waits forever.
- buttonList:
List of one character strings containing the buttons to react to. All other button presses will be ignored. Note that for BITSI buttonboxes the buttons are identified by capital letters upon press and by lower case letters upon release.
Returns None if times out. Returns a list of one character upon succes, like the PsychoPy event module.
Mutatis Mutandis identical tot waitButtons
Set buttonbox LEDs to a certain pattern and wait a while. Reset afterwards.
rusocsci.experiment module¶
RuSocSci module for the BITSI buttonbox
Copyright (C) 2013-2015 Wilbert van Ham, Radboud University Nijmegen Distributed under the terms of the GNU General Public License (GPL) version 3 or newer.
rusocsci.extended module¶
RuSocSci module for the BITSI extended buttonbox
Copyright (C) 2013,2014 Wilbert van Ham, Radboud University Nijmegen Distributed under the terms of the GNU General Public License (GPL) version 3 or newer.
-
class
rusocsci.extended.
Extended
(id=0, port=None)[source]¶ Bases:
rusocsci.buttonbox.Buttonbox
rusocsci.joystick module¶
RuSocSci module for the red joystick
Copyright (C) 2013 Wilbert van Ham, Radboud University Nijmegen Distributed under the terms of the GNU General Public License (GPL) version 3 or newer.
- Known issues:
- All usb2serial devices are detected. The list of joysticks therefore also contains buttonboxes.
rusocsci.utils module¶
RuSocSci module for utilities, like listing USB to serial devices and connecting to them.
# Copyright (C) 2013 Wilbert van Ham, Radboud University Nijmegen # Distributed under the terms of the GNU General Public License (GPL) version 3 or newer.
- Known issues:
- All usb to serial devices are detected. The list of devices therefore contains joysticks, buttonboxes and other usb to serial devices.
-
class
rusocsci.utils.
HideStderr
(*args, **kw)[source]¶ Bases:
object
A context manager that blocks stderr for its scope, usage:
from rusocsci import utils import os with utils.HideStderr(): os.system('ls noexistentfile') # error will not show
-
class
rusocsci.utils.
HideStdout
(*args, **kw)[source]¶ Bases:
object
A context manager that blocks stdout for its scope, usage:
from rusocsci import utils import os with utils.HideStdout(): os.system('ls -l') # output will not show
-
rusocsci.utils.
getPort
(id=0, port=None)[source]¶ Return serial port. id is position in list (0 is latest), port is ‘COM1’, /dev/tty, 0 or something similar. Note that port can also be a real serial port (non USB). returns serial connection and id string.