Tscope5
timer06.c
////////////////////////////////////////////////////////////////////////////////
//
// __ ______
// / /_______________ ____ ___ / ____/
// / __/ ___/ ___/ __ \/ __ \/ _ \ /___ )
// / /_(__ ) /__/ /_/ / /_/ / __/ ____/ /
// \__/____/\___/\____/ .___/\___/ /_____/
// /_/
//
// timer06.c
// - Measure button press time.
// - Instructions: press S when an S appears, press L when an L appears.
////////////////////////////////////////////////////////////////////////////////
#include <tscope5.h>
int main()
{
// open a display
ts5_wait(2.0);
// define two buttons + the release of those buttons (using -)
double start, stop, release, error1, error2;
int i;
for (i=0; i<5; i++) {
// fixation
ts5_printf(0.0, 0.0, "+");
ts5_wait(0.5);
// stimulus
unsigned int stim = ts5_random_integer(2);
if (stim==0) {
stim='S';
}
else {
stim='L';
}
ts5_printf(0.0, 0.0, "%c", stim);
start = ts5_flip_display();
// register the press (hide the responses corresponding to releases)
int resp = ts5_wait_for_response_timed(&stop, &error1, 2.0);
// register the release (hide the responses corresponding to presses)
ts5_wait_for_response_timed(&release, &error2, 2.0);
// compute RT and press time
ts5_printf(0.0, 30.0, "response %d", resp);
ts5_printf(0.0, 10.0, "rt %f, error %f", stop-start, error1);
ts5_printf(0.0, -10.0, "release %f, measurement error %f", release-start, error2);
ts5_printf(0.0, -30.0, "press time %f", release-stop);
// iti
ts5_wait(2.0);
}
ts5_draw_mouse_button(ax(0.9), ay(-0.8));
return 0;
}