Tscope5
timer04.c
////////////////////////////////////////////////////////////////////////////////
//
// __ ______
// / /_______________ ____ ___ / ____/
// / __/ ___/ ___/ __ \/ __ \/ _ \ /___ )
// / /_(__ ) /__/ /_/ / /_/ / __/ ____/ /
// \__/____/\___/\____/ .___/\___/ /_____/
// /_/
//
// timer04.c
// - Double buttonpress response.
// - Instructions: press S+D when a SD appears, press K+L when KL appears.
////////////////////////////////////////////////////////////////////////////////
#include <tscope5.h>
int main()
{
// open a display
ts5_wait(2.0);
// define 4 response buttons (2 left, 2 right)
// helper variables for 2 responses
double start;
double stop1, rt1, error1;
double stop2, rt2, 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);
char stim1, stim2;
if (stim==0) {
stim1='S';
stim2='D';
}
else {
stim1='K';
stim2='L';
}
ts5_printf(0.0, 0.0, "%c%c", stim1, stim2);
start = ts5_flip_display();
// wait for 2 reponses:
int resp1 = ts5_wait_for_response_until(&stop1, &error1, start + 2.0);
ts5_hide_response_button(resp1); // hide the first response
// so we are sure the second response
// is not just a repetition of the first
int resp2 = ts5_wait_for_response_until(&stop2, &error2, start + 2.0);
// compute and print RT
rt1 = stop1-start;
rt2 = stop2-start;
int align = ts5_set_text_alignment(TS5_ALIGN_LEFT);
ts5_printf(-200.0, 20.0, "responses: %d %d", resp1, resp2);
ts5_printf(-200.0, 0.0, "rts: %f %f", rt1, rt2);
ts5_printf(-200.0, -20.0, "measurement errors: %f %f", error1, error2);
// iti
ts5_wait(2.0);
}
// wait for a click
ts5_draw_mouse_button(ax(0.9), ay(-0.8));
return 0;
}