Most of my locomotives have all their functions in the range, F0 to F8 but one loco, the Baden IV, has a short whistle sound (which I call 'Toot') on F3 of a secondary decoder address. My software did not support secondary decoder addresses so I have now added that facility. While I was busy with that feature I decided to also solve the issue of different sounds and functions being activated in different manners.
The classic example of how functions demand different types of activation is the switching on and off of the acceleration feature in some decoders. Some decoders present the function as something to be switched on (i.e. switch the acceleration feature on), others present it as a feature to switch off (i.e. suppress acceleration). So some locos have to have the function switched on, others need it switched off to achieve the same effect! Some of these decoders do not have the capability to have the behavior reversed either.
To get around this problem, I previously defined two different type of function:
- Acceleration ON
- Acceleration OFF
In addition, some functions are activated any time the decoder function is switched on, but others will activate if there is any change in the function status, from on to off or off to on!
A further, even worse example turned up. The previously mentioned "Toot" sound on my nice Baden IV locomotive can only be activated when F3 is switched from 'off' to 'on'. If the software sends a command to switch F3 on, and F3 is already on, nothing happens. (They assumed a non-latching button would be used to activate it, ignoring software control.) To reliably activate that function, I have to ensure it is off first, then switch it on.
So I decided to enhance my function definitions to allow every function to also have it's invocation defined, - how does it get switched on? I came up with the following possibilities:
- Switch from Off to On
- Switch from On to Off
|User interface design Copyright Dale Schultz, 2018|
This allows me to indicate if 'acceleration' is enabled by switching the function on, or, as in the example above, off. It also allows me to define a sound effect that is activated with any change to the function (F3 above) or a move from off to on (F2 in the example).
Implementation was complex, I found for example that simply sending F3-OFF, F3-ON commands to the Intellibox does not give the loco decoder time to actually go off, before it it switched on again. I have to send the initial command to switch the function off and then a second later, send the followup command to switch it on again. My software has no wait states (delay loops) so I had to place the second command into a queue to be sent out later in cases where I find the function is already on.
Given these new enhancements, whenever a train is about to start off in a visible area, it will give a 'toot' and a 'hiss', if those capabilities are present by any locos in the train. It works reliably no matter what state the decoder is in.
I have also simplified the track definitions that switch acceleration functionality, to use a single type of function, and the software now knows how to switch it correctly for the various locomotives.