mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-27 01:56:14 +01:00
Autocreate turnouts
This commit is contained in:
parent
deec8b7e8c
commit
b886a09f82
|
@ -21,6 +21,7 @@
|
|||
#include "StringFormatter.h"
|
||||
#include "Hardware.h"
|
||||
#include "PWMServoDriver.h"
|
||||
//#include "DIAG.h" // uncomment if you need DIAG below
|
||||
|
||||
bool Turnout::activate(int n,bool state){
|
||||
//DIAG(F("\nTurnout::activate(%d,%d)\n"),n,state);
|
||||
|
|
|
@ -133,14 +133,19 @@ void WiThrottle::parse(Print & stream, byte * cmdx) {
|
|||
else if (cmd[1]=='T' && cmd[2]=='A') { // PTA accessory toggle
|
||||
// TODO... if we are given an address that is not a known Turnout...
|
||||
// should we create one or just send the DCC message.
|
||||
int id=getInt(cmd+6);
|
||||
int id=getInt(cmd+4);
|
||||
bool newstate=false;
|
||||
switch (cmd[3]) {
|
||||
case 'T': newstate=true; break;
|
||||
case 'C': newstate=false; break;
|
||||
case '2': newstate=!Turnout::isActive(id);
|
||||
}
|
||||
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%cDT%d\n"),newstate?'4':'2',id );
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue
Block a user