Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions demos/CPP_waitForTriggerDemo.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
% add parent/src directory to the path (to make sure we can access the CPP_PTB functions)
addpath(genpath(fullfile(pwd, '..', 'src')));

cfg.mri.triggerNb = 5;
cfg.testingDevice = 'mri';

cfg.mri.triggerNb = 5;
cfg.mri.triggerKey = 't';

KbName('UnifyKeyNames');

%%
% waitForTrigger(cfg);

%%
quietMode = false;
% waitForTrigger(cfg, [], quietMode);

%%
waitForTrigger(cfg, [], quietMode, cfg.mri.triggerNb);
fprintf(1, 'Press the letter %s %i times, please.\n', cfg.mri.triggerKey, cfg.mri.triggerNb);

lastTriggerTimeStamp = waitForTrigger(cfg, [], quietMode, cfg.mri.triggerNb);

fprintf(1, 'Thank you. The time stamp of the last trigger was %f.\n', lastTriggerTimeStamp);
4 changes: 2 additions & 2 deletions src/waitForTrigger.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
% (C) Copyright 2020 CPP_PTB developers

function waitForTrigger(varargin)
function lastTriggerTimeStamp = waitForTrigger(varargin)
% waitForTrigger(cfg, deviceNumber, quietMode, nbTriggersToWait)
%
% Counts a certain number of triggers coming from the scanner before returning.
Expand Down Expand Up @@ -45,7 +45,7 @@ function waitForTrigger(varargin)

keyCode = []; %#ok<NASGU>

[~, ~, keyCode] = KbCheck(deviceNumber);
[~, lastTriggerTimeStamp, keyCode] = KbCheck(deviceNumber);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes this is exactly what I'm / was doing! thanks! I didn't update wirh the previous PR so I was using:
[sec, keyCode] = KbPressWait(deviceNumber);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okidoki so I will merge this now. :-)


if strcmp(KbName(keyCode), cfg.mri.triggerKey)

Expand Down