Hi,
I tried to write soft code handler function and redefine the states, but it cannot work,
here is my state and soft code handler function,
sma = AddState(sma, 'Name', 'SetPunishAttenuation', ...
'Timer', .001,...
'StateChangeConditions', {'Tup', 'WaitforSoftCode1'},...
'OutputActions', {'SoftCode',1});
sma = AddState(sma, 'Name', 'WaitforSoftCode1', ...
'Timer', .001,...
'StateChangeConditions', {'SoftCode1', 'PlayPunishSound'},...
'OutputActions', {});
sma = AddState(sma, 'Name', 'PlayPunishSound', ...
'Timer', S.GUI.ErrorDelay,...
'StateChangeConditions', {'Tup', 'ResetAttenuation'},...
'OutputActions', {'HiFi1', ['P' 2]});
sma = AddState(sma, 'Name', 'ResetAttenuation', ...
'Timer', .001,...
'StateChangeConditions', {'Tup', 'WaitforSoftCode2'},...
'OutputActions', {'SoftCode', 2});
sma = AddState(sma, 'Name', 'WaitforSoftCode2', ...
'Timer', .001,...
'StateChangeConditions', {'SoftCode2', '>exit'},...
'OutputActions', {});
function SoftCodeHandler_ErrorSound(softcode)
global BpodSystem
if softcode == 1
BpodSystem.PluginObjects.Sound.DigitalAttenuation_dB = -20;
elseif softcode == 2
BpodSystem.PluginObjects.Sound.DigitalAttenuation_dB = FA(currentTrial);
end
and I also added
BpodSystem.SoftCodeHandlerFunction = 'SoftCodeHandler_ErrorSound';
in the protocol.
When I run the protocol, it gets stuck at WaitforSoftCode1 and doesn’t proceed to PlayPunishSound. No error is shown in the command window either.
Do you have any suggestions for what might be causing the soft code not to be received or acknowledged by the state machine?
Thanks so much!