ButtonBox: Difference between revisions

Jump to navigation Jump to search
No edit summary
No edit summary
Line 343: Line 343:
% or
% or
%
%
% to send a marker: (marker: a numeric value)
% to send a marker: (marker: a numeric value; Fs: sampling frequency device)
% buttonbox(marker)
% buttonbox(marker,Fs)
%
%
% or
% or
Line 362: Line 362:
bb.StopBits  = 1;
bb.StopBits  = 1;
bb.Parity    = 'none';  
bb.Parity    = 'none';  
if nargin < 1
if nargin < 1
   cmd = 'open';
   cmd = 'open';
end
end
if nargin > 1
if nargin > 1 && isstruct(varargin{1})
   % user overwrites default settings
   % user overwrites default settings
   flds = fields(varargin{1});
   flds = fields(varargin{1});
Line 373: Line 374:
end
end
if nargin==1 && isnumeric(cmd)
if nargin==1 && isnumeric(cmd)
  error('Please also specify acquisition sampling frequency of device that receives the marker');
end
if nargin > 1 && isnumeric(cmd)
   marker = cmd;
   marker = cmd;
   cmd = 'marker';
   cmd = 'marker';
  Fs = varargin{1};
end
end


Line 388: Line 393:
   case 'marker'
   case 'marker'
       fwrite(handle, uint8(marker));%IOPort('Write', handle, uint8(marker), 1); % last argument: blocking
       fwrite(handle, uint8(marker));%IOPort('Write', handle, uint8(marker), 1); % last argument: blocking
       WaitSecs(0.002);
       WaitSecs(2/Fs);
       fwrite(handle, uint8(0));%IOPort('Write', handle, uint8(0), 0); % last argument: blocking
       fwrite(handle, uint8(0));%IOPort('Write', handle, uint8(0), 0); % last argument: blocking
       return
       return
Line 525: Line 530:
   end  
   end  
end
end
end</syntaxhighlight>
end</syntaxhighlight>