ButtonBox: Difference between revisions

Jump to navigation Jump to search
No edit summary
No edit summary
Line 477: Line 477:


  <nowiki>
  <nowiki>
  ===================================================================================================
  % ===================================================================================================
  function handle = serial_buttonbox_common(cmd,varargin)
  function handle = serial_buttonbox_common(cmd,varargin)
%
% NOTE: this is a functional example, please adapt code according to your needs.
%
  % to initialize connection:
  % to initialize connection:
  % handle = serial_buttonbox('open',se)
  % handle = serial_buttonbox_common('open',se)
  % settings (se):
  % settings (se):
  % define settings as a structure, i.e.:
  % define settings as a structure, i.e.:
  % se.Device = 'COM1';
  % se.Device = 'COM2';
  % se.BaudRate = 115200;
  % se.BaudRate = 115200;
  % se.DataBits = 8;
  % se.DataBits = 8;
  % se.StopBits = 1;
  % se.StopBits = 1;
  % se.Parity = 0;
  % se.Parity = 0;
  % se.PTBPath = 'c:\MyToolboxes\PsychToolbox'
  % se.PTBPath = 'c:\toolboxes\PsychToolbox'
%
% to run:
% serial_buttonbox_common('run')
  %
  %
  % to close the connection:
  % to close the connection:
  % serial_buttonbox('close',handle);
  % serial_buttonbox_common('close',handle);
   
   
  persistent old_hdl
  persistent old_hdl
   
   
  % set defaults
  % set defaults
  se.Device = 'COM1';
  se.Device = 'COM2';
  se.BaudRate = 115200;
  se.BaudRate = 115200;
  se.DataBits = 8;
  se.DataBits = 8;
  se.StopBits = 1;
  se.StopBits = 1;
  se.Parity = 0;
  se.Parity = 0;
  se.PTBPath = 'c:\Pgrogram Files\PsychToolbox';
  se.PTBPath = 'c:\toolboxes\PsychToolbox';
   
   
  if nargin < 1
  if nargin < 1