diff --git a/WiThrottle.cpp b/WiThrottle.cpp index 3974b54..8fa6464 100644 --- a/WiThrottle.cpp +++ b/WiThrottle.cpp @@ -135,21 +135,22 @@ void WiThrottle::parse(Print & stream, byte * cmdx) { bool newstate=false; Turnout * tt=Turnout::get(id); if (!tt) { + // If turnout does not exist, create it + int addr = ((id - 1) / 4) + 1; + int subaddr = (id - 1) % 4; + Turnout::create(id,addr,subaddr); + StringFormatter::send(stream, F("HMTurnout %d created\n"),id); +/* StringFormatter::send(stream, F("HMTurnout %d Unknown\n"),id); break; +*/ } switch (cmd[3]) { case 'T': newstate=true; break; case 'C': newstate=false; break; case '2': newstate=!Turnout::isActive(id); } - // If turnout does not exist, create it - if (Turnout::activate(id,newstate) == false) { - int addr = ((id - 1) / 4) + 1; - int subaddr = (id - 1) % 4; - Turnout::create(id,addr,subaddr); - Turnout::activate(id,newstate); - } + Turnout::activate(id,newstate); StringFormatter::send(stream, F("PTA%c%d\n"),newstate?'4':'2',id ); } break;