updated the examples to reflect the removal of support for the two call-back functions: notifyDccAccState(), notifyDccSigState()

This commit is contained in:
Alex Shepherd
2018-02-28 23:50:59 +13:00
parent 90470987a8
commit ec801bf463
8 changed files with 48 additions and 183 deletions

View File

@@ -1,103 +0,0 @@
------------------------------------------------------------------------
OpenDCC - NmraDcc
Copyright (c) 2008 Alex Shepherd
This source file is subject of the GNU general public license 2,
that is available at the world-wide-web at
http:www.gnu.org/licenses/gpl.txt
------------------------------------------------------------------------
file: Description NmraDcc.txt
author:
webpage:
history:
------------------------------------------------------------------------
Call the DCC pin function to define which External Interrupt and Pin to use and also to enable the Pull-Up
Dcc.pin(0, 2, 1);
Call the main DCC Init function to enable the DCC Receiver
Dcc.init( MAN_ID_DIY, 10, FLAGS_OUTPUT_ADDRESS_MODE | FLAGS_DCC_ACCESSORY_DECODER, 0 )
MAN_ID_DIY = 0x0D (CV8 defined in NmraDcc.h)
FLAGS_OUTPUT_ADDRESS_MODE = 0x40 (CV29/541 bit 6 defined in NmraDcc.h)
FLAGS_DCC_ACCESSORY_DECODER = 0x80 (CV 29/541 bit 7 defined in NmraDcc.h)
------------------------------------------------------------------------
You MUST call the NmraDcc.process() method frequently from the Arduino loop()
function for correct library operation
Dcc.process();
------------------------------------------------------------------------
This function is called whenever a normal DCC Turnout Packet is received
notifyDccAccState( uint16_t Addr, uint16_t BoardAddr, uint8_t OutputAddr, uint8_t State)
Addr = Decoder address
BoardAddr = Address of this decoder
OutputAddr = Address of Turnout on this decoder
State =
------------------------------------------------------------------------
This function is called whenever a DCC Signal Aspect Packet is received
notifyDccSigState( uint16_t Addr, uint8_t OutputIndex, uint8_t State)
Addr = Decoder address
OutputIndex = Address of Signal Aspect
State =
------------------------------------------------------------------------
notifyDccFunc( uint16_t Addr, uint8_t FuncNum, uint8_t FuncState)
Addr = Decoder address
FuncNum =
FuncState =
------------------------------------------------------------------------
Perform a decoder total reset
notifyDccReset(uint8_t hardReset )
hardReset =
------------------------------------------------------------------------
The decoder receives a Idle packet and should do nothing
notifyDccIdle(void)
------------------------------------------------------------------------
A locomotive packet is received
notifyDccSpeed( uint16_t Addr, uint8_t Speed, uint8_t ForwardDir, uint8_t MaxSpeed )
Addr = Address received
Speed = Requested speed
ForwardDir = True if loco moves forward
MaxSpeed =
------------------------------------------------------------------------
Checks if a CV is present in the table and is writable
notifyCVValid( uint16_t CV, uint8_t Writable )
CV = The number of the requested CV
Writable = True is CV is writable
------------------------------------------------------------------------
Read a CV value from the decoder table
notifyCVRead( uint16_t CV)
CV = The number of the requested CV
------------------------------------------------------------------------
Write a CV with Value to the decoder table
notifyCVWrite( uint16_t CV, uint8_t Value)
CV = The number of the requested CV
Value = Value to be written into the requested CV
------------------------------------------------------------------------
Check if the CV written to the table has the correct value
notifyCVChange( uint16_t CV, uint8_t Value)
CV = The number of the requested CV
Value = Value of the changed requested CV
------------------------------------------------------------------------
notifyCVAck(void)

View File

@@ -471,6 +471,7 @@ extern void notifyDccFunc( uint16_t Addr, DCC_ADDR_TYPE AddrType, FN_GROUP Fu
* Returns: * Returns:
* None * None
*/ */
extern void notifyDccAccTurnoutBoard( uint16_t BoardAddr, uint8_t OutputPair, uint8_t Direction, uint8_t OutputPower ) __attribute__ ((weak)); extern void notifyDccAccTurnoutBoard( uint16_t BoardAddr, uint8_t OutputPair, uint8_t Direction, uint8_t OutputPower ) __attribute__ ((weak));
/*+ /*+
* notifyDccAccTurnoutOutput() Output oriented callback for a turnout accessory decoder. * notifyDccAccTurnoutOutput() Output oriented callback for a turnout accessory decoder.
@@ -550,7 +551,7 @@ extern void notifyDccSigOutputState( uint16_t Addr, uint8_t State) __attribut
* Returns: * Returns:
* None * None
*/ */
extern void notifyDccMsg( DCC_MSG * Msg ) __attribute__ ((weak)); extern void notifyDccMsg( DCC_MSG * Msg ) __attribute__ ((weak));
/*+ /*+
* notifyCVValid() Callback to determine if a given CV is valid. * notifyCVValid() Callback to determine if a given CV is valid.

View File

@@ -1,2 +1,8 @@
# NmraDcc # NmraDcc
NMRA Digital Command Control (DCC) Library NMRA Digital Command Control (DCC) Library
**Warning** as of version 1.4.4 support has been removed for the following two call-back functions, which will cause your sketch to silently stop working:
extern void notifyDccAccState( uint16_t Addr, uint16_t BoardAddr, uint8_t OutputAddr, uint8_t State )
extern void notifyDccSigState( uint16_t Addr, uint8_t OutputIndex, uint8_t State)

View File

@@ -56,20 +56,7 @@ void notifyDccMsg( DCC_MSG * Msg)
} }
#endif #endif
// This function is called whenever a normal DCC Turnout Packet is received // This function is called whenever a normal DCC Turnout Packet is received and we're in Board Addressing Mode
void notifyDccAccState( uint16_t Addr, uint16_t BoardAddr, uint8_t OutputAddr, uint8_t State)
{
Serial.print("notifyDccAccState: ") ;
Serial.print(Addr,DEC) ;
Serial.print(',');
Serial.print(BoardAddr,DEC) ;
Serial.print(',');
Serial.print(OutputAddr,DEC) ;
Serial.print(',');
Serial.println(State, HEX) ;
}
// This function is called whenever a normal DCC Turnout Packet is received
void notifyDccAccTurnoutBoard( uint16_t BoardAddr, uint8_t OutputPair, uint8_t Direction, uint8_t OutputPower ) void notifyDccAccTurnoutBoard( uint16_t BoardAddr, uint8_t OutputPair, uint8_t Direction, uint8_t OutputPower )
{ {
Serial.print("notifyDccAccTurnoutBoard: ") ; Serial.print("notifyDccAccTurnoutBoard: ") ;
@@ -82,7 +69,7 @@ void notifyDccAccTurnoutBoard( uint16_t BoardAddr, uint8_t OutputPair, uint8_t D
Serial.println(OutputPower, HEX) ; Serial.println(OutputPower, HEX) ;
} }
// This function is called whenever a normal DCC Turnout Packet is received // This function is called whenever a normal DCC Turnout Packet is received and we're in Output Addressing Mode
void notifyDccAccTurnoutOutput( uint16_t Addr, uint8_t Direction, uint8_t OutputPower ) void notifyDccAccTurnoutOutput( uint16_t Addr, uint8_t Direction, uint8_t OutputPower )
{ {
Serial.print("notifyDccAccTurnoutOutput: ") ; Serial.print("notifyDccAccTurnoutOutput: ") ;
@@ -94,13 +81,11 @@ void notifyDccAccTurnoutOutput( uint16_t Addr, uint8_t Direction, uint8_t Output
} }
// This function is called whenever a DCC Signal Aspect Packet is received // This function is called whenever a DCC Signal Aspect Packet is received
void notifyDccSigState( uint16_t Addr, uint8_t OutputIndex, uint8_t State) void notifyDccSigOutputState( uint16_t Addr, uint8_t State)
{ {
Serial.print("notifyDccSigState: ") ; Serial.print("notifyDccSigOutputState: ") ;
Serial.print(Addr,DEC) ; Serial.print(Addr,DEC) ;
Serial.print(','); Serial.print(',');
Serial.print(OutputIndex,DEC) ;
Serial.print(',');
Serial.println(State, HEX) ; Serial.println(State, HEX) ;
} }

View File

@@ -134,24 +134,6 @@ void notifyCVResetFactoryDefault()
FactoryDefaultCVIndex = sizeof(FactoryDefaultCVs)/sizeof(CVPair); FactoryDefaultCVIndex = sizeof(FactoryDefaultCVs)/sizeof(CVPair);
}; };
// This function is called whenever a normal DCC Turnout Packet is received
#define NOTITY_DCC_ACC_STATE
#ifdef NOTITY_DCC_ACC_STATE
void notifyDccAccState( uint16_t Addr, uint16_t BoardAddr, uint8_t OutputAddr, uint8_t State)
{
if (ShowData & S_DCC) {
Serial.print("notifyDccAccState: ") ;
Serial.print(Addr,DEC) ;
Serial.print(',');
Serial.print(BoardAddr,DEC) ;
Serial.print(',');
Serial.print(OutputAddr,DEC) ;
Serial.print(',');
Serial.println(State, HEX) ;
}
}
#endif // NOTITY_DCC_ACC_STATE
// This function is called whenever a normal DCC Turnout Packet is received // This function is called whenever a normal DCC Turnout Packet is received
#define NOTITY_DCC_ACC_TURNOUT_BOARD #define NOTITY_DCC_ACC_TURNOUT_BOARD
#ifdef NOTITY_DCC_ACC_TURNOUT_BOARD #ifdef NOTITY_DCC_ACC_TURNOUT_BOARD
@@ -202,7 +184,7 @@ void notifyDccAccTurnoutOutput( uint16_t Addr, uint8_t Direction, uint8_t Output
// if NOTIFY_DCC_SIG_STATE and SIGNAL_DCC are defined. // if NOTIFY_DCC_SIG_STATE and SIGNAL_DCC are defined.
#define NOTITY_DCC_SIG_STATE #define NOTITY_DCC_SIG_STATE
#if defined(NOTITY_DCC_SIG_STATE) && defined(SIGNAL_DCC) #if defined(NOTITY_DCC_SIG_STATE) && defined(SIGNAL_DCC)
void notifyDccSigState( uint16_t Addr, uint8_t OutputIndex, uint8_t State) void notifyDccSigOutputState( uint16_t Addr, uint8_t State)
{ {
#ifdef DO_SCOPE #ifdef DO_SCOPE
digitalWrite(SCOPE_PIN, HIGH); digitalWrite(SCOPE_PIN, HIGH);
@@ -210,11 +192,9 @@ void notifyDccSigState( uint16_t Addr, uint8_t OutputIndex, uint8_t State)
#endif // DO_SCOPE #endif // DO_SCOPE
if (ShowData & S_DCC) { if (ShowData & S_DCC) {
Serial.print("notifyDccSigState: ") ; Serial.print("notifyDccSigOutputState: ") ;
Serial.print(Addr,DEC) ; Serial.print(Addr,DEC) ;
Serial.print(','); Serial.print(',');
Serial.print(OutputIndex,DEC) ;
Serial.print(',');
Serial.println(State, DEC) ; Serial.println(State, DEC) ;
} }

View File

@@ -370,22 +370,17 @@ void loop() //****************************************************************
} }
} }
extern void notifyDccAccState( uint16_t Addr, uint16_t BoardAddr, uint8_t OutputAddr, uint8_t State) { extern void notifyDccAccTurnoutOutput( uint16_t Addr, uint8_t Direction, uint8_t OutputPower ) {
uint16_t Current_Decoder_Addr; uint16_t Current_Decoder_Addr = Dcc.getAddr();
uint8_t Bit_State;
Current_Decoder_Addr = Dcc.getAddr();
Bit_State = OutputAddr & 0x01;
if ( Addr >= Current_Decoder_Addr && Addr < Current_Decoder_Addr+17) { //Controls Accessory_Address+16 if ( Addr >= Current_Decoder_Addr && Addr < Current_Decoder_Addr+17) { //Controls Accessory_Address+16
#ifdef DEBUG #ifdef DEBUG
Serial.print("Addr = "); Serial.print("Addr = ");
Serial.println(Addr); Serial.println(Addr);
Serial.print("BoardAddr = "); Serial.print("Direction = ");
Serial.println(BoardAddr); Serial.println(Direction);
Serial.print("Bit_State = ");
Serial.println(Bit_State);
#endif #endif
exec_function(Addr-Current_Decoder_Addr, Bit_State ); exec_function(Addr-Current_Decoder_Addr, Direction );
} }
} }
void exec_function (int function, int FuncState) { void exec_function (int function, int FuncState) {

View File

@@ -12,51 +12,52 @@ NmraDcc KEYWORD1
####################################### #######################################
# Methods and Functions (KEYWORD2) # Methods and Functions (KEYWORD2)
####################################### #######################################
NmraDcc KEYWORD2 NmraDcc KEYWORD2
pin KEYWORD2 pin KEYWORD2
init KEYWORD2 init KEYWORD2
process KEYWORD2 process KEYWORD2
getCV KEYWORD2 getCV KEYWORD2
setCV KEYWORD2 setCV KEYWORD2
isSetCVReady KEYWORD2 isSetCVReady KEYWORD2
notifyDccReset KEYWORD2 notifyDccReset KEYWORD2
notifyDccIdle KEYWORD2 notifyDccIdle KEYWORD2
notifyDccSpeed KEYWORD2 notifyDccSpeed KEYWORD2
notifyDccSpeedRaw notifyDccSpeedRaw KEYWORD2
notifyDccFunc KEYWORD2 notifyDccFunc KEYWORD2
notifyDccAccState KEYWORD2 notifyDccAccTurnoutBoard KEYWORD2
notifyDccAccTurnoutBoard notifyDccAccTurnoutOutput KEYWORD2
notifyDccAccTurnoutOutput notifyDccAccBoardAddrSet KEYWORD2
notifyDccSigState KEYWORD2 notifyDccAccOutputAddrSet KEYWORD2
notifyDccSigOutputState KEYWORD2
notifyDccMsg KEYWORD2 notifyDccMsg KEYWORD2
notifyCVValid KEYWORD2 notifyCVValid KEYWORD2
notifyCVRead KEYWORD2 notifyCVRead KEYWORD2
notifyCVWrite KEYWORD2 notifyCVWrite KEYWORD2
notifyIsSetCVReady KEYWORD2 notifyIsSetCVReady KEYWORD2
notifyCVChange KEYWORD2 notifyCVChange KEYWORD2
notifyCVAck KEYWORD2 notifyCVAck KEYWORD2
notifyCVResetFactoryDefault KEYWORD2 notifyCVResetFactoryDefault KEYWORD2
####################################### #######################################
# Constants (LITERAL1) # Constants (LITERAL1)
MAN_ID_JMRI LITERAL1 MAN_ID_JMRI LITERAL1
MAN_ID_DIY LITERAL1 MAN_ID_DIY LITERAL1
MAN_ID_SILICON_RAILWAY LITERAL1 MAN_ID_SILICON_RAILWAY LITERAL1
FLAGS_MY_ADDRESS_ONLY LITERAL1 FLAGS_MY_ADDRESS_ONLY LITERAL1
FLAGS_OUTPUT_ADDRESS_MODE LITERAL1 FLAGS_OUTPUT_ADDRESS_MODE LITERAL1
FLAGS_DCC_ACCESSORY_DECODER LITERAL1 FLAGS_DCC_ACCESSORY_DECODER LITERAL1
CV_ACCESSORY_DECODER_ADDRESS_LSB LITERAL1 CV_ACCESSORY_DECODER_ADDRESS_LSB LITERAL1
CV_ACCESSORY_DECODER_ADDRESS_MSB LITERAL1 CV_ACCESSORY_DECODER_ADDRESS_MSB LITERAL1
CV_MULTIFUNCTION_PRIMARY_ADDRESS LITERAL1 CV_MULTIFUNCTION_PRIMARY_ADDRESS LITERAL1
CV_MULTIFUNCTION_EXTENDED_ADDRESS_MSB LITERAL1 CV_MULTIFUNCTION_EXTENDED_ADDRESS_MSB LITERAL1
CV_MULTIFUNCTION_EXTENDED_ADDRESS_LSB LITERAL1 CV_MULTIFUNCTION_EXTENDED_ADDRESS_LSB LITERAL1
CV_VERSION_ID LITERAL1 CV_VERSION_ID LITERAL1
CV_MANUFACTURER_ID LITERAL1 CV_MANUFACTURER_ID LITERAL1
CV_29_CONFIG LITERAL1 CV_29_CONFIG LITERAL1
CV_OPS_MODE_ADDRESS_LSB LITERAL1 CV_OPS_MODE_ADDRESS_LSB LITERAL1
####################################### #######################################

View File

@@ -3,7 +3,7 @@ version=1.4.4
author=Alex Shepherd, Wolfgang Kuffer, Geoff Bunza, Martin Pischky, Franz-Peter Müller, Sven (littleyoda) author=Alex Shepherd, Wolfgang Kuffer, Geoff Bunza, Martin Pischky, Franz-Peter Müller, Sven (littleyoda)
maintainer=Alex Shepherd <kiwi64ajs@gmail.com> maintainer=Alex Shepherd <kiwi64ajs@gmail.com>
sentence=Enables NMRA DCC Communication sentence=Enables NMRA DCC Communication
paragraph=This library allows you to interface to a NMRA DCC track signal and receive DCC commands. The library currently supports the AVR ATTiny84/85 & ATMega88/168/328/32u4 and Teensy 3.x using the INT0/1 Hardware Interrupt and micros() ONLY and no longer uses Timer0 Compare Match B, which makes it much more portable to other platforms paragraph=This library allows you to interface to a NMRA DCC track signal and receive DCC commands. The library currently supports the AVR ATTiny84/85 & ATMega88/168/328/32u4 and Teensy 3.x using the INT0/1 Hardware Interrupt and micros() ONLY and no longer uses Timer0 Compare Match B, which makes it much more portable to other platforms. ALSO BEWARE as of version 1.4.4 support for the call-back functions notifyDccAccState() and notifyDccSigState() has been removed, please check and update your sketches, as they will silently fail.
category=Communication category=Communication
url=http://mrrwa.org/dcc-decoder-interface/ url=http://mrrwa.org/dcc-decoder-interface/
architectures=avr,esp8266,STM32F1 architectures=avr,esp8266,STM32F1