Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: states.cpp
- Revision:
- 16:33c17c62840e
- Parent:
- 15:20f7f737c256
- Child:
- 17:0b241aa1f5b6
--- a/states.cpp Mon Jun 25 17:43:40 2018 +0000
+++ b/states.cpp Sat Jun 30 12:28:18 2018 +0000
@@ -27,7 +27,6 @@
// initialize the trial-related params
trial.reset(task);
audioOut.write(0);
- rewardOut.setDuration(ms_to_us(task.reward_ms.value));
events::setup(true);
// set up the timeout for the next state
@@ -35,6 +34,9 @@
case Pair:
stateTimeout.attach_us(&automaton::jump<Delay,Paired>, ms_to_us(trial.delay_dur_ms + task.prep_dur_ms.value));
break;
+ case MotionAlt:
+ stateTimeout.attach_us(&automaton::jump<Delay,Cued>, ms_to_us(trial.delay_dur_ms + task.prep_dur_ms.value));
+ break;
default:
stateTimeout.attach_us(&automaton::jump<Delay,Prepare>, ms_to_us(trial.delay_dur_ms));
}
@@ -91,13 +93,20 @@
trial.response &= ~TrialFlags::Cues;
// configure the interrupts
- events::lickhandler = &automaton::jump<Cued,Abort>;
+ if (task.mode.value != MotionAlt) {
+ events::lickhandler = &automaton::jump<Cued,Abort>;
+ }
// "cue" comes from either internal visual stimulus generation (Report, Associate)
// or the animal's whisker motion (Motion)
- if (task.mode.value == Motion) {
+ switch (task.mode.value) {
+ case Motion:
events::whiskhandler = &Cued::gate;
- } else {
+ break;
+ case MotionAlt:
+ events::whiskhandler = &automaton::jump<Cued,WithResp>;
+ break;
+ default:
events::gatehandler = &Cued::gate;
}
@@ -111,6 +120,7 @@
visualOut.run();
// fallthrough (with auditory cue)
case Motion:
+ case MotionAlt:
audioOut.write(1);
buzzerTicker.attach_us(&tickBuzzer, trial.aud_ticker_cycle);
}
@@ -133,7 +143,7 @@
// end cue output
buzzerTicker.detach();
audioOut.write(0);
- if (task.mode.value != Motion) {
+ if ((task.mode.value != Motion) && (task.mode.value != MotionAlt)) {
visualOut.stop();
}
}
@@ -190,9 +200,10 @@
LOGSTATE(TestReward)
// open/close the valve
- rewardOut.setDuration(ms_to_us(task.reward_ms.value));
+ rewardOut.setOnset(0);
+ rewardOut.setDuration(ms_to_us(task.reward_dur_ms.value));
rewardOut.start();
- stateTimeout.attach_us(&automaton::done<TestReward>, ms_to_us(task.reward_ms.value+20));
+ stateTimeout.attach_us(&automaton::done<TestReward>, ms_to_us(task.reward_dur_ms.value+100));
}
void TestReward::teardown() {