[][src]Function libeyelink_sys::eyelink_newest_float_sample

pub unsafe extern "C" fn eyelink_newest_float_sample(buf: *mut c_void) -> INT16

@ingroup messaging Check if a new sample has arrived from the link. This is the latest sample, not the oldest sample that is read by \c eyelink_get_next_data(), and is intended to drive gaze cursors and gaze-contingent displays. Typically the function is called with a \c NULL buffer pointer, to test if new data has arrived. If a value of \c 1 is returned, the function is called with a \c FSAMPLE buffer to get the new sample.

@param buf Pointer to sample buffer type \c FSAMPLE. If \c NULL, just checks new-sample status. @return \c -1 if no samples, \c 0 if no new data, \c 1 if new sample.

\b Example:

\code

Example 1:
#include 

ALLF_DATA evt;         // buffer to hold sample and event data
int eye_used = 0;      // indicates which eye's data to display
float x, y;		// gaze position

error = start_recording(1,1,1,0);
if(error != 0) return error;   // ERROR: couldn't start recording

eye_used = eyelink_eye_available();

switch(eye_used)
{
case RIGHT_EYE:
eyemsg_printf("EYE_USED 1 RIGHT");
break;
case BINOCULAR:   // both eye's data present: use left eye only
eye_used = LEFT_EYE;
case LEFT_EYE:
eyemsg_printf("EYE_USED 0 LEFT");
break;
}
while (1)
{
if(eyelink_newest_float_sample(NULL)>0)
{
eyelink_newest_float_sample(&evt);

x = evt.fs.gx[eye_used];
y = evt.fs.gy[eye_used];

if(x!=MISSING_DATA && y!=MISSING_DATA && evt.fs.pa[eye_used]>0)
eyemsg_printf("Sample: %ld %8.2f %8.2f",
evt.fs.time, x, y);
}
...
}
\endcode
\b Output:
\code
MSG	23701980 EYE_USED 0 LEFT
MSG	23703426 Sample: 23703424   412.90   217.90
MSG	23703430 Sample: 23703426   433.20   216.20
MSG	23703430 Sample: 23703428   453.40   214.40
MSG	23703434 Sample: 23703430   473.60   212.60
MSG	23703434 Sample: 23703432   493.80   210.80
MSG	23703438 Sample: 23703434   514.00   209.00
MSG	23703438 Sample: 23703436   534.20   207.10
MSG	23703442 Sample: 23703438   554.30   205.20
MSG	23703442 Sample: 23703440   574.40   203.30
MSG	23703446 Sample: 23703442   594.50   201.30
MSG	23703446 Sample: 23703444   614.60   199.30
MSG	23703450 Sample: 23703446   634.70   197.20
MSG	23703450 Sample: 23703448   634.70   197.20
\endcode

\b

\code
Example 2:
eyecmd_printf("file_sample_data = LEFT,RIGHT,GAZE,AREA,HTARGET,GAZERES,STATUS,INPUT");
eyecmd_printf("link_sample_data = LEFT,RIGHT,GAZE,GAZERES,AREA,HTARGET,STATUS,INPUT");



if(eyelink_newest_float_sample(NULL)>0)
{
eyelink_newest_float_sample(&evt);   // get the sample

eyemsg_printf("remote data %d %d %d %x", evt.fs.hdata[0], evt.fs.hdata[1], evt.fs.hdata[2], evt.fs.hdata[3]);
}

\endcode

\sa \c eyelink_get_float_data(), \c eyelink_get_last_data(), \c eyelink_get_next_data(), \c eyelink_get_sample() \c eyelink_newest_double_sample() and \c eyelink_newest_sample()