KAP150 Autopilot KAS297B Altitude and Vertical Speed Targets

Questions about deployment and use of Air Manager Instruments

Moderators: russ, Ralph

Message
Author
AnthonySullivan
Posts: 91
Joined: Wed Jul 01, 2020 8:06 am

KAP150 Autopilot KAS297B Altitude and Vertical Speed Targets

#1 Post by AnthonySullivan »

Gentlemen,
I seek your kind assistance once again.
I am building a KAS297B for the KAP150 Autopilot as used in the Mooney Ovation M20
According to the Bendix King information, It is an optional instrument which allows the pilot to set target altitudes and vertical speeds for the autopilot to reach.
I have found the Datarefs:
xpl_dataref_subscribe("sim/cockpit/autopilot/vertical_velocity","FLOAT",VerticalSpeed_Callback) for vertical speed
and
xpl_dataref_subscribe("sim/cockpit/autopilot/altitude","FLOAT",Altitude_Callback) for Altitude
They show up on my instrument when they are changed in X-Plane.
I now want the knob on the instrument to change modes between altitude and vertical speed when it is clicked, but, search as I may, I cannot find the relevant dataref to record this change in mode.
Could you tell me what is the correct dataref to change the display between altitude and vertical speed?
Many thanks in advance as usual.
best wishes
Anthony Sullivan


User avatar
Sling
Posts: 5244
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: KAP150 Autopilot KAS297B Altitude and Vertical Speed Targets

#3 Post by Sling »

You can also write directly to the dataref "sim/cockpit/autopilot/autopilot_state" but that takes more complex code to get right and can be a pain. :?

AnthonySullivan
Posts: 91
Joined: Wed Jul 01, 2020 8:06 am

Re: KAP150 Autopilot KAS297B Altitude and Vertical Speed Targets

#4 Post by AnthonySullivan »

Dear Sling and Ralph,

Thanks for your advice. I have not explored commands yet but obviously need to do so.

One further issue which has me beaten is recording the inner knob being pushed on the Knobster.
I have looked at the script behind the GNS530 and that appears to use a button with no image:

function click_cv()
if g_manf == 1 then
if g_unit==1 then xpl_command( "sim/GPS/g430n1_nav_com_tog" ) elseif g_unit == 2 then xpl_command( "sim/GPS/g430n2_nav_com_tog") end
else
xpl_command("RXP/GNS/COM_PUSH")
end
sound_play(click_snd)
end

button_add( nil,nil, 58,507,30,30, click_cv)

but when I try that I get no response. I just have some simple code in the function to check if it is working or not.
Could you confirm for me the correct script for dealing with a press of the inner knob on the Knobster please?

Many thanks as always
Yours sincerely
Anthony Sullivan

User avatar
Sling
Posts: 5244
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: KAP150 Autopilot KAS297B Altitude and Vertical Speed Targets

#5 Post by Sling »

Hi Anthony,

For the knobster inner button to work you must co-locate the button with the corresponding knob. If you study the 530 code you will see the button is located directly on top of the knobs but small enough for the knobs to still function. Remember when coding for these it has to work for mouse and touch as the first thing. It will automatically work for knobster if it works for these.

Tony

AnthonySullivan
Posts: 91
Joined: Wed Jul 01, 2020 8:06 am

Re: KAP150 Autopilot KAS297B Altitude and Vertical Speed Targets

#6 Post by AnthonySullivan »

Dear Tony,

Thanks for your prompt response.
I think I have the button co-located. I am using:
AltitudeVerticalSpeedRev B.siff
(28.07 KiB) Downloaded 190 times
button_id = button_add("Knob.png", "",374,71,84,84,callback_pressed)
dial_id = dial_add("Knob.png",374,71,84,84,1,dial_callback)
However I now have a really strange phenomenon.
I have put simple print statements into the functions to test them.
If I run the instrument to test it, the code works fine.
If I add the instrument to a panel then the code does not work, no print statements appear in the console.
However if I set the panel for Knobster that is fine and I can turn the dial with the Knobster but still no print statements appear.
This difference between testing an instrument on its own and trying it out in a panel has me completely stumped.
Is there any setting in panel that could affect how an instrument behaves?

One further question is that in your answer, you mentioned that the button has to be small enough for the knobs to still function. How much smaller should the button be than the dial for this to work? I currently have them both at the same size (84,84).

Many thanks in advance as ever.
Anthony

SimPassion
Posts: 5346
Joined: Thu Jul 27, 2017 12:22 am

Re: KAP150 Autopilot KAS297B Altitude and Vertical Speed Targets

#7 Post by SimPassion »

AnthonySullivan wrote: Tue Aug 25, 2020 9:50 am Dear Tony,

Thanks for your prompt response.
I think I have the button co-located. I am using:
AltitudeVerticalSpeedRev B.siff button_id = button_add("Knob.png", "",374,71,84,84,callback_pressed)
dial_id = dial_add("Knob.png",374,71,84,84,1,dial_callback)
However I now have a really strange phenomenon.
I have put simple print statements into the functions to test them.
If I run the instrument to test it, the code works fine.
If I add the instrument to a panel then the code does not work, no print statements appear in the console.
However if I set the panel for Knobster that is fine and I can turn the dial with the Knobster but still no print statements appear.
This difference between testing an instrument on its own and trying it out in a panel has me completely stumped.
Is there any setting in panel that could affect how an instrument behaves?

One further question is that in your answer, you mentioned that the button has to be small enough for the knobs to still function. How much smaller should the button be than the dial for this to work? I currently have them both at the same size (84,84).

Many thanks in advance as ever.
Anthony

The panel behavior is still the same from a long time now, no print result displayed in the console from it, as per design

The space between button and inner knob should be enough to be reach using mouse or touch, try with lowering by 5 or 10

Gilles

User avatar
Ralph
Posts: 7933
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: KAP150 Autopilot KAS297B Altitude and Vertical Speed Targets

#8 Post by Ralph »

Like Gilles said, don't make them the same size. You will still need to be able to select the dial.

User avatar
Sling
Posts: 5244
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: KAP150 Autopilot KAS297B Altitude and Vertical Speed Targets

#9 Post by Sling »

Yep as the guys say the button needs to be smaller than the dial. For your application I would try

Code: Select all

button_add(nil,nil,389,86,54,54,callback_pressed)
Last edited by Sling on Wed Aug 26, 2020 10:18 am, edited 1 time in total.

AnthonySullivan
Posts: 91
Joined: Wed Jul 01, 2020 8:06 am

Re: KAP150 Autopilot KAS297B Altitude and Vertical Speed Targets

#10 Post by AnthonySullivan »

Gentlemen,
As always many thanks for your advice.
One key issue I discovered by trial and error taking several hours, is the importance of the sequence of the code.
As shown in the GPS530 code, the function for the dial should come first and the function for the button second.
If you do it the other way around the button does not work.
It seems that Lua displays the larger knobs first and then the smaller button on top.
If the code is reversed then the larger knob is on top and obscures the button. Something like that.
One more mountain climbed!
sincerely
Anthony Sullivan

Post Reply