def initializeDPX(): """ InitializeDPX performs a few DataPixx operations in order to ready the presentation of images. It returns the datapixx object, which must be maintained in order to continue using DataPixx. """ # Open datapixx. dpixx = dpx.open() # set videomode: Concatenate Red and Green into a 16 bit luminance # channel. dpixx.setVidMode(dpx.DPREG_VID_CTRL_MODE_M16) # Demonstrate successful initialization. dpixx.blink(dpx.BWHITE | dpx.BBLUE | dpx.BGREEN | dpx.BYELLOW | dpx.BRED) return dpixx
def __init__(self ,graphics='gpu' ,inputs='keyboard' ,photometer=None ,wdth=1024,hght=768,bg=0.0 ,fs=False,db=True,scrn=0 ,dfl=None,rfl=None,rhds=None ,lut=None): """ Initialize an HRL object. Parameters ---------- graphics : The graphics device to use. Available: 'gpu','datapixx', None. Default: 'gpu' inputs : The input device to use. Available: 'keyboard', 'responsepixx', None. Default: 'keyboard' photometer : The graphics device to use. Available: 'optical', 'minolta', None. Default: None wdth : The desired width of the screen. Default: 1024 hght : The desired height of the screen. Default: 768 bg : The background luminance on a scale from 0 to 1. Default: 0.0 fs : Whether or not to run in Fullscreen.Default: False db : Whether or not to use double buffering. Default: True scrn: Which monitor to use. Numbered 0,1... Default: 0 dfl : The read location of the design matrix. Default: None rfl : The write location of the result matrix. Default: None rhds : A list of the string names of the headers for the Result Matrix. The string names should be without spaces, e.g. 'InputLuminance'. If rfl != None, rhds must be provided. Default: None lut : The lookup table. Default: None Returns ------- hrl instance. Comes with a number of methods required to run an experiment. """ ### Load Config ### #data_files=[(os.path.expanduser('~/.config'), ['misc/hrlrc'])] #cfg = cp.RawConfigParser() #cfg.read([os.path.expanduser('~/.config/hrlrc')]) os.environ['DISPLAY'] = ':0.' + str(scrn) ## Load Datapixx ## if (graphics == 'datapixx') or (inputs == 'responsepixx'): import datapixx as dpx # Open datapixx. self.datapixx = dpx.open() # set videomode: Concatenate Red and Green into a 16 bit luminance # channel. self.datapixx.setVidMode(dpx.DPREG_VID_CTRL_MODE_M16) # Demonstrate successful initialization. self.datapixx.blink(dpx.BWHITE | dpx.BBLUE | dpx.BGREEN | dpx.BYELLOW | dpx.BRED) else: self.datapixx = None ## Load Graphics Device ## if graphics == 'gpu': from graphics.gpu import GPU self.graphics = GPU(wdth,hght,bg,fs,db,lut) elif graphics == 'datapixx': from graphics.datapixx import DATAPixx self.graphics = DATAPixx(wdth,hght,bg,fs,db,lut) else: self.graphics = None ## Load Input Device ## if inputs == 'keyboard': from inputs.keyboard import Keyboard self.inputs = Keyboard() elif inputs == 'responsepixx': from inputs.responsepixx import RESPONSEPixx self.inputs = RESPONSEPixx(self.datapixx) else: self.inputs = None ## Load Photometer ## if photometer == 'optical': from photometer.optical import OptiCAL self.photometer = OptiCAL('/dev/ttyUSB0') if photometer == 'minolta': from photometer.minolta import Minolta self.photometer = Minolta('/dev/ttyUSB0') else: self.photometer = None ## Design and Result matrices ## self._dfl = None if dfl != None: self._dfl = open(dfl,'rb') self.designs = csv.DictReader(self._dfl,delimiter=' ',skipinitialspace=True) self._rfl = None if rfl != None: self._rfl = open(rfl,'wb') self._rwtr = csv.DictWriter(self._rfl,rhds,delimiter=' ') self.results = {} #self._rwtr.writeheader() - requires Python 2.7 self._rfl.write(' '.join(rhds) + '\r\n')
# -*- coding: utf-8 -*- """ Example script to test connection with DATAPixx @author: Guillermo Aguilar, Dec 2017 """ import time import sys sys.path.insert(0, "../build/dist-packages") import datapixx as dpx # Open datapixx. datapixx = dpx.open() # set videomode: Concatenate Red and Green into a 16 bit luminance # channel. datapixx.setVidMode(dpx.DPREG_VID_CTRL_MODE_M16) # Demonstrate successful initialization with button blinks datapixx.blink(dpx.BWHITE) datapixx.blink(dpx.BWHITE | dpx.BBLUE | dpx.BGREEN | dpx.BYELLOW | dpx.BRED) datapixx.blink(dpx.BBLUE | dpx.BGREEN | dpx.BYELLOW | dpx.BRED) # closes datapixx.close()