mrrwa / NmraDcc

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

How to Use Curve (Speed Table) #71

Closed murarduino closed 1 year ago

murarduino commented 1 year ago

I want the multi-function decoder to support a 28-step speedometer, so I store 28 steps of speed values in CV67 to CV94, and set value 16 in CV29. I noticed that the void notifyDccSpeed() function is used to define a specific speedometer value. But there is no such setting in any of the examples, so I'm not sure about it. Is it understood like this:

void notifyDccSpeed(uint16_t Addr, DCC_ADDR_TYPE AddrType, uint8_t Speed, DCC_DIRECTION Dir, DCC_SPEED_STEPS SpeedSteps) { uint16_t aSpeedRef = 0;

if (Speed >= 1) { aSpeedRef = Dcc.getCV(67+Speed-1); } else {

ifdef DCC_DEBUG

Serial.println("***** Emagency STOP **** ");

endif

aSpeedRef = 0;

} .........

Another: I looked at a lot of documentation on CV29(Bit 4), and it was all about CV25. But I don't understand that CV25 is associated with the curve table. Please advise.

kiwi64ajs commented 1 year ago

You'll need to implement the speed table in your sketch as the notifyDccSpeed() function is just telling your sketch what the DCC Command Station is sending via the DCC Commands.

What your sketch does with the speed information is up to your coding as I personally don't want to go down that rat-hole... ;)