outputaddressing corrected
declared notifyDccAccState for backward compatibility
This commit is contained in:
15
NmraDcc.cpp
15
NmraDcc.cpp
@@ -605,7 +605,7 @@ uint16_t getMyAddr(void)
|
|||||||
if( CV29Value & CV29_ACCESSORY_DECODER ) // Accessory Decoder?
|
if( CV29Value & CV29_ACCESSORY_DECODER ) // Accessory Decoder?
|
||||||
{
|
{
|
||||||
if( CV29Value & CV29_OUTPUT_ADDRESS_MODE )
|
if( CV29Value & CV29_OUTPUT_ADDRESS_MODE )
|
||||||
DccProcState.myDccAddress = ( readCV( CV_ACCESSORY_DECODER_ADDRESS_MSB ) << 8 ) | readCV( CV_ACCESSORY_DECODER_ADDRESS_LSB ) - 1;
|
DccProcState.myDccAddress = ( readCV( CV_ACCESSORY_DECODER_ADDRESS_MSB ) << 8 ) | readCV( CV_ACCESSORY_DECODER_ADDRESS_LSB );
|
||||||
else
|
else
|
||||||
DccProcState.myDccAddress = ( ( readCV( CV_ACCESSORY_DECODER_ADDRESS_MSB ) & 0b00000111) << 6 ) | ( readCV( CV_ACCESSORY_DECODER_ADDRESS_LSB ) & 0b00111111) ;
|
DccProcState.myDccAddress = ( ( readCV( CV_ACCESSORY_DECODER_ADDRESS_MSB ) & 0b00000111) << 6 ) | ( readCV( CV_ACCESSORY_DECODER_ADDRESS_LSB ) & 0b00111111) ;
|
||||||
}
|
}
|
||||||
@@ -1071,7 +1071,8 @@ void execDccProcessor( DCC_MSG * pDccMsg )
|
|||||||
|
|
||||||
TurnoutPairIndex = (pDccMsg->Data[1] & 0b00000110) >> 1;
|
TurnoutPairIndex = (pDccMsg->Data[1] & 0b00000110) >> 1;
|
||||||
|
|
||||||
OutputAddress = (((BoardAddress - 1) << 2 ) | TurnoutPairIndex) + 1 ;
|
OutputAddress = (((BoardAddress - 1) << 2 ) | TurnoutPairIndex) + 1 ; //decoder output addresses start with 1, packet address range starts with 0
|
||||||
|
// ( according to NMRA 9.2.2 )
|
||||||
|
|
||||||
if( DccProcState.inAccDecDCCAddrNextReceivedMode)
|
if( DccProcState.inAccDecDCCAddrNextReceivedMode)
|
||||||
{
|
{
|
||||||
@@ -1081,9 +1082,9 @@ void execDccProcessor( DCC_MSG * pDccMsg )
|
|||||||
Serial.print(F("execDccProcessor: Set Output Addr: "));
|
Serial.print(F("execDccProcessor: Set Output Addr: "));
|
||||||
Serial.println(OutputAddress);
|
Serial.println(OutputAddress);
|
||||||
#endif
|
#endif
|
||||||
uint16_t storedOutputAddress = OutputAddress + 1; // The value stored in CV1 & 9 for Output Addressing Mode is + 1
|
//uint16_t storedOutputAddress = OutputAddress + 1; // The value stored in CV1 & 9 for Output Addressing Mode is + 1
|
||||||
writeCV(CV_ACCESSORY_DECODER_ADDRESS_LSB, (uint8_t)(storedOutputAddress % 256));
|
writeCV(CV_ACCESSORY_DECODER_ADDRESS_LSB, (uint8_t)(OutputAddress % 256));
|
||||||
writeCV(CV_ACCESSORY_DECODER_ADDRESS_MSB, (uint8_t)(storedOutputAddress / 256));
|
writeCV(CV_ACCESSORY_DECODER_ADDRESS_MSB, (uint8_t)(OutputAddress / 256));
|
||||||
|
|
||||||
if( notifyDccAccOutputAddrSet )
|
if( notifyDccAccOutputAddrSet )
|
||||||
notifyDccAccOutputAddrSet(OutputAddress);
|
notifyDccAccOutputAddrSet(OutputAddress);
|
||||||
@@ -1136,6 +1137,10 @@ void execDccProcessor( DCC_MSG * pDccMsg )
|
|||||||
{
|
{
|
||||||
uint8_t direction = pDccMsg->Data[1] & 0b00000001;
|
uint8_t direction = pDccMsg->Data[1] & 0b00000001;
|
||||||
uint8_t outputPower = (pDccMsg->Data[1] & 0b00001000) >> 3;
|
uint8_t outputPower = (pDccMsg->Data[1] & 0b00001000) >> 3;
|
||||||
|
|
||||||
|
// for compatibility with 1.4.2
|
||||||
|
if ( notifyDccAccState )
|
||||||
|
notifyDccAccState( OutputAddress, BoardAddress, pDccMsg->Data[1] & 0b00000111, outputPower );
|
||||||
|
|
||||||
if( DccProcState.Flags & FLAGS_OUTPUT_ADDRESS_MODE )
|
if( DccProcState.Flags & FLAGS_OUTPUT_ADDRESS_MODE )
|
||||||
{
|
{
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
//
|
//
|
||||||
// Model Railroading with Arduino - NmraDcc.h
|
// Model Railroading with Arduino - NmraDcc.h
|
||||||
//
|
//
|
||||||
// Copyright (c) 2008 - 2105 Alex Shepherd
|
// Copyright (c) 2008 - 2018 Alex Shepherd
|
||||||
//
|
//
|
||||||
// This source file is subject of the GNU general public license 2,
|
// This source file is subject of the GNU general public license 2,
|
||||||
// that is available at the world-wide-web at
|
// that is available at the world-wide-web at
|
||||||
@@ -670,6 +670,9 @@ extern void notifyCVResetFactoryDefault(void) __attribute__ ((weak));
|
|||||||
*/
|
*/
|
||||||
extern void notifyCVAck(void) __attribute__ ((weak));
|
extern void notifyCVAck(void) __attribute__ ((weak));
|
||||||
|
|
||||||
|
// Deprecated, only for backward compatibility with version 1.4.2. Don't use in new designs
|
||||||
|
extern void notifyDccAccState( uint16_t Addr, uint16_t BoardAddr, uint8_t OutputAddr, uint8_t State ) __attribute__ ((weak));
|
||||||
|
|
||||||
#if defined (__cplusplus)
|
#if defined (__cplusplus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user