Skip to content

Commit 4cc80ea

Browse files
committed
add more comments to explain the code
1 parent 05219b0 commit 4cc80ea

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

eyeTracker.m

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,16 @@
2727
function [el, edfFile] = eyeTracker(input, cfg, varargin)
2828
% [el, edfFile] = eyeTracker(input, cfg, varargin)
2929
%
30+
% Optional useful functions to implement in future:
3031
%
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+
3140

3241
if ~cfg.eyeTracker.do
3342

@@ -63,7 +72,7 @@
6372
% Initialization of the connection with the Eyelink Gazetracker.
6473
% exit program if this fails.
6574

66-
% make sure EL is initialized.
75+
% Initialize EL and make sure it worked: returns: 0 if OK, -1 if error
6776
ELinit = Eyelink('Initialize');
6877
if ELinit ~= 0
6978
fprintf('Eyelink is not initialized, aborted.\n');
@@ -72,7 +81,8 @@
7281
return
7382
end
7483

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
7686
ELconnection = Eyelink('IsConnected');
7787
if ELconnection ~= 1
7888
fprintf('Eyelink is not connected, aborted.\n');
@@ -111,7 +121,7 @@
111121
Eyelink('message', 'DISPLAY_COORDS %ld %ld %ld %ld', 0, 0, 0, 0);
112122

113123
if cfg.eyeTracker.defaultCalibration
114-
124+
115125
end
116126

117127
% Set default calibration parameters
@@ -175,8 +185,8 @@
175185
% return;
176186
% end
177187

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);
180190
Screen('Flip', cfg.screen.win);
181191

182192
case 'StartRecording'
@@ -239,13 +249,15 @@
239249
try
240250
fprintf('Receiving data file ''%s''\n', edfFileName);
241251

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);
243255

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);
246258
end
247259

248-
if 2 == exist(edfFileName, 'file')
260+
if exist(edfFileName, 'file') == 2
249261

250262
fprintf('Data file ''%s'' can be found in ''%s''\n', ...
251263
cfg.fileName.eyetracker, ...
@@ -255,10 +267,11 @@
255267

256268
catch
257269

258-
fprintf('Problem receiving data file ''%s''\n', edfFileName);
270+
fprintf('Problem receiving eye tracker data ''%s''\n', edfFileName);
259271

260272
end
261273

274+
% Close connection with EyeLink
262275
Eyelink('shutdown');
263276

264277
end

0 commit comments

Comments
 (0)