Keisuke Sehara
/
STM32_Whisking
fast-feedback virtual target task code on STM Nucleo
Diff: task.h
- Revision:
- 1:871d3066c2ab
- Child:
- 2:0c241937eabd
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/task.h Mon May 14 17:37:26 2018 +0000 @@ -0,0 +1,54 @@ +#ifndef TASK_H_ +#define TASK_H_ + +#include "mbed.h" + +/* + * command characters + */ +#define CMD_MODE_PAIR 'P' +#define CMD_MODE_APPEAR 'A' +#define CMD_TEST_REWARD 'T' +#define CMD_EXECUTE 'x' + +#define CHR_DELAY_MIN 'm' +#define CHR_DELAY_VAR 'v' +#define CHR_PREP_DUR 'p' +#define CHR_CUE_DUR 'c' +#define CHR_POST_DUR 'n' +#define CHR_REWARD_DUR 'r' + +#define STR_DELIMITER ";" +#define STR_NEWLINE "\r\n" + +enum Mode { + Pair, + Appear +}; + +struct Task { + Mode mode; // the trial mode. + + uint16_t delay_min_ms; // the minimum duration for the delay. + + uint16_t delay_var_ms; // the average for the (exponential) variable + // duration of the delay. + + uint16_t prep_dur_ms; // the duration of the "preparatory period", + // during which licking is not allowed. + + uint16_t cue_dur_ms; // the cue duration. + + uint16_t post_dur_ms; // the post-reward recording duration. + + uint16_t reward_ms; // the duration of reward.reward_ms + + explicit Task(const Mode& mode=Pair); + + void parseFromSerial(); + +private: + void writeModeToSerial(bool newline=true); + void writeSettingsToSerial(); +}; +#endif \ No newline at end of file