Keisuke Sehara / Mbed 2 deprecated STM32_Whisking

Dependencies:   mbed

Revision:
22:41163fb3fdc6
Parent:
21:e51733fc1c36
Child:
24:e236faf66935
--- a/states.cpp	Mon Jul 02 11:51:16 2018 +0000
+++ b/states.cpp	Tue Jul 03 10:50:14 2018 +0000
@@ -21,7 +21,7 @@
     
     // initialize the trial-related params
     trial.reset(task);
-    events::setup(true);
+    events::setup(true, task.lick_debounce_ms.value);
     
     // set up the timeout for the next state
     switch (task.mode.value) {
@@ -175,8 +175,9 @@
     events::lickhandler  = 0;
     events::gatehandler  = 0;
     
+    // open/close the valve, only when the cue was there
+    // (for Pair, reward will be there no matter the response)
     if ((task.mode.value == Pair) || trial.flag.cued ) {
-        // open/close the valve, only when the cue was there
         rewardOut.start();
     }
     
@@ -193,7 +194,10 @@
     events::lickhandler  = 0;
     events::gatehandler  = 0;
     
-    // no reward here no matter the mode
+    // no reward here, except for Pair
+    if (task.mode.value == Pair) {
+        rewardOut.start();
+    }
     
     stateTimeout.attach_us(&automaton::done<NoResp>, ms_to_us(task.post_dur_ms.value));
 }