fast-feedback virtual target task code on STM Nucleo

Dependencies:   mbed

Committer:
gwappa
Date:
Sun Jul 01 13:08:06 2018 +0000
Revision:
18:66246d6c5476
Parent:
17:0b241aa1f5b6
Child:
20:4c06d3041337
coding style: include default values into config definitions

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gwappa 1:871d3066c2ab 1 #ifndef TASK_H_
gwappa 1:871d3066c2ab 2 #define TASK_H_
gwappa 1:871d3066c2ab 3
gwappa 1:871d3066c2ab 4 #include "mbed.h"
gwappa 5:849446d19406 5 #include "config.h"
gwappa 1:871d3066c2ab 6
gwappa 1:871d3066c2ab 7 /*
gwappa 1:871d3066c2ab 8 * command characters
gwappa 1:871d3066c2ab 9 */
gwappa 9:e136394bdb39 10
gwappa 11:897ecd5413e0 11 #define CMD_TEST_REWARD 'T'
gwappa 11:897ecd5413e0 12 #define CMD_EXECUTE 'X'
gwappa 1:871d3066c2ab 13
gwappa 18:66246d6c5476 14 #define CFG_DELAY_MIN 'm', (3000)
gwappa 18:66246d6c5476 15 #define CFG_DELAY_VAR 'd', (3000)
gwappa 18:66246d6c5476 16 #define CFG_PREP_DUR 'p', (1500)
gwappa 18:66246d6c5476 17 #define CFG_AUD_DUR 'a', (4500)
gwappa 18:66246d6c5476 18 #define CFG_AUD_FREQ 'f', (4)
gwappa 18:66246d6c5476 19 #define CFG_RESP_DUR 'y', (2000)
gwappa 18:66246d6c5476 20 #define CFG_POST_DUR 'n', (4000)
gwappa 18:66246d6c5476 21 #define CFG_REWARD_ONSET 'u', (500)
gwappa 18:66246d6c5476 22 #define CFG_REWARD_DUR 'r', (40)
gwappa 18:66246d6c5476 23 #define CFG_PRE_MIN 'o', (1000)
gwappa 18:66246d6c5476 24 #define CFG_VIS_MIN 'j', (1)
gwappa 18:66246d6c5476 25 #define CFG_VIS_AVG 'v', (50)
gwappa 18:66246d6c5476 26 #define CFG_VIS_FAIL 'q', (30)
gwappa 1:871d3066c2ab 27
gwappa 1:871d3066c2ab 28 enum Mode {
gwappa 1:871d3066c2ab 29 Pair,
gwappa 4:fcf597f82632 30 Report,
gwappa 11:897ecd5413e0 31 Associate,
gwappa 16:33c17c62840e 32 Motion,
gwappa 16:33c17c62840e 33 MotionAlt
gwappa 1:871d3066c2ab 34 };
gwappa 1:871d3066c2ab 35
gwappa 5:849446d19406 36 struct ModeSelection: public config::CommandResponder
gwappa 5:849446d19406 37 {
gwappa 9:e136394bdb39 38 static const char CMD_ID_MODE;
gwappa 9:e136394bdb39 39 static const char CMD_MODE_PAIR;
gwappa 9:e136394bdb39 40 static const char CMD_MODE_REPORT;
gwappa 11:897ecd5413e0 41 static const char CMD_MODE_ASSOCIATE;
gwappa 11:897ecd5413e0 42 static const char CMD_MODE_MOTION;
gwappa 16:33c17c62840e 43 static const char CMD_MODE_MOTION_ALT;
gwappa 9:e136394bdb39 44
gwappa 5:849446d19406 45 ModeSelection(); // not allowed
gwappa 5:849446d19406 46
gwappa 5:849446d19406 47 explicit ModeSelection(const Mode& defaultValue);
gwappa 1:871d3066c2ab 48
gwappa 5:849446d19406 49 virtual ~ModeSelection();
gwappa 5:849446d19406 50
gwappa 5:849446d19406 51 virtual bool parse(const char& c);
gwappa 5:849446d19406 52
gwappa 5:849446d19406 53 virtual bool writeSettings();
gwappa 1:871d3066c2ab 54
gwappa 5:849446d19406 55 virtual void echoback();
gwappa 5:849446d19406 56
gwappa 5:849446d19406 57 Mode value;
gwappa 5:849446d19406 58 };
gwappa 5:849446d19406 59
gwappa 5:849446d19406 60 struct Task {
gwappa 5:849446d19406 61 ModeSelection mode; // the trial mode.
gwappa 5:849446d19406 62
gwappa 5:849446d19406 63 Property<uint16_t> delay_min_ms; // the minimum duration for the delay.
gwappa 5:849446d19406 64
gwappa 5:849446d19406 65 Property<uint16_t> delay_var_ms; // the average for the (exponential) variable
gwappa 5:849446d19406 66 // duration of the delay.
gwappa 1:871d3066c2ab 67
gwappa 5:849446d19406 68 Property<uint16_t> prep_dur_ms; // the duration of the "preparatory period",
gwappa 1:871d3066c2ab 69 // during which licking is not allowed.
gwappa 1:871d3066c2ab 70
gwappa 11:897ecd5413e0 71 Property<uint16_t> aud_dur_ms; // the auditory cue duration.
gwappa 11:897ecd5413e0 72
gwappa 11:897ecd5413e0 73 Property<uint16_t> aud_tick_hz; // the frequency of auditory cue flickering.
gwappa 5:849446d19406 74
gwappa 13:8ea85a33e37a 75 Property<uint16_t> resp_dur_ms; // the size of the minimal 'response window' for the passive paradigms.
gwappa 13:8ea85a33e37a 76
gwappa 5:849446d19406 77 Property<uint16_t> post_dur_ms; // the post-reward recording duration.
gwappa 1:871d3066c2ab 78
gwappa 16:33c17c62840e 79 Property<uint16_t> reward_on_ms; // the onset of reward relative to visual cue during Pair.
gwappa 16:33c17c62840e 80
gwappa 16:33c17c62840e 81 Property<uint16_t> reward_dur_ms; // the duration of reward.
gwappa 1:871d3066c2ab 82
gwappa 15:20f7f737c256 83 Property<uint16_t> pre_min_ms; // the minimum onset for the (passive) visual cue.
gwappa 15:20f7f737c256 84
gwappa 11:897ecd5413e0 85 Property<uint16_t> vis_min_ms; // the minimum duration for the (passive) visual cue.
gwappa 11:897ecd5413e0 86
gwappa 14:af3adf5d5ddf 87 Property<uint16_t> vis_avg_ms; // the average duration for the (passive) visual cue.
gwappa 14:af3adf5d5ddf 88
gwappa 13:8ea85a33e37a 89 Property<uint16_t> vis_fail_perc; // the 'failure rate' of the (passive) visual cue.
gwappa 11:897ecd5413e0 90
gwappa 5:849446d19406 91 Action test_reward;
gwappa 5:849446d19406 92
gwappa 5:849446d19406 93 Action run;
gwappa 1:871d3066c2ab 94
gwappa 1:871d3066c2ab 95 explicit Task(const Mode& mode=Pair);
gwappa 1:871d3066c2ab 96
gwappa 1:871d3066c2ab 97 void parseFromSerial();
gwappa 1:871d3066c2ab 98
gwappa 1:871d3066c2ab 99 private:
gwappa 5:849446d19406 100 void testReward();
gwappa 5:849446d19406 101 void runTrial();
gwappa 1:871d3066c2ab 102 void writeSettingsToSerial();
gwappa 1:871d3066c2ab 103 };
gwappa 1:871d3066c2ab 104 #endif