I got it to work.
Quick summary.
The Spektrum DX5e and possibly other entry level radios don't have
a
three way switch for mode selection.
The workaround is to combine two regular throw switches.
One will switch between MANUAL and AUTO
<define name="RADIO_MODE" value="RADIO_GEAR"/>
And the other one will, in case the MODE switch is on AUTO select
between the different AUTO MODES.
<define name="RADIO_AUTO_MODE" value="RADIO_AUX1"/>
This way CH 5 in position 1 means MANUAL.
With CH 5 in position 0 trainer in normal position means AUTO2
with
trainer switch pulled AUTO1.
It might obviously be convenient to replace the trainer switch
with a
bistable version.
As for the code. Thanks Gareth and Felix for the inspiration and
clarification.
I re-used the TRESHOLD (typo?) mechanism which divides the range
in
upper and lower quarters. I guess that makes still sense even
though
the divider probably lies somewhere between min and max. A switch
should be well in that range in either position.
Also, I did not put the _expression_ in a macro like
PPRZ_MODE_OF_PULSE(). I guess that is just not worth it.
I can document that in the wiki. If you are happy with it.
https://github.com/paparazzi/paparazzi/pull/216
|