fast-feedback virtual target task code on STM Nucleo

Dependencies:   mbed

Revision:
5:849446d19406
Parent:
4:fcf597f82632
Child:
9:e136394bdb39
--- a/task.h	Wed May 23 15:15:03 2018 +0000
+++ b/task.h	Thu May 24 14:47:48 2018 +0000
@@ -2,10 +2,12 @@
 #define TASK_H_
 
 #include "mbed.h"
+#include "config.h"
 
 /*
  * command characters
  */
+#define CMD_ID_MODE       '_'
 #define CMD_MODE_PAIR     'P'
 #define CMD_MODE_REPORT   'R'
 #define CMD_MODE_APPEAR   'A'
@@ -25,29 +27,51 @@
     Appear
 };
 
-struct Task {
-    Mode        mode;           // the trial mode.
+struct ModeSelection: public config::CommandResponder
+{
+    ModeSelection(); // not allowed
+    
+    explicit ModeSelection(const Mode& defaultValue);
     
-    uint16_t    delay_min_ms;   // the minimum duration for the delay.
+    virtual ~ModeSelection();
+    
+    virtual bool parse(const char& c);
+    
+    virtual bool writeSettings();
     
-    uint16_t    delay_var_ms;   // the average for the (exponential) variable 
-                                // duration of the delay.
+    virtual void echoback();
+    
+    Mode value;
+};
+
+struct Task {
+    ModeSelection       mode;           // the trial mode.
+    
+    Property<uint16_t>  delay_min_ms;   // the minimum duration for the delay.
+    
+    Property<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", 
+    Property<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.
+    Property<uint16_t>  cue_dur_ms;     // the cue duration.
+    
+    Property<uint16_t>  post_dur_ms;    // the post-reward recording duration.
     
-    uint16_t    post_dur_ms;    // the post-reward recording duration.
+    Property<uint16_t>  reward_ms;      // the duration of reward.
     
-    uint16_t    reward_ms;      // the duration of reward.reward_ms
+    Action              test_reward;
+    
+    Action              run;
     
     explicit Task(const Mode& mode=Pair);
     
     void parseFromSerial();
     
 private:
-    void writeModeToSerial(bool newline=true);
+    void testReward();
+    void runTrial();
     void writeSettingsToSerial();
 };
 #endif
\ No newline at end of file