def test_bitsSharp(): win = visual.Window(screen=1, fullscr=True, useFBO=True, autoLog=True) win.setGamma(1.0) #make sure gfx card LUT is identity #initialise BitsSharp try: bits = crs.BitsSharp(win=win, mode='color++') except ImportError: pytest.skip( "crs.BitsSharp: could not initialize. possible:\nfrom serial.tools import list_ports\n" "ImportError: No module named tools") if not bits.OK: win.close() pytest.skip("No BitsSharp connected") print(bits.info) #switch to status screen (while keeping in mono 'mode') bits.getVideoLine(lineN=1, nPixels=1) core.wait(5) #wait for status mode to take effect #create a stimulus to check luminance values screenSqr = visual.GratingStim(win, tex=None, mask=None, size=2) print('\n up from zero:') bit16 = (2.0**16) - 1 for frameN in range(5): intensity = frameN / bit16 screenSqr.color = intensity * 2 - 1 # psychopy is -1:1 screenSqr.draw() win.flip() pixels = bits.getVideoLine(lineN=1, nPixels=2) print(pixels[0], pixels[1], intensity) print('\n down from 1:') for frameN in range(5): intensity = 1 - (frameN / bit16) screenSqr.color = intensity * 2 - 1 # psychopy is -1:1 screenSqr.draw() win.flip() pixels = bits.getVideoLine(lineN=1, nPixels=2) print(pixels[0], pixels[1], intensity) print('\n check the middle::') for intensity in [0.5, 0.5 + (1 / bit16)]: screenSqr.color = intensity * 2 - 1 # psychopy is -1:1 screenSqr.draw() win.flip() pixels = bits.getVideoLine(lineN=1, nPixels=2) print(pixels[0], pixels[1], intensity) bits.mode = "color++" #get out of status screen
from psychopy import visual, core, event, logging from psychopy.hardware import crs logging.console.setLevel(logging.INFO) win = visual.Window([1024, 768], screen=0, useFBO=True, fullscr=True, allowGUI=False, autoLog=False) # Initialize BitsSharp # you need to give this the psychopy Window so that it can override various # window functions (e.g. to override gamma settings etc) bits = crs.BitsSharp(win=win, mode='bits++') print(bits.info) if not bits.OK: print('failed to connect to Bits box') core.quit() core.wait(0.1) # Now, you can change modes using bits.mode = 'mono++' # 'color++', 'mono++', 'bits++', 'auto++' or 'status' # Create a stimulus and draw as normal stim = visual.GratingStim(win, tex='sin', units='pix', size=400,
# Initialize components for Routine "preflight" #preflightClock = core.Clock() #frameRate=win.getActualFrameRate() #print(expInfo['frameRate']) mon = monitors.Monitor(expInfo['Monitor'], distance=56) #=======================================================================================# #Opening the appropriate a CRS class of the desired / necessary type print("open CRS") if expInfo['Device'] == 'Bits++': bits = crs.BitsPlusPlus(win, mode='bits++', rampType=1) if expInfo['Device'] == 'Bits#': bits = crs.BitsSharp(win, mode='bits++', checkConfigLevel=1) if expInfo['Device'] == 'Display++' or expInfo['Device'] == 'None': if expInfo['Touch screen'] == "Yes": if expInfo['Device'] == 'Display++': bits = crs.DisplayPlusPlusTouch(win, mode='bits++', checkConfigLevel=1) else: bits = crs.DisplayPlusPlusTouch(win, mode='bits++', checkConfigLevel=1, noComms=True) else: if expInfo['Device'] == 'Display++': bits = crs.DisplayPlusPlus(win, mode='bits++', checkConfigLevel=1) else:
As of version 1.81.00 PsychoPy can make use of the Bits# in any of its rendering modes provided that your graphics card supports OpenGL framebuffer objects. You don't need to worry about setting the high- and low-bit pixels. Just draw as normal and PsychoPy will do the conversions for you """ from psychopy import visual, core, event from psychopy.hardware import crs win = visual.Window(screen=1, fullscr=True, useFBO=True) #initialise BitsSharp #you need to give this the psychopy Window so that it can override various #window functions (e.g. to override gamma settings etc) bits = crs.BitsSharp(win=win, mode='mono++') print bits.info core.wait(0.1) # now, you can change modes using bits.mode = 'color++' # 'color++', 'mono++', 'bits++', 'auto++' or 'status' #create a stimulus and draw as normal stim = visual.GratingStim(win, tex='sin', units='pix', size=400, sf=0.01, mask='gauss') globalClock = core.Clock() while len(event.getKeys()) < 1:
# -*- coding: utf-8 -*- """ Created on Thu May 8 10:46:41 2014 @author: jon.peirce """ import pytest from psychopy import visual, core, event from psychopy.hardware import crs win = visual.Window(screen=1, fullscr=True, useFBO=True) win.setGamma(1.0) #make sure gfx card LUT is identity #initialise BitsSharp bits = crs.BitsSharp(win=win, mode='color++') if not bits.OK: win.close() pytest.skip("No BitsSharp connected") print bits.info #switch to status screen (while keeping in mono 'mode') bits.getVideoLine(lineN=1, nPixels=1) core.wait(5) #wait for status mode to take effect #createa stimulus to check luminance values screenSqr = visual.GratingStim(win, tex=None, mask=None, size=2) print '\n up from zero:' bit16 = (2.0**16) - 1 for frameN in range(5): intensity = frameN / bit16 screenSqr.color = intensity * 2 - 1 #psychopy is -1:1