|
27 | 27 | function [el, edfFile] = eyeTracker(input, cfg, varargin) |
28 | 28 | % [el, edfFile] = eyeTracker(input, cfg, varargin) |
29 | 29 | % |
| 30 | + % Optional useful functions to implement in future: |
30 | 31 | % |
| 32 | + % - oldlevel = Eyelink(‘Verbosity’ [,level]); |
| 33 | + % |
| 34 | + % Set level of verbosity for error/warning/status messages. ‘level’ optional, new |
| 35 | + % level of verbosity. ‘oldlevel’ is the old level of verbosity. The following |
| 36 | + % levels are supported: 0 = Shut up. 1 = Print errors, 2 = Print also warnings, 3 |
| 37 | + % = Print also some info, 4 = Print more useful info (default), >5 = Be very |
| 38 | + % verbose (mostly for debugging the driver itself). |
| 39 | + |
31 | 40 |
|
32 | 41 | if ~cfg.eyeTracker.do |
33 | 42 |
|
|
63 | 72 | % Initialization of the connection with the Eyelink Gazetracker. |
64 | 73 | % exit program if this fails. |
65 | 74 |
|
66 | | - % make sure EL is initialized. |
| 75 | + % Initialize EL and make sure it worked: returns: 0 if OK, -1 if error |
67 | 76 | ELinit = Eyelink('Initialize'); |
68 | 77 | if ELinit ~= 0 |
69 | 78 | fprintf('Eyelink is not initialized, aborted.\n'); |
|
72 | 81 | return |
73 | 82 | end |
74 | 83 |
|
75 | | - % make sure we're still connected. |
| 84 | + % Make sure EL is still connected: returns 1 if connected, -1 if dummy-connected, |
| 85 | + % 2 if broadcast-connected and 0 if not connected |
76 | 86 | ELconnection = Eyelink('IsConnected'); |
77 | 87 | if ELconnection ~= 1 |
78 | 88 | fprintf('Eyelink is not connected, aborted.\n'); |
|
111 | 121 | Eyelink('message', 'DISPLAY_COORDS %ld %ld %ld %ld', 0, 0, 0, 0); |
112 | 122 |
|
113 | 123 | if cfg.eyeTracker.defaultCalibration |
114 | | - |
| 124 | + |
115 | 125 | end |
116 | 126 |
|
117 | 127 | % Set default calibration parameters |
|
175 | 185 | % return; |
176 | 186 | % end |
177 | 187 |
|
178 | | - % Go back to black screen |
179 | | - Screen('FillRect', cfg.screen.win, [0 0 0]); |
| 188 | + % Go back to default screen background color |
| 189 | + Screen('FillRect', cfg.screen.win, cfg.color.background); |
180 | 190 | Screen('Flip', cfg.screen.win); |
181 | 191 |
|
182 | 192 | case 'StartRecording' |
|
239 | 249 | try |
240 | 250 | fprintf('Receiving data file ''%s''\n', edfFileName); |
241 | 251 |
|
242 | | - status = Eyelink('ReceiveFile', '', edfFileName); |
| 252 | + % Download the file and check the status: returns file size if OK, 0 if file |
| 253 | + % transfer was cancelled, negative = error |
| 254 | + elReceiveFile = Eyelink('ReceiveFile', '', edfFileName); |
243 | 255 |
|
244 | | - if status > 0 |
245 | | - fprintf('ReceiveFile status %d\n', status); |
| 256 | + if elReceiveFile > 0 |
| 257 | + fprintf('Downloading eye tracker file of size %d\n', elReceiveFile); |
246 | 258 | end |
247 | 259 |
|
248 | | - if 2 == exist(edfFileName, 'file') |
| 260 | + if exist(edfFileName, 'file') == 2 |
249 | 261 |
|
250 | 262 | fprintf('Data file ''%s'' can be found in ''%s''\n', ... |
251 | 263 | cfg.fileName.eyetracker, ... |
|
255 | 267 |
|
256 | 268 | catch |
257 | 269 |
|
258 | | - fprintf('Problem receiving data file ''%s''\n', edfFileName); |
| 270 | + fprintf('Problem receiving eye tracker data ''%s''\n', edfFileName); |
259 | 271 |
|
260 | 272 | end |
261 | 273 |
|
| 274 | + % Close connection with EyeLink |
262 | 275 | Eyelink('shutdown'); |
263 | 276 |
|
264 | 277 | end |
|
0 commit comments