---------------------------------------------- Lightcrafter ---------------------------------------------- .. _lightcrafter_API: API ---------------------------------------------- To interact with the lightcrafter device directly in a python script (during **compile-time** of the stimulus, see section :doc:`how_QDSpy_works`), use the follwing lightcrafter class. Note that this library requires firmware 3.0 and higher. .. autoclass:: Devices.lightcrafter.Lightcrafter :members: .. _lightcrafter_general_notes: General notes ---------------------------------------------- * There are two modes for LED control, "manual" and "sequencer". When disabling the lightcrafter LEDs in the GUI, control is switched to manual and the LEDs can be individually turned on and off (by cutting the power supply). When the LEDs are enabled in the GUI, "sequencer" is the mode of operation. Now the lightcrafter takes control and switches them depending on the way the incoming video stream (via HDMI) is interpreted. .. _lightcrafter-example-scripts: Example scripts ---------------------------------------------- Example script for setting up the lightcrafter in pattern mode (fixed exposure), for two times 8-bit color frames streaming via HDMI (e.g. mouse dichromatic stimulation). Here, the red LED illuminates the green bit planes, and the blue LED illuminates the blue bit planes. .. code-block:: python import Devices.lightcrafter as lcr import time dev = lcr.Lightcrafter(_isCheckOnly=False, _logLevel=3) res = dev.connect() if res[0] is not lcr.ERROR.OK: exit() dev.getFirmwareVersion() dev.getHardwareStatus() dev.getMainStatus() dev.getSystemStatus() dev.getVideoSignalDetectStatus() dev.stopPatternSequence() dev.setDisplayMode(lcr.DispMode.Pattern) dev.setPatternDisplayDataInputSource(lcr.SourcePat.Parallel) dev.setPatternDispLUTControl(2, True, 2, 1) dev.setPatternTriggerMode(lcr.PatTrigMode.Vsync_fixedExposure) dev.setPatternExpTimeFrPer(16666, 16666) dev.setPatternDispLUTAccessControl(lcr.MailboxCmd.OpenPat) dev.setPatternDispLUTOffsetPointer(0) dev.setPatternDispLUTData(lcr.MailboxPat.G76543210, lcr.MailboxTrig.ExternalPos, 8, lcr.MailboxLED.Red) dev.setPatternDispLUTOffsetPointer(1) dev.setPatternDispLUTData(lcr.MailboxPat.B76543210, lcr.MailboxTrig.None_, 8, lcr.MailboxLED.Blue, _trigOut1High=True) dev.setPatternDispLUTAccessControl(lcr.MailboxCmd.Close) res = dev.validateDataCommandResponse() if res[0] == lcr.ERROR.OK: dev.getHardwareStatus() dev.getMainStatus() time.sleep(1) dev.startPatternSequence() time.sleep(1) dev.getMainStatus() dev.getSystemStatus() dev.disconnect() The following script switches the lightcrafter back to video mode. .. code-block:: python import Devices.lightcrafter as lcr import time dev = lcr.Lightcrafter(_isCheckOnly=False, _logLevel=3) res = dev.connect() if res[0] is not lcr.ERROR.OK: exit() dev.getFirmwareVersion() dev.getHardwareStatus() dev.getMainStatus() dev.getSystemStatus() dev.getVideoSignalDetectStatus() dev.stopPatternSequence() dev.setInputSource(lcr.SourceSel.HDMI, lcr.SourcePar.Bit24) dev.setDisplayMode(lcr.DispMode.Video) dev.getMainStatus() dev.getSystemStatus() dev.disconnect()