|
53 | 53 | EyelinkUpdateDefaults(el); |
54 | 54 |
|
55 | 55 | % Initialize EL and make sure it worked: returns 0 if OK, -1 if error. |
56 | | - % Exit program if this fails. |
57 | | - elInit = Eyelink('Initialize'); |
58 | | - if ELinit ~= 0 |
59 | | - fprintf('Eyelink is not initialized, aborted.\n'); |
60 | | - Eyelink('Shutdown'); |
61 | | - CleanUp(); |
62 | | - return |
63 | | - end |
64 | 56 |
|
65 | | - % Make sure EL is still connected: returns 1 if connected, -1 if dummy-connected, |
66 | | - % 2 if broadcast-connected and 0 if not connected. Exit program if this fails. |
67 | | - elConnection = Eyelink('IsConnected'); |
68 | | - if ELconnection ~= 1 |
69 | | - fprintf('Eyelink is not connected, aborted.\n'); |
70 | | - Eyelink('Shutdown'); |
71 | | - CleanUp(); |
72 | | - return |
73 | | - end |
74 | | - |
75 | | - % Last check that the EL is up to work and exit program if this fails. |
76 | | - if ~EyelinkInit(0, 1) |
77 | | - fprintf('Eyelink Init aborted.\n'); |
78 | | - CleanUp(); |
79 | | - return |
80 | | - end |
| 57 | + % Check that EL is initialzed and connected, otherwise abort experiment |
| 58 | + eyetrackerCheckConnection |
81 | 59 |
|
82 | 60 | % Open the edf file to write the data. |
83 | 61 | edfFile = 'demo.edf'; |
|
139 | 117 | end |
140 | 118 |
|
141 | 119 | % Set EDF file contents (not clear what this lines are used for). |
142 | | - el.vsn = regexp(el.vs, '\d', 'match'); % wont work on EL |
| 120 | + el.vsn = regexp(el.vs, '\d', 'match'); % won't work on EL |
143 | 121 |
|
144 | 122 | % Enter Eyetracker camera setup mode, calibration and validation. |
145 | 123 | EyelinkDoTrackerSetup(el); |
|
239 | 217 |
|
240 | 218 | end |
241 | 219 |
|
| 220 | +function eyetrackerCheckConnection |
| 221 | + |
| 222 | + % Initialize EL and make sure it worked: returns 0 if OK, -1 if error. |
| 223 | + % Exit program if this fails. |
| 224 | + elInit = Eyelink('Initialize'); |
| 225 | + if ELinit ~= 0 |
| 226 | + error('Eyelink is not initialized, aborted.\n'); |
| 227 | + end |
| 228 | + |
| 229 | + % Make sure EL is still connected: returns 1 if connected, -1 if dummy-connected, |
| 230 | + % 2 if broadcast-connected and 0 if not connected. Exit program if this fails. |
| 231 | + elConnection = Eyelink('IsConnected'); |
| 232 | + if ELconnection ~= 1 |
| 233 | + error('Eyelink is not connected, aborted.\n'); |
| 234 | + end |
| 235 | + |
| 236 | +end |
| 237 | + |
| 238 | + |
242 | 239 | %% subfunctions for iView |
243 | 240 |
|
244 | 241 | % function ivx = eyeTrackInit(cfg) |
|
0 commit comments