Tscope5
timer03.c
////////////////////////////////////////////////////////////////////////////////
//
// __ ______
// / /_______________ ____ ___ / ____/
// / __/ ___/ ___/ __ \/ __ \/ _ \ /___ )
// / /_(__ ) /__/ /_/ / /_/ / __/ ____/ /
// \__/____/\___/\____/ .___/\___/ /_____/
// /_/
//
// timer03.c
// - Basic response timing example.
// - 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 responses
double start, stop, rt, error;
int i;
for (i=0; i<5; i++) {
// fixation, no real need to time this
ts5_printf(0.0, 0.0, "+");
ts5_wait(0.5);
// put on a stimulus
// timing starts at stimulus onset
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();
// flush the response buffer
// wait for a response
int resp = ts5_wait_for_response_timed(&stop, &error, 2.0);
rt = stop-start;
// print response time and measurement error
// measurement error is only known
// for parallel port response boxes
// and cedrusboxes
ts5_printf(0.0, 20.0, "response %d", resp);
ts5_printf(0.0, 0.0, "rt %f", rt);
ts5_printf(0.0, -20.0, "measurement error %f", error);
// iti
ts5_wait(2.0);
}
// wait for a click
ts5_draw_mouse_button(ax(0.9), ay(-0.8));
return 0;
}