Skip to content

Commit 8964e10

Browse files
committed
take setDefaults out of initPTB
1 parent 18a8fc8 commit 8964e10

File tree

2 files changed

+38
-39
lines changed

2 files changed

+38
-39
lines changed

initPTB.m

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
% check for OpenGL compatibility, abort otherwise:
2727
AssertOpenGL;
2828

29-
cfg = setDefaults(cfg);
29+
cfg = setDefaultsPTB(cfg);
3030

3131
initDebug(cfg);
3232

@@ -104,44 +104,6 @@
104104

105105
end
106106

107-
function cfg = setDefaults(cfg)
108-
109-
% list the default values
110-
fieldsToSet.keyboard = [];
111-
fieldsToSet.responseBox = [];
112-
113-
fieldsToSet.debug = true;
114-
fieldsToSet.testingTranspScreen = true;
115-
fieldsToSet.testingSmallScreen = true;
116-
117-
fieldsToSet.backgroundColor = [0 0 0];
118-
119-
fieldsToSet.textFont = 'Courier New';
120-
fieldsToSet.textSize = 18;
121-
fieldsToSet.textStyle = 1;
122-
123-
fieldsToSet.monitorWidth = 42;
124-
fieldsToSet.screenDistance = 134;
125-
126-
% loop through the defaults and set them in cfg if they don't exist
127-
names = fieldnames(fieldsToSet);
128-
129-
for i = 1:numel(names)
130-
cfg = setFieldToIfNotPresent(...
131-
cfg, ...
132-
names{i}, ...
133-
getfield(fieldsToSet, names{i})); %#ok<GFLD>
134-
end
135-
136-
137-
end
138-
139-
function struct = setFieldToIfNotPresent(struct, fieldName, value)
140-
if ~isfield(struct, fieldName)
141-
struct = setfield(struct, fieldName, value); %#ok<SFLD>
142-
end
143-
end
144-
145107

146108
function initDebug(cfg)
147109

setDefaultsPTB.m

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
function cfg = setDefaultsPTB(cfg)
2+
3+
% list the default values
4+
fieldsToSet.keyboard = [];
5+
fieldsToSet.responseBox = [];
6+
7+
fieldsToSet.debug = true;
8+
fieldsToSet.testingTranspScreen = true;
9+
fieldsToSet.testingSmallScreen = true;
10+
11+
fieldsToSet.backgroundColor = [0 0 0];
12+
13+
fieldsToSet.textFont = 'Courier New';
14+
fieldsToSet.textSize = 18;
15+
fieldsToSet.textStyle = 1;
16+
17+
fieldsToSet.monitorWidth = 42;
18+
fieldsToSet.screenDistance = 134;
19+
20+
% loop through the defaults and set them in cfg if they don't exist
21+
names = fieldnames(fieldsToSet);
22+
23+
for i = 1:numel(names)
24+
cfg = setFieldToIfNotPresent(...
25+
cfg, ...
26+
names{i}, ...
27+
getfield(fieldsToSet, names{i})); %#ok<GFLD>
28+
end
29+
30+
31+
end
32+
33+
function struct = setFieldToIfNotPresent(struct, fieldName, value)
34+
if ~isfield(struct, fieldName)
35+
struct = setfield(struct, fieldName, value); %#ok<SFLD>
36+
end
37+
end

0 commit comments

Comments
 (0)