#Found code for custom variable but not sure what part

1 messages · Page 1 of 1 (latest)

crimson jewel
#

So, I have the full code and I am sure it is the right code but I dont know what segment of the code it is. If you are wondering the code is for a rotary encoder and I want it to control the speedmach knob.

crimson jewel
#

I am flying the f22 on msfs2020 I tried 1 (A:AUTOPILOT MACH HOLD VAR:1, mach) 0.01 l0 * + 100 * (>K:2:AP_MACH_VAR_SET) and 1 (A:AUTOPILOT AIRSPEED HOLD VAR:1, knots) 1 l0 * + 0 max (>K:2:AP_SPD_VAR_SET) but all I could do is the first one worked but it only worked one time and it would decrease

balmy coral
#

You need to learn the RPN syntax and functions

#

For example l0 is load value stored in register 0 to stack, but you can't load something if you didn't save it with p0 or s0 first.

#

In this case, the value being stored is +1 or -1 to be used as multiplier in the code to increase or decrease the value to be set.

#

You don't need the multiplier because you know which event (Inc or Dec) you are dealing with so you know which sign to use.

crimson jewel
#

thank you, could I have some more information?

balmy coral
#

For INC
(L:XMLVAR_AirSpeedIsInMach) if{ 1 (A:AUTOPILOT MACH HOLD VAR:1, mach) 0.01 + 100 * (>K:2:AP_MACH_VAR_SET) } els{ 1 (A:AUTOPILOT AIRSPEED HOLD VAR:1, knots) 1 + 0 max (>K:2:AP_SPD_VAR_SET) }

#

For DEC
(L:XMLVAR_AirSpeedIsInMach) if{ 1 (A:AUTOPILOT MACH HOLD VAR:1, mach) 0.01 - 100 * (>K:2:AP_MACH_VAR_SET) } els{ 1 (A:AUTOPILOT AIRSPEED HOLD VAR:1, knots) 1 - 0 max (>K:2:AP_SPD_VAR_SET) }

crimson jewel
#

It worked. Thank you!

balmy coral
#

But please note the only difference between the two events is just the + or - sign. That is what I meant by not needing the multiplier.