mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-24 13:21:23 +01:00
Parse ONOFF with 4 param <a> command
This commit is contained in:
parent
d3b72dc4fc
commit
c7b38170c1
@ -272,20 +272,29 @@ void DCCEXParser::parse(Print *stream, byte *com, RingStream * ringStream)
|
|||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'a': // ACCESSORY <a ADDRESS SUBADDRESS ACTIVATE> or <a LINEARADDRESS ACTIVATE>
|
case 'a': // ACCESSORY <a ADDRESS SUBADDRESS ACTIVATE [ONOFF]> or <a LINEARADDRESS ACTIVATE>
|
||||||
{
|
{
|
||||||
int address;
|
int address;
|
||||||
byte subaddress;
|
byte subaddress;
|
||||||
byte activep;
|
byte activep;
|
||||||
|
byte onoff;
|
||||||
if (params==2) { // <a LINEARADDRESS ACTIVATE>
|
if (params==2) { // <a LINEARADDRESS ACTIVATE>
|
||||||
address=(p[0] - 1) / 4 + 1;
|
address=(p[0] - 1) / 4 + 1;
|
||||||
subaddress=(p[0] - 1) % 4;
|
subaddress=(p[0] - 1) % 4;
|
||||||
activep=1;
|
activep=1;
|
||||||
|
onoff=2; // send both
|
||||||
}
|
}
|
||||||
else if (params==3) { // <a ADDRESS SUBADDRESS ACTIVATE>
|
else if (params==3) { // <a ADDRESS SUBADDRESS ACTIVATE>
|
||||||
address=p[0];
|
address=p[0];
|
||||||
subaddress=p[1];
|
subaddress=p[1];
|
||||||
activep=2;
|
activep=2;
|
||||||
|
onoff=2; // send both
|
||||||
|
}
|
||||||
|
else if (params==4) { // <a ADDRESS SUBADDRESS ACTIVATE ONOFF>
|
||||||
|
address=p[0];
|
||||||
|
subaddress=p[1];
|
||||||
|
activep=2;
|
||||||
|
onoff=p[3];
|
||||||
}
|
}
|
||||||
else break; // invalid no of parameters
|
else break; // invalid no of parameters
|
||||||
|
|
||||||
@ -293,12 +302,13 @@ void DCCEXParser::parse(Print *stream, byte *com, RingStream * ringStream)
|
|||||||
((address & 0x01FF) != address) // invalid address (limit 9 bits )
|
((address & 0x01FF) != address) // invalid address (limit 9 bits )
|
||||||
|| ((subaddress & 0x03) != subaddress) // invalid subaddress (limit 2 bits )
|
|| ((subaddress & 0x03) != subaddress) // invalid subaddress (limit 2 bits )
|
||||||
|| ((p[activep] & 0x01) != p[activep]) // invalid activate 0|1
|
|| ((p[activep] & 0x01) != p[activep]) // invalid activate 0|1
|
||||||
|
|| ((onoff & 0x01) != onoff) // invalid onoff 0|1
|
||||||
) break;
|
) break;
|
||||||
// Honour the configuration option (config.h) which allows the <a> command to be reversed
|
// Honour the configuration option (config.h) which allows the <a> command to be reversed
|
||||||
#ifdef DCC_ACCESSORY_COMMAND_REVERSE
|
#ifdef DCC_ACCESSORY_COMMAND_REVERSE
|
||||||
DCC::setAccessory(address, subaddress,p[activep]==0);
|
DCC::setAccessory(address, subaddress,p[activep]==0,onoff);
|
||||||
#else
|
#else
|
||||||
DCC::setAccessory(address, subaddress,p[activep]==1);
|
DCC::setAccessory(address, subaddress,p[activep]==1,onoff);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user