Merge branch 'ESU_ECoS_CV_Programming'
* ESU_ECoS_CV_Programming: Added ESU ECoS CV Programming support
This commit is contained in:
45
NmraDcc.cpp
45
NmraDcc.cpp
@@ -981,26 +981,45 @@ void execDccProcessor( DCC_MSG * pDccMsg )
|
||||
|
||||
Address = ( ( ( BoardAddress - 1 ) << 2 ) | OutputIndex ) + 1 ;
|
||||
|
||||
if(pDccMsg->Data[1] & 0b10000000)
|
||||
if( pDccMsg->Size == 6 && (pDccMsg->Data[2] & 0b11100000) == 0b11100000 && (pDccMsg->Data[1] & 0b00001111) == 0 )
|
||||
{
|
||||
uint8_t direction = OutputAddress & 0x01;
|
||||
uint8_t outputPower = (pDccMsg->Data[1] & 0b00001000) >> 3;
|
||||
// Accessory CV programming, program entire decoder
|
||||
|
||||
if( notifyDccAccState )
|
||||
notifyDccAccState( Address, BoardAddress, OutputAddress, pDccMsg->Data[1] & 0b00001000 ) ;
|
||||
// Process only if it is our board address or a broadcast
|
||||
// (even if we have more than one address on this decoder,
|
||||
// CV programming is allowed only for address defined in CV1/CV9)
|
||||
if( BoardAddress == getMyAddr() || BoardAddress == 511 )
|
||||
{
|
||||
uint16_t CVAddr = ( ( ( pDccMsg->Data[2] & 0x03 ) << 8 ) | pDccMsg->Data[3] ) + 1 ;
|
||||
uint8_t Value = pDccMsg->Data[4] ;
|
||||
|
||||
if( notifyDccAccTurnoutBoard )
|
||||
notifyDccAccTurnoutBoard( BoardAddress, OutputIndex, direction, outputPower );
|
||||
processDirectOpsOperation( pDccMsg->Data[2] & 0b00001100, CVAddr, Value ) ;
|
||||
}
|
||||
|
||||
if( notifyDccAccTurnoutOutput )
|
||||
notifyDccAccTurnoutOutput( Address, direction, outputPower );
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if( notifyDccSigState )
|
||||
notifyDccSigState( Address, OutputIndex, pDccMsg->Data[2] ) ;
|
||||
}
|
||||
if(pDccMsg->Data[1] & 0b10000000)
|
||||
{
|
||||
uint8_t direction = OutputAddress & 0x01;
|
||||
uint8_t outputPower = (pDccMsg->Data[1] & 0b00001000) >> 3;
|
||||
|
||||
if( notifyDccAccState )
|
||||
notifyDccAccState( Address, BoardAddress, OutputAddress, pDccMsg->Data[1] & 0b00001000 ) ;
|
||||
|
||||
if( notifyDccAccTurnoutBoard )
|
||||
notifyDccAccTurnoutBoard( BoardAddress, OutputIndex, direction, outputPower );
|
||||
|
||||
if( notifyDccAccTurnoutOutput )
|
||||
notifyDccAccTurnoutOutput( Address, direction, outputPower );
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if( notifyDccSigState )
|
||||
notifyDccSigState( Address, OutputIndex, pDccMsg->Data[2] ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user