~ubuntu-branches/ubuntu/trusty/psychtoolbox-3/trusty-proposed

« back to all changes in this revision

Viewing changes to Psychtoolbox/PsychHardware/Daq/DaqWaitButtonDumbTest1408FS.m

  • Committer: Package Import Robot
  • Author(s): Yaroslav Halchenko
  • Date: 2013-11-19 23:34:50 UTC
  • mfrom: (3.1.4 experimental)
  • Revision ID: package-import@ubuntu.com-20131119233450-f7nf92vb8qavjmk8
Tags: 3.0.11.20131017.dfsg1-3
Upload to unsable since fresh glew has arrived to sid!

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
% DaqWaitButtonDumbTest1408FS.m
 
2
%
 
3
% A quick and dirty demo on how to poll the digital inputs
 
4
% of a USB-1408FS as fast as possible, without overhead.
 
5
%
 
6
% This is essentially a stripped down version of DaqDIn() with
 
7
% some polling loops wrapped around and a options.secs value of
 
8
% zero for essentially polling with no timeout.
 
9
%
 
10
 
 
11
daq = DaqFind;
 
12
reportId = 3;
 
13
TheReport = uint8(0);
 
14
NumberOfPorts = 2;
 
15
 
 
16
if IsWin
 
17
 % Windows needs some minimal polling time:
 
18
 options.secs = 0.001;
 
19
else
 
20
 options.secs = 0.000;
 
21
end
 
22
 
 
23
PsychHID('ReceiveReportsStop',daq);
 
24
PsychHID('GiveMeReports',daq);
 
25
PsychHID('ReceiveReports',daq, options);
 
26
 
 
27
while 1
 
28
% Emit query to device:
 
29
PsychHID('SetReport',daq,2,reportId, TheReport);
 
30
 
 
31
% Wait for result from device:
 
32
inreport = [];
 
33
while isempty(inreport)
 
34
% Yield some minimum amount of time to other processes if you want to be
 
35
WaitSecs('YieldSecs', 0);
 
36
% New data available?
 
37
inreport = PsychHID('GetReport',daq,1,reportId,NumberOfPorts+1);
 
38
end
 
39
 
 
40
% inreport contains latest button query result: Button pressed?
 
41
if inreport(3) ~= 255
 
42
% yes: Done!
 
43
break;
 
44
end
 
45
 
 
46
% No. Repeat sampling...
 
47
end
 
48
 
 
49
fprintf('Change detected! Bye.\n');