-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTakeBreak.m
40 lines (33 loc) · 1.51 KB
/
TakeBreak.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
function [ ] = TakeBreak( E )
Screen(E.screen.theWindow,'TextSize',E.screen.textsize*2);
DrawFormattedText(E.screen.theWindow,'Puoi prendere una piccola pausa','center','center',E.screen.textcolor);
%DrawFormattedText(theWindow,'Puoi prendere una piccola pausa \n Premi la BARRA per continuare','center','center',255);
Screen('Flip', E.screen.theWindow);
for c = 1:E.times.Break - E.times.CountDown; % Break between blocks
WaitSecs(1);
STOP = press_ctrlalt(E.keys.c_alt, E.keys.c_ctrl); % if ctrl+alt are pressed, ends the Block and continues
if STOP; break; end
end
for c = 1:E.times.CountDown % Break between blocks (CountDown)
if STOP; break; end
DrawFormattedText(E.screen.theWindow,['Pausa finisce in ', num2str(E.times.CountDown+1 - c)],'center','center',E.screen.textcolor);
%DrawFormattedText(theWindow,'Puoi prendere una piccola pausa \n Premi la BARRA per continuare','center','center',255);
Screen('Flip', E.screen.theWindow);
WaitSecs(1);
STOP = press_ctrlalt(E.keys.c_alt, E.keys.c_ctrl); % if ctrl+alt are pressed, ends the Block and continues
if STOP; break; end
end
end
%% Auxiliary functions
function var = press_ctrlalt(altkey,ctrlkey) % If ctrl + alt are pressed it set the variable out to 0
[~, ~, keyCode, ~] = KbCheck;
%if any(keyCode)
key = find(keyCode);
K1 = repmat(altkey,numel(key),1) == repmat(key',1,numel(altkey));
K2 = repmat(ctrlkey,numel(key),1) == repmat(key',1,numel(ctrlkey));
if any(any(K1)) && any(any(K2))
var = 1;
else
var = 0;
end
end