mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-27 01:56:14 +01:00
The auto create turnout feature should be there
This commit is contained in:
parent
11395dde2b
commit
4fce31158f
|
@ -135,21 +135,22 @@ void WiThrottle::parse(Print & stream, byte * cmdx) {
|
||||||
bool newstate=false;
|
bool newstate=false;
|
||||||
Turnout * tt=Turnout::get(id);
|
Turnout * tt=Turnout::get(id);
|
||||||
if (!tt) {
|
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);
|
StringFormatter::send(stream, F("HMTurnout %d Unknown\n"),id);
|
||||||
break;
|
break;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
switch (cmd[3]) {
|
switch (cmd[3]) {
|
||||||
case 'T': newstate=true; break;
|
case 'T': newstate=true; break;
|
||||||
case 'C': newstate=false; break;
|
case 'C': newstate=false; break;
|
||||||
case '2': newstate=!Turnout::isActive(id);
|
case '2': newstate=!Turnout::isActive(id);
|
||||||
}
|
}
|
||||||
// If turnout does not exist, create it
|
Turnout::activate(id,newstate);
|
||||||
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);
|
|
||||||
}
|
|
||||||
StringFormatter::send(stream, F("PTA%c%d\n"),newstate?'4':'2',id );
|
StringFormatter::send(stream, F("PTA%c%d\n"),newstate?'4':'2',id );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user