fast-feedback virtual target task code on STM Nucleo

Dependencies:   mbed

trial.h

Committer:
gwappa
Date:
2018-05-14
Revision:
2:0c241937eabd
Child:
3:991c6d5ce19d

File content as of revision 2:0c241937eabd:

#ifndef TRIAL_H_
#define TRIAL_H_

#include "task.h"

namespace TrialFlags {
    // nothing
    const char Clear     = 0x00;
    // flags if the auditory cue is there during the trial
    const char Cues      = 0x01;
    // flags if any whisking event is detected during the response window
    const char Responded = 0x02;
    // flags if licking event is detected during the preparatory/pre-response window
    const char Licked    = 0x04;
}

namespace Responses {
    const char Hit     = 0x03; // cues && responded
    const char Miss    = 0x01; // cues && ~responded
    const char Catch   = 0x02; // ~cues && responded
    const char Reject  = 0x00; // ~cues && ~responded
    const char Reset   = 0x04; // invalid lick
    const char NA      = 0x08; // default
}

struct Trial {
    /**
    * whether the animal whisked during the cue.
    * + whether the animal waited for the cue.
    */
    char          response;
    /**
    * the timestamp when the trial started.
    */
    unsigned long starting;
    /**
    * the timestamp when the cue started
    */
    unsigned long cuestarting;
    /**
    * the total waiting period for the animal during this trial before the cue.
    */
    unsigned long waiting;   // used for calculation of waiting period
    /**
    * the duration of the delay period for this trial.
    */
    uint16_t      delay_dur_ms;
    
    void reset(const Task& task);
    
    void writeToSerial();
};

#endif