Keisuke Sehara
/
STM32_Whisking
fast-feedback virtual target task code on STM Nucleo
task.h@29:1fb060aab1f8, 2018-10-01 (annotated)
- Committer:
- gwappa
- Date:
- Mon Oct 01 14:54:37 2018 +0000
- Revision:
- 29:1fb060aab1f8
- Parent:
- 28:797536a42b9f
- Child:
- 30:5f975f572ffb
update task structure
Who changed what in which revision?
User | Revision | Line number | New 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 | 27:b31ea8d74f9e | 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 | 29:1fb060aab1f8 | 17 | #define CFG_AUD_DUR 'a', (5000) |
gwappa | 18:66246d6c5476 | 18 | #define CFG_AUD_FREQ 'f', (4) |
gwappa | 27:b31ea8d74f9e | 19 | #define CFG_RESP_DUR 'y', (1000) |
gwappa | 18:66246d6c5476 | 20 | #define CFG_POST_DUR 'n', (4000) |
gwappa | 25:56c4b22ec034 | 21 | #define CFG_REWARD_DUR 'r', (50) |
gwappa | 29:1fb060aab1f8 | 22 | #define CFG_ONSET_MIN 'o', (500) |
gwappa | 29:1fb060aab1f8 | 23 | #define CFG_ONSET_STEPS 's', (10) |
gwappa | 29:1fb060aab1f8 | 24 | #define CFG_VIS_DUR 'v', (800) |
gwappa | 29:1fb060aab1f8 | 25 | #define CFG_VIS_TEST_EVERY 'q', (30) |
gwappa | 25:56c4b22ec034 | 26 | #define CFG_WHISK_DEBOUNCE 'w', (5) |
gwappa | 25:56c4b22ec034 | 27 | #define CFG_LICK_DEBOUNCE 'l', (80) |
gwappa | 1:871d3066c2ab | 28 | |
gwappa | 1:871d3066c2ab | 29 | enum Mode { |
gwappa | 28:797536a42b9f | 30 | Condition, |
gwappa | 4:fcf597f82632 | 31 | Report, |
gwappa | 11:897ecd5413e0 | 32 | Associate, |
gwappa | 16:33c17c62840e | 33 | Motion, |
gwappa | 16:33c17c62840e | 34 | MotionAlt |
gwappa | 1:871d3066c2ab | 35 | }; |
gwappa | 1:871d3066c2ab | 36 | |
gwappa | 5:849446d19406 | 37 | struct ModeSelection: public config::CommandResponder |
gwappa | 5:849446d19406 | 38 | { |
gwappa | 9:e136394bdb39 | 39 | static const char CMD_ID_MODE; |
gwappa | 28:797536a42b9f | 40 | static const char CMD_MODE_CONDITION; |
gwappa | 9:e136394bdb39 | 41 | static const char CMD_MODE_REPORT; |
gwappa | 11:897ecd5413e0 | 42 | static const char CMD_MODE_ASSOCIATE; |
gwappa | 11:897ecd5413e0 | 43 | static const char CMD_MODE_MOTION; |
gwappa | 16:33c17c62840e | 44 | static const char CMD_MODE_MOTION_ALT; |
gwappa | 9:e136394bdb39 | 45 | |
gwappa | 5:849446d19406 | 46 | ModeSelection(); // not allowed |
gwappa | 5:849446d19406 | 47 | |
gwappa | 5:849446d19406 | 48 | explicit ModeSelection(const Mode& defaultValue); |
gwappa | 1:871d3066c2ab | 49 | |
gwappa | 5:849446d19406 | 50 | virtual ~ModeSelection(); |
gwappa | 5:849446d19406 | 51 | |
gwappa | 29:1fb060aab1f8 | 52 | // the interface function defined in CommandResponder |
gwappa | 5:849446d19406 | 53 | virtual bool parse(const char& c); |
gwappa | 5:849446d19406 | 54 | |
gwappa | 29:1fb060aab1f8 | 55 | // the interface function defined in CommandResponder |
gwappa | 5:849446d19406 | 56 | virtual bool writeSettings(); |
gwappa | 1:871d3066c2ab | 57 | |
gwappa | 29:1fb060aab1f8 | 58 | // the interface function defined in CommandResponder |
gwappa | 5:849446d19406 | 59 | virtual void echoback(); |
gwappa | 5:849446d19406 | 60 | |
gwappa | 5:849446d19406 | 61 | Mode value; |
gwappa | 5:849446d19406 | 62 | }; |
gwappa | 5:849446d19406 | 63 | |
gwappa | 5:849446d19406 | 64 | struct Task { |
gwappa | 5:849446d19406 | 65 | ModeSelection mode; // the trial mode. |
gwappa | 5:849446d19406 | 66 | |
gwappa | 5:849446d19406 | 67 | Property<uint16_t> delay_min_ms; // the minimum duration for the delay. |
gwappa | 5:849446d19406 | 68 | |
gwappa | 5:849446d19406 | 69 | Property<uint16_t> delay_var_ms; // the average for the (exponential) variable |
gwappa | 5:849446d19406 | 70 | // duration of the delay. |
gwappa | 1:871d3066c2ab | 71 | |
gwappa | 5:849446d19406 | 72 | Property<uint16_t> prep_dur_ms; // the duration of the "preparatory period", |
gwappa | 1:871d3066c2ab | 73 | // during which licking is not allowed. |
gwappa | 1:871d3066c2ab | 74 | |
gwappa | 11:897ecd5413e0 | 75 | Property<uint16_t> aud_dur_ms; // the auditory cue duration. |
gwappa | 11:897ecd5413e0 | 76 | |
gwappa | 11:897ecd5413e0 | 77 | Property<uint16_t> aud_tick_hz; // the frequency of auditory cue flickering. |
gwappa | 5:849446d19406 | 78 | |
gwappa | 13:8ea85a33e37a | 79 | Property<uint16_t> resp_dur_ms; // the size of the minimal 'response window' for the passive paradigms. |
gwappa | 13:8ea85a33e37a | 80 | |
gwappa | 5:849446d19406 | 81 | Property<uint16_t> post_dur_ms; // the post-reward recording duration. |
gwappa | 1:871d3066c2ab | 82 | |
gwappa | 16:33c17c62840e | 83 | Property<uint16_t> reward_dur_ms; // the duration of reward. |
gwappa | 1:871d3066c2ab | 84 | |
gwappa | 29:1fb060aab1f8 | 85 | Property<uint16_t> onset_min_ms; // the minimum onset for the (passive) visual cue during the Associate mode. |
gwappa | 15:20f7f737c256 | 86 | |
gwappa | 29:1fb060aab1f8 | 87 | Property<uint16_t> onset_steps_n; // the number of steps in the onset during the Associate mode. |
gwappa | 11:897ecd5413e0 | 88 | |
gwappa | 29:1fb060aab1f8 | 89 | Property<uint16_t> vis_dur_ms; // the duration for the (passive) visual cue. |
gwappa | 14:af3adf5d5ddf | 90 | |
gwappa | 29:1fb060aab1f8 | 91 | Property<uint16_t> vis_test_every; // the frequency of 'test' trials during the Condition mode. |
gwappa | 11:897ecd5413e0 | 92 | |
gwappa | 25:56c4b22ec034 | 93 | Property<uint16_t> whisk_debounce_ms; // the debounce period for whisking events. |
gwappa | 25:56c4b22ec034 | 94 | |
gwappa | 22:41163fb3fdc6 | 95 | Property<uint16_t> lick_debounce_ms; // the debouncing period for licking events. |
gwappa | 22:41163fb3fdc6 | 96 | |
gwappa | 5:849446d19406 | 97 | Action test_reward; |
gwappa | 5:849446d19406 | 98 | |
gwappa | 5:849446d19406 | 99 | Action run; |
gwappa | 1:871d3066c2ab | 100 | |
gwappa | 28:797536a42b9f | 101 | explicit Task(const Mode& mode=Condition); |
gwappa | 1:871d3066c2ab | 102 | |
gwappa | 1:871d3066c2ab | 103 | void parseFromSerial(); |
gwappa | 1:871d3066c2ab | 104 | |
gwappa | 1:871d3066c2ab | 105 | private: |
gwappa | 5:849446d19406 | 106 | void testReward(); |
gwappa | 5:849446d19406 | 107 | void runTrial(); |
gwappa | 1:871d3066c2ab | 108 | void writeSettingsToSerial(); |
gwappa | 1:871d3066c2ab | 109 | }; |
gwappa | 1:871d3066c2ab | 110 | #endif |