mrrwa / NmraDcc

NMRA Digital Command Control (DCC) Library
GNU Lesser General Public License v2.1
135 stars 53 forks source link

More than one locomotive / function decoder address #42

Closed ajoreis closed 3 years ago

ajoreis commented 4 years ago

Hallo,, is there a possibility that you can use more than one locomotive address. e.g. Address 100 is configured, the second address is then address 101 and possibly a third one with address 102 etc.

Thanks for your Info.

Olaf

MicroBahner commented 4 years ago

Hi Olaf, if you don't use the flag 'FLAGS_MY_ADDRESS_ONLY' you get a callback at every received address. You can than select the wanted addresses by yourself. Regards Franz-Peter

ajoreis commented 4 years ago

Hi Franz-Peter, Ok if I see that correctly this is the init string: Dcc.init (MAN_ID_DIY, 100, FLAGS_MY_ADDRESS_ONLY, 1); then what can I use as a variable? or can add a second by adding this variable with 1 e.g. FLAGS_MY_ADDRESS_ONLY2 = (FLAGS_MY_ADDRESS_ONLY + 1)

I use this function: void notifyDccFunc (uint16_t Addr, DCC_ADDR_TYPE AddrType, FN_GROUP FuncGrp, uint8_t FuncState) Which variable is the decoder address here?

christianloesel commented 4 years ago

The FLAGS_MY_ADDRESS_ONLY ist used to raise the callbacks only when your declared address is called.

If you leave it, they will always be called and you can filter the „Addr“ parameter in the callbacks.

Greetings Chris

Ps: the callbacks are: notifyDccSpeed and notifyDccFunc

MicroBahner commented 4 years ago

Hi, the decoder address is coded in CV values, not in the init flags. The flag FLAGS_MY_ADDRESS_ONLY means the lib compares the received address to the addres in the CV and the notifyDccFunc is only called if this matches. If you don't set this flag, this comparison is not done and the notifyDccFunc is called with every address. You have to compare the addresses in your sketch. Thi init command must look like this: Dcc.init( MAN_ID_DIY, 100, 0, 0 );

It's just as it Chris wrote ;)

kiwi64ajs commented 4 years ago

Hi Olaf,

On 17/06/2020, at 8:29 PM, ajoreis notifications@github.com wrote: Hi Franz-Peter, Ok if I see that correctly this is the init string: Dcc.init (MAN_ID_DIY, 100, FLAGS_MY_ADDRESS_ONLY, 1); then what can I use as a variable? or can add a second by adding this variable with 1 e.g. FLAGS_MY_ADDRESS_ONLY2 = (FLAGS_MY_ADDRESS_ONLY + 1)

No, the FLAGS_MY_ADDRESS_ONLY flag enables a filter that compares the address in all DCC Packets to the DCC address stored in the EEPROM Address CVs as per CV29. If the address matches you call-back will be called.

If you omit the FLAGS_MY_ADDRESS_ONLY flag like:

Dcc.init (MAN_ID_DIY, 100, 0, 0);

Then the call-back functions will get called for any packet of the appropriate type for all/any addresses. There will not be any address filtering.

I use this function: void notifyDccFunc (uint16_t Addr, DCC_ADDR_TYPE AddrType, FN_GROUP FuncGrp, uint8_t FuncState) Which variable is the decoder address here?

The address will be in the Addr (1..9999) parameter and the type of address will be in the AddrType (DCC_ADDR_SHORT or DCC_ADDR_LONG) parameter.

HTH

Alex Shepherd

ajoreis commented 4 years ago

Hello Alex Thank you for your info, I've tried a few things, but unfortunately I can't get it. I just send you my little sketch, in this sketch I create a small sound decoder for a train station, because I am restricted to 29 with the functions and I have enough space on the memory stick, I would like to play more than only 29 sounds. that's why I considered using several consecutive Loc addresses. Its functions are then assigned to the sound file. NmraDccMultiFunctionDecoder_2_MP3.zip

MicroBahner commented 4 years ago

Hi Olaf, you still use the 'FLAGS_MY_ADDRESS_ONLY' Flag when initializing the lib. You must not do that, if you want to use more than one address. You must initialize with Dcc.init( MAN_ID_DIY, 100, 0, 1); You have to check the addresses by yourself in the notifyDccFunc() function.

regards Franz-Peter

N.B. If this is not really a locomotive, but a stationary decoder for a train station you should consider using the extended accessory decoder packets ( if your command station supports this ). This is mainly for light signals with many signal aspects, but could also be a good solution for your needs.

kiwi64ajs commented 3 years ago

Has this issue/request been resolved?