Skip to content

Commit

Permalink
NF: Add StimTracker backend to Builder
Browse files Browse the repository at this point in the history
  • Loading branch information
TEParsons committed Oct 2, 2024
1 parent 324179c commit c788ab6
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 6 deletions.
66 changes: 66 additions & 0 deletions psychopy_cedrus/components/stimtracker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
from psychopy.experiment.components.buttonBox import ButtonBoxComponent
from psychopy.experiment.routines.photodiodeValidator import PhotodiodeValidatorRoutine
from psychopy.experiment import getInitVals, Param
from psychopy.experiment.plugins import DeviceBackend
from psychopy.localization import _translate
from . import util


class StimTrackerPhotodiodeValidatorBackend(DeviceBackend):
# which component is this backend for?
component = PhotodiodeValidatorRoutine
# what value should Builder use for this backend?
key = "stimtracker"
# what label should be displayed by Builder for this backend?
label = _translate("Cedrus StimTracker")
# what hardware classes are relevant to this backend?
deviceClasses = ["psychopy_cedrus.stimtracker.StimTrackerPhotodiodeGroup"]

def getParams(self):
return util.getXidPhotodiodeParams(key="stimtracker")

def addRequirements(self):
"""
Add any required module/package imports for this backend
"""
self.exp.requireImport(
importName="stimtracker",
importFrom="psychopy_cedrus"
)

def writeDeviceCode(self, buff):
return util.writeXidPhotodiodeCode(
self,
buff,
cls="psychopy_cedrus.stimtracker.StimTrackerPhotodiodeGroup",
key="stimtracker"
)



class StimTrackerButtonBoxBackend(DeviceBackend):
"""
Adds a basic serial connection backend for ButtonBoxComponent, as well as acting as an example for implementing
other ButtonBoxBackends.
"""
key = "stimtracker"
label = _translate("Cedrus StimTracker")
component = ButtonBoxComponent
deviceClasses = ["psychopy_cedrus.stimtracker.StimTrackerButtonGroup"]

def getParams(self):
return util.getXidButtonBoxParams(key="stimtracker")

def addRequirements(self: ButtonBoxComponent):
self.exp.requireImport(
importName="stimtracker",
importFrom="psychopy_cedrus"
)

def writeDeviceCode(self, buff):
return util.writeXidButtonBoxCode(
self,
buff,
cls="psychopy_cedrus.stimtracker.StimTrackerButtonGroup",
key="stimtracker"
)
12 changes: 6 additions & 6 deletions psychopy_cedrus/stimtracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ def __init__(

class StimTrackerButtonGroup(BaseXidButtonGroup):
def __init__(
self, index=0, enableResponses=True
self, pad=0, channels=8, enableResponses=True
):
# initialise
BaseXidButtonGroup.__init__(
self, index=index
self, pad=pad, channels=channels
)
# allow USB input (it's disabled by default)
if enableResponses:
Expand All @@ -31,11 +31,11 @@ def __init__(

class StimTrackerPhotodiodeGroup(BaseXidPhotodiodeGroup):
def __init__(
self, index=0, enableResponses=True
self, pad=0, channels=3, enableResponses=True
):
# initialise
BaseXidPhotodiodeGroup.__init__(
self, index=index
self, pad=pad, channels=channels
)
# allow USB input (it's disabled by default)
if enableResponses:
Expand All @@ -45,11 +45,11 @@ def __init__(

class StimTrackerVoicekeyGroup(BaseXidVoicekeyGroup):
def __init__(
self, index=0, enableResponses=True
self, index=0, channels=3, threshold=None, enableResponses=True
):
# initialise
BaseXidDevice.__init__(
self, index=index
self, index=index, channels=channels, threshold=threshold
)
# allow USB input (it's disabled by default)
if enableResponses:
Expand Down

0 comments on commit c788ab6

Please sign in to comment.