diff --git a/Aircraft/Instruments/KAP140TwoAxis.xml b/Aircraft/Instruments/KAP140TwoAxis.xml
new file mode 100644
index 000000000..75b7cfd24
--- /dev/null
+++ b/Aircraft/Instruments/KAP140TwoAxis.xml
@@ -0,0 +1,459 @@
+
+
+
+
+
+ KAP140TwoAxis
+ 512
+ 133
+
+
+
+
+
+
+ background
+
+ Aircraft/Instruments/Textures/KAP140.rgb
+ 0.0
+ 1.0
+ 0.265625
+ 0.529296875
+
+ 512
+ 133
+
+
+
+ AP Anunciator
+
+
+ /autopilot/KAP140/annunciators/ap
+ on
+
+
+
+ Aircraft/Instruments/Textures/KAP140.rgb
+ 0.32421875
+ 0.392578125
+ 0.802734375
+ 0.845703125
+
+ 35
+ 21
+
+
+ x-shift
+ -160
+
+
+ y-shift
+ 40
+
+
+
+
+
+ ROL Anunciator
+
+
+ /autopilot/KAP140/annunciators/rol
+ on
+
+
+
+ Aircraft/Instruments/Textures/KAP140.rgb
+ 0.0
+ 0.09765625
+ 0.802734375
+ 0.845703125
+
+ 50
+ 21
+
+
+ x-shift
+ -152
+
+
+ y-shift
+ 40
+
+
+
+
+
+ HDG Anunciator
+
+
+ /autopilot/KAP140/annunciators/hdg
+ on
+
+
+
+ Aircraft/Instruments/Textures/KAP140.rgb
+ 0.1015625
+ 0.205078125
+ 0.802734375
+ 0.845703125
+
+ 52
+ 21
+
+
+ x-shift
+ -150
+
+
+ y-shift
+ 40
+
+
+
+
+
+ NAV Anunciator
+
+
+ /autopilot/KAP140/annunciators/nav
+ on
+
+
+
+ Aircraft/Instruments/Textures/KAP140.rgb
+ 0.2109375
+ 0.31640625
+ 0.802734375
+ 0.845703125
+
+ 53
+ 21
+
+
+ x-shift
+ -150
+
+
+ y-shift
+ 40
+
+
+
+
+
+ NAV ARM Anunciator
+
+
+ /autopilot/KAP140/annunciators/nav-arm
+ on
+
+
+
+ Aircraft/Instruments/Textures/KAP140.rgb
+ 0.0
+ 0.12890625
+ 0.939453125
+ 1.0
+
+ 64
+ 30
+
+
+ x-shift
+ -145
+
+
+ y-shift
+ 15
+
+
+
+
+
+ APR Anunciator
+
+
+ /autopilot/KAP140/annunciators/apr
+ on
+
+
+
+ Aircraft/Instruments/Textures/KAP140.rgb
+ 0.32421875
+ 0.4296875
+ 0.802734375
+ 0.845703125
+
+ 53
+ 21
+
+
+ x-shift
+ -150
+
+
+ y-shift
+ 40
+
+
+
+
+
+ VS Anunciator
+
+
+ /autopilot/KAP140/annunciators/vs
+ on
+
+
+
+ Aircraft/Instruments/Textures/KAP140.rgb
+ 0.732421875
+ 0.787109375
+ 0.802734375
+ 0.845703125
+
+ 28
+ 21
+
+
+ x-shift
+ -47
+
+
+ y-shift
+ 40
+
+
+
+
+
+ FPM Anunciator
+
+
+ /autopilot/KAP140/annunciators/fpm
+ on
+
+
+
+ Aircraft/Instruments/Textures/KAP140.rgb
+ 0.91015625
+ 0.955078125
+ 0.978515625
+ 0.998046875
+
+ 23
+ 10
+
+
+ x-shift
+ 70
+
+
+ y-shift
+ 20
+
+
+
+
+
+ VS Number
+
+
+ /autopilot/KAP140/annunciators/vs-number
+ on
+
+
+ text
+ led
+ 11
+
+ 1.0
+ 0.5
+ 0.0
+
+
+
+ number-value
+ /autopilot/KAP140/settings/target-pressure-rate
+ -58000
+ %03.0f
+
+
+
+
+ x-shift
+ 50
+
+
+ y-shift
+ 30
+
+
+
+
+
+ ALT Anunciator
+
+
+ /autopilot/KAP140/annunciators/alt
+ on
+
+
+
+ Aircraft/Instruments/Textures/KAP140.rgb
+ 0.623046875
+ 0.724609375
+ 0.802734375
+ 0.845703125
+
+ 52
+ 21
+
+
+ x-shift
+ -60
+
+
+ y-shift
+ 40
+
+
+
+
+
+
+
+
+
+
+
+ AP Button
+
+ -239
+ -54
+ 30
+ 20
+
+ nasal
+
+
+
+
+
+ HDG Button
+
+ -149
+ -54
+ 30
+ 20
+
+ nasal
+
+
+
+
+
+ NAV Button
+
+ -90
+ -54
+ 30
+ 20
+
+ nasal
+
+
+
+
+
+ APR Button
+
+ -30
+ -54
+ 30
+ 20
+
+ nasal
+
+
+
+
+
+ ALT Button
+
+ 80
+ -54
+ 30
+ 20
+
+ nasal
+
+
+
+
+
+ DN Button
+
+ 128
+ -48
+ 30
+ 20
+
+ nasal
+
+
+
+
+
+ UP Button
+
+ 128
+ -8
+ 30
+ 20
+
+ nasal
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Aircraft/Instruments/Textures/KAP140.rgb b/Aircraft/Instruments/Textures/KAP140.rgb
new file mode 100644
index 000000000..86a21a778
Binary files /dev/null and b/Aircraft/Instruments/Textures/KAP140.rgb differ
diff --git a/Aircraft/c172p/Models/c172p-2d-panel.xml b/Aircraft/c172p/Models/c172p-2d-panel.xml
index cf08f57d4..fe7159b33 100644
--- a/Aircraft/c172p/Models/c172p-2d-panel.xml
+++ b/Aircraft/c172p/Models/c172p-2d-panel.xml
@@ -257,7 +257,7 @@ Legacy 2D instruments and actions for the 3D C172P cockpit.
DME
880
- 16
+ -50
+
+ KAP140 Autopilot
+ 880
+ 20
+ 256
+ 64
+
diff --git a/Aircraft/c172p/Systems/KAP140.xml b/Aircraft/c172p/Systems/KAP140.xml
new file mode 100644
index 000000000..5d35caa50
--- /dev/null
+++ b/Aircraft/c172p/Systems/KAP140.xml
@@ -0,0 +1,233 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Nav hold (NAV) Mode
+ false
+
+ /autopilot/KAP140/locks/nav-hold
+ nav
+
+
+ /radios/nav/heading-needle-deflection
+
+
+ 0.0
+
+
+
+ 7.0
+ 1.0
+ 0.1
+ 0.0
+
+ 10.0
+ 0.0 |
+ -45.0
+ 45.0
+
+
+
+
+
+ Approach hold (APR) Mode
+ true
+
+ /autopilot/KAP140/locks/apr-hold
+ apr
+
+
+ /radios/nav/heading-needle-deflection
+
+
+ 0.0
+
+
+
+ 7.0
+ 1.0
+ 0.1
+ 0.0
+
+ 10.0
+ 0.0 |
+ -45.0
+ 45.0
+
+
+
+
+
+
+ Heading Select (HDG) Mode
+ false
+
+ /autopilot/KAP140/locks/hdg-hold
+ hdg
+
+
+ /autopilot/internal/heading-bug-error-deg
+
+
+ /autopilot/KAP140/settings/target-intercept-angle
+
+
+
+ -0.05
+ 1.0
+ 0.1
+ 0.0
+
+ 15.0
+ 0.0 |
+ -0.9
+ 0.9
+
+
+
+
+
+
+ Wing Leveler (ROL) Mode
+ false
+
+ /autopilot/KAP140/locks/roll-axis
+ trn
+
+
+ /instrumentation/turn-indicator/indicated-turn-rate
+
+
+ /autopilot/KAP140/settings/target-turn-rate
+
+
+
+ 0.15
+ 1.0
+ 0.1
+ 0.0
+
+ 15.0
+ 0.0 |
+ -0.25
+ 0.25
+
+
+
+
+
+
+
+
+
+ Altitude Hold (ALT) Mode
+ false
+
+ /autopilot/KAP140/locks/alt-hold
+ alt
+
+
+ /systems/static[0]/pressure-inhg[0]
+
+
+ /autopilot/KAP140/settings/target-alt-pressure
+
+
+
+ 0.125
+ 1.0
+ 0.1
+ 0.0
+
+ 12.0
+ 0.0 |
+ -0.007
+ 0.007
+
+
+
+
+
+ Glideslope Hold (GS) Mode
+ true
+
+ /autopilot/KAP140/locks/gs-hold
+ gs
+
+
+ /radios/nav/gs-needle-deflection
+
+
+ 0.0
+
+
+
+ 0.025
+ 1.0
+ 0.1
+ 0.0
+
+ 15.0
+ 0.0 |
+ -0.001
+ 0.017
+
+
+
+
+
+ Vertical Speed (VS) Mode
+ false
+
+ /autopilot/KAP140/locks/pitch-axis
+ vs
+
+
+ /autopilot/internal/pressure-rate
+
+
+ /autopilot/KAP140/settings/target-pressure-rate
+
+
+
+ 5.0
+ 1.0
+ 0.1
+ 0.0
+
+ 4.0
+ 0.0 |
+ -0.5
+ 0.5
+
+
+
+
\ No newline at end of file
diff --git a/Aircraft/c172p/c172p-set.xml b/Aircraft/c172p/c172p-set.xml
index defba55b0..18941c37a 100644
--- a/Aircraft/c172p/c172p-set.xml
+++ b/Aircraft/c172p/c172p-set.xml
@@ -40,7 +40,7 @@ Started October 23 2001 by John Check, fgpanels@rockfish.net
- Aircraft/Generic/generic-autopilot.xml
+ Aircraft/c172p/Systems/KAP140.xml
Aircraft/c172/c172-electrical.xml
diff --git a/Nasal/kap140.nas b/Nasal/kap140.nas
new file mode 100644
index 000000000..88ee1fac7
--- /dev/null
+++ b/Nasal/kap140.nas
@@ -0,0 +1,489 @@
+##
+# Bendix/King KAP140 Two Axis Autopilot System
+##
+
+Locks = "/autopilot/KAP140/locks";
+Settings = "/autopilot/KAP140/settings";
+Annunciators = "/autopilot/KAP140/annunciators";
+Internal = "/autopilot/internal";
+
+annunciator = "";
+annunciator_state = "";
+flash_interval = 0.0;
+flash_count = 0.0;
+flash_timer = -1.0;
+
+
+
+flasher = func {
+ annunciator = arg[0];
+ flash_interval = arg[1];
+ flash_count = arg[2] + 1;
+ annunciator_state = arg[3];
+
+ flash_timer = 0.0;
+
+ flash_annunciator();
+}
+
+flash_annunciator = func {
+ #print(annunciator);
+ #print(flash_interval);
+ #print(flash_count);
+
+ ##
+ # If flash_timer is set to -1 then flashing is aborted
+ if (flash_timer < -0.5)
+ {
+ setprop(Annunciators, annunciator, "off");
+ return;
+ }
+
+ if (flash_timer < flash_count)
+ {
+ #flash_timer = flash_timer + 1.0;
+ if (getprop(Annunciators, annunciator) == "on")
+ {
+ setprop(Annunciators, annunciator, "off");
+ settimer(flash_annunciator, flash_interval / 2.0);
+ }
+ else
+ #elsif (getprop(Annunciators, annunciator) == "off")
+ {
+ flash_timer = flash_timer + 1.0;
+ setprop(Annunciators, annunciator, "on");
+ settimer(flash_annunciator, flash_interval);
+ }
+ }
+ else
+ {
+ flash_timer = -1.0;
+ setprop(Annunciators, annunciator, annunciator_state);
+ }
+}
+
+ap_button = func {
+ #print("ap_button");
+
+ ##
+ # Engages the autopilot in Wings level mode (ROL) and Vertical speed hold
+ # mode (VS).
+ ##
+ if (getprop(Locks, "roll-mode") == "off" and
+ getprop(Locks, "pitch-mode") == "off")
+ {
+ flash_timer = -1.0;
+
+ setprop(Locks, "alt-hold", "off");
+ setprop(Locks, "apr-hold", "off");
+ setprop(Locks, "gs-hold", "off");
+ setprop(Locks, "hdg-hold", "off");
+ setprop(Locks, "nav-hold", "off");
+ setprop(Locks, "roll-axis", "trn");
+ setprop(Locks, "roll-mode", "rol");
+ setprop(Locks, "pitch-axis", "vs");
+ setprop(Locks, "pitch-mode", "vs");
+
+ setprop(Annunciators, "rol", "on");
+ setprop(Annunciators, "vs", "on");
+ setprop(Annunciators, "fpm", "on");
+ setprop(Annunciators, "vs-number", "on");
+
+ setprop(Settings, "target-turn-rate", 0.0);
+ setprop(Settings, "target-pressure-rate", getprop(Internal,
+ "pressure-rate"));
+ }
+ ##
+ # Disengages all modes.
+ ##
+ elsif (getprop(Locks, "roll-mode") != "off" and
+ getprop(Locks, "pitch-mode") != "off")
+ {
+ flash_timer = -1.0;
+
+ setprop(Locks, "alt-hold", "off");
+ setprop(Locks, "apr-hold", "off");
+ setprop(Locks, "gs-hold", "off");
+ setprop(Locks, "hdg-hold", "off");
+ setprop(Locks, "nav-hold", "off");
+ setprop(Locks, "roll-axis", "off");
+ setprop(Locks, "roll-mode", "off");
+ setprop(Locks, "pitch-axis", "off");
+ setprop(Locks, "pitch-mode", "off");
+
+ setprop(Settings, "target-alt-pressure", 0.0);
+ setprop(Settings, "target-intercept-angle", 0.0);
+ setprop(Settings, "target-pressure-rate", 0.0);
+ setprop(Settings, "target-turn-rate", 0.0);
+
+ setprop(Annunciators, "rol", "off");
+ setprop(Annunciators, "hdg", "off");
+ setprop(Annunciators, "nav", "off");
+ setprop(Annunciators, "nav-arm", "off");
+ setprop(Annunciators, "vs", "off");
+ setprop(Annunciators, "vs-number", "off");
+ setprop(Annunciators, "fpm", "off");
+ setprop(Annunciators, "alt", "off");
+ setprop(Annunciators, "apr", "off");
+ setprop(Annunciators, "gs", "off");
+
+ flasher("ap", 1.0, 5, "off");
+
+ setprop(Internal, "ft", 0.1);
+ }
+}
+
+
+hdg_button = func {
+ #print("hdg_button");
+
+ ##
+ # Engages the heading mode (HDG) and vertical speed hold mode (VS). The
+ # commanded vertical speed is set to the vertical speed present at button
+ # press.
+ ##
+ if (getprop(Locks, "roll-mode") == "off" and
+ getprop(Locks, "pitch-mode") == "off")
+ {
+ setprop(Locks, "alt-hold", "off");
+ setprop(Locks, "apr-hold", "off");
+ setprop(Locks, "gs-hold", "off");
+ setprop(Locks, "hdg-hold", "hdg");
+ setprop(Locks, "nav-hold", "off");
+ setprop(Locks, "roll-axis", "trn");
+ setprop(Locks, "roll-mode", "hdg");
+ setprop(Locks, "pitch-axis", "vs");
+ setprop(Locks, "pitch-mode", "vs");
+
+ setprop(Annunciators, "hdg", "on");
+ setprop(Annunciators, "alt", "off");
+ setprop(Annunciators, "apr", "off");
+ setprop(Annunciators, "gs", "off");
+ setprop(Annunciators, "nav", "off");
+ setprop(Annunciators, "vs", "on");
+ setprop(Annunciators, "vs-number", "on");
+ setprop(Annunciators, "fpm", "on");
+
+ setprop(Settings, "target-intercept-angle", 0.0);
+ setprop(Settings, "target-pressure-rate", getprop(Internal,
+ "pressure-rate"));
+ }
+ ##
+ # Switch to HDG mode, but don't change pitch mode.
+ ##
+ elsif (getprop(Locks, "roll-mode") == "rol" or
+ getprop(Locks, "roll-mode") == "nav" or
+ getprop(Locks, "roll-mode") == "nav-arm" or
+ getprop(Locks, "roll-mode") == "rev")
+ {
+ #setprop(Locks, "alt-hold", "off");
+ setprop(Locks, "apr-hold", "off");
+ setprop(Locks, "gs-hold", "off");
+ setprop(Locks, "hdg-hold", "hdg");
+ setprop(Locks, "nav-hold", "off");
+ setprop(Locks, "roll-axis", "trn");
+ setprop(Locks, "roll-mode", "hdg");
+ #setprop(Locks, "pitch-axis", "off");
+ #setprop(Locks, "pitch-mode", "off");
+
+ setprop(Annunciators, "apr", "off");
+ setprop(Annunciators, "gs", "off");
+ setprop(Annunciators, "hdg", "on");
+ setprop(Annunciators, "nav", "off");
+ setprop(Annunciators, "rol", "off");
+
+ setprop(Settings, "target-intercept-angle", 0.0);
+ }
+ ##
+ # If we already are in HDG mode switch to ROL mode. Again don't touch pitch
+ # mode.
+ ##
+ elsif (getprop(Locks, "roll-mode") == "hdg")
+ {
+ #setprop(Locks, "alt-hold", "off");
+ setprop(Locks, "apr-hold", "off");
+ setprop(Locks, "gs-hold", "off");
+ setprop(Locks, "hdg-hold", "off");
+ setprop(Locks, "nav-hold", "off");
+ setprop(Locks, "roll-axis", "trn");
+ setprop(Locks, "roll-mode", "rol");
+ #setprop(Locks, "pitch-axis", "off");
+ #setprop(Locks, "pitch-mode", "off");
+
+ setprop(Annunciators, "apr", "off");
+ setprop(Annunciators, "gs", "off");
+ setprop(Annunciators, "hdg", "off");
+ setprop(Annunciators, "nav", "off");
+ setprop(Annunciators, "rol", "on");
+
+ setprop(Settings, "target-turn-rate", 0.0);
+ }
+ ##
+ # If we are in APR mode we also have to change pitch mode.
+ # TODO: Should we switch to VS or ALT mode? (currently VS)
+ ##
+ elsif (getprop(Locks, "roll-mode") == "apr" and
+ getprop(Locks, "pitch-mode") == "gs")
+ {
+ setprop(Locks, "alt-hold", "off");
+ setprop(Locks, "apr-hold", "off");
+ setprop(Locks, "gs-hold", "off");
+ setprop(Locks, "hdg-hold", "hdg");
+ setprop(Locks, "nav-hold", "off");
+ setprop(Locks, "roll-axis", "trn");
+ setprop(Locks, "roll-mode", "hdg");
+ setprop(Locks, "pitch-axis", "vs");
+ setprop(Locks, "pitch-mode", "vs");
+
+ setprop(Annunciators, "alt", "off");
+ setprop(Annunciators, "apr", "off");
+ setprop(Annunciators, "gs", "off");
+ setprop(Annunciators, "hdg", "on");
+ setprop(Annunciators, "nav", "off");
+ setprop(Annunciators, "vs", "on");
+ setprop(Annunciators, "vs-number", "on");
+ setprop(Annunciators, "fpm", "on");
+
+ setprop(Settings, "target-intercept-angle", 0.0);
+ setprop(Settings, "target-pressure-rate", getprop(Internal,
+ "pressure-rate"));
+ }
+}
+
+
+nav_button = func {
+ #print("nav_button");
+ if (getprop(Locks, "roll-mode") == "hdg")
+ {
+ flasher("hdg", 0.5, 8, "off");
+
+ setprop(Locks, "apr-hold", "off");
+ setprop(Locks, "gs-hold", "off");
+ setprop(Locks, "hdg-hold", "hdg");
+ setprop(Locks, "nav-hold", "off");
+ setprop(Locks, "roll-axis", "trn");
+ setprop(Locks, "roll-mode", "nav-arm");
+
+ nav_arm_from_hdg();
+ }
+ elsif (getprop(Locks, "roll-mode") == "rol")
+ {
+ flasher("hdg", 0.5, 8, "off");
+
+ setprop(Locks, "apr-hold", "off");
+ setprop(Locks, "gs-hold", "off");
+ setprop(Locks, "hdg-hold", "off");
+ setprop(Locks, "nav-hold", "off");
+ setprop(Locks, "roll-axis", "trn");
+ setprop(Locks, "roll-mode", "nav-arm");
+
+ nav_arm_from_rol();
+ }
+ elsif (getprop(Locks, "roll-mode") == "apr" and
+ getprop(Locks, "pitch-mode") == "gs")
+ {
+ setprop(Locks, "alt-hold", "off");
+ setprop(Locks, "apr-hold", "off");
+ setprop(Locks, "gs-hold", "off");
+ setprop(Locks, "hdg-hold", "hdg");
+ setprop(Locks, "nav-hold", "nav");
+ setprop(Locks, "roll-axis", "trn");
+ setprop(Locks, "roll-mode", "nav");
+ setprop(Locks, "pitch-axis", "vs");
+ setprop(Locks, "pitch-mode", "vs");
+
+ setprop(Settings, "target-pressure-rate", getprop(Internal,
+ "pressure-rate"));
+ }
+}
+
+nav_arm_from_hdg = func
+{
+ if (getprop(Locks, "roll-mode") != "nav-arm")
+ {
+ setprop(Annunciators, "nav-arm", "off");
+ return;
+ }
+
+ setprop(Annunciators, "nav-arm", "on");
+ if (flash_timer > -0.5)
+ {
+ print("flashing...");
+ settimer(nav_arm_from_hdg, 2.5);
+ return;
+ }
+
+ setprop(Locks, "nav-hold", "nav");
+ deviation = getprop("/radios/nav/heading-needle-deflection");
+ if (abs(deviation) > 3.0)
+ {
+ print("deviation");
+ settimer(nav_arm_from_hdg, 5);
+ return;
+ }
+ elsif (abs(deviation) < 3.1)
+ {
+ print("capture");
+ setprop(Annunciators, "nav-arm", "off");
+ setprop(Annunciators, "nav", "on");
+ }
+}
+
+nav_arm_from_rol = func
+{
+ if (getprop(Locks, "roll-mode") != "nav-arm")
+ {
+ setprop(Annunciators, "nav-arm", "off");
+ return;
+ }
+
+ setprop(Annunciators, "nav-arm", "on");
+ if (flash_timer > -0.5)
+ {
+ print("flashing...");
+ setprop(Annunciators, "rol", "off");
+ settimer(nav_arm_from_rol, 2.5);
+ return;
+ }
+
+ setprop(Annunciators, "rol", "on");
+ setprop(Locks, "roll-axis", "trn");
+ setprop(Settings, "target-turn-rate", 0.0);
+ deviation = getprop("/radios/nav/heading-needle-deflection");
+ if (abs(deviation) > 3.0)
+ {
+ print("deviation");
+ settimer(nav_arm_from_rol, 5);
+ return;
+ }
+ elsif (abs(deviation) < 3.1)
+ {
+ print("capture");
+ setprop(Annunciators, "rol", "off");
+ setprop(Annunciators, "nav-arm", "off");
+ setprop(Annunciators, "nav", "on");
+
+ setprop(Locks, "apr-hold", "off");
+ setprop(Locks, "gs-hold", "off");
+ setprop(Locks, "hdg-hold", "hdg");
+ setprop(Locks, "nav-hold", "nav");
+ setprop(Locks, "roll-axis", "trn");
+ setprop(Locks, "roll-mode", "nav");
+ }
+}
+
+apr_button = func {
+ #print("apr_button");
+ if (getprop(Locks, "roll-mode") == "hdg" or
+ getprop(Locks, "roll-mode") == "rol" or
+ getprop(Locks, "roll-mode") == "rev" or
+ #getprop(Locks, "roll-mode") == "apr" or
+ getprop(Locks, "pitch-mode") == "nav")
+ {
+ setprop(Locks, "alt-hold", "off");
+ setprop(Locks, "apr-hold", "apr");
+ setprop(Locks, "gs-hold", "gs");
+ setprop(Locks, "hdg-hold", "off");
+ setprop(Locks, "nav-hold", "off");
+ setprop(Locks, "roll-axis", "trn");
+ setprop(Locks, "roll-mode", "apr");
+ setprop(Locks, "pitch-axis", "vs");
+ setprop(Locks, "pitch-mode", "gs");
+ }
+ elsif (getprop(Locks, "roll-mode") == "apr" and
+ getprop(Locks, "pitch-mode") == "gs")
+ {
+ setprop(Locks, "alt-hold", "off");
+ setprop(Locks, "apr-hold", "off");
+ setprop(Locks, "gs-hold", "off");
+ setprop(Locks, "hdg-hold", "hdg");
+ setprop(Locks, "nav-hold", "nav");
+ setprop(Locks, "roll-axis", "trn");
+ setprop(Locks, "roll-mode", "nav");
+ setprop(Locks, "pitch-axis", "vs");
+ setprop(Locks, "pitch-mode", "vs");
+
+ setprop(Settings, "target-pressure-rate", getprop(Internal,
+ "pressure-rate"));
+ }
+}
+
+
+alt_button = func {
+ #print("alt_button");
+ if (getprop(Locks, "pitch-mode") == "alt")
+ {
+ setprop(Locks, "alt-hold", "off");
+ #setprop(Locks, "apr-hold", "apr");
+ #setprop(Locks, "gs-hold", "gs");
+ #setprop(Locks, "hdg-hold", "off");
+ #setprop(Locks, "nav-hold", "off");
+ #setprop(Locks, "roll-axis", "trn");
+ #setprop(Locks, "roll-mode", "apr");
+ setprop(Locks, "pitch-axis", "vs");
+ setprop(Locks, "pitch-mode", "vs");
+
+ setprop(Annunciators, "alt", "off");
+ setprop(Annunciators, "vs", "on");
+ setprop(Annunciators, "vs-number", "on");
+ setprop(Annunciators, "fpm", "on");
+
+ setprop(Settings, "target-pressure-rate", getprop(Internal,
+ "pressure-rate"));
+ }
+ elsif (getprop(Locks, "pitch-mode") == "vs")
+ {
+ setprop(Locks, "alt-hold", "alt");
+ #setprop(Locks, "apr-hold", "off");
+ #setprop(Locks, "gs-hold", "off");
+ #setprop(Locks, "hdg-hold", "hdg");
+ #setprop(Locks, "nav-hold", "nav");
+ #setprop(Locks, "roll-axis", "trn");
+ #setprop(Locks, "roll-mode", "nav");
+ setprop(Locks, "pitch-axis", "vs");
+ setprop(Locks, "pitch-mode", "alt");
+
+ setprop(Annunciators, "alt", "on");
+ setprop(Annunciators, "vs", "off");
+ setprop(Annunciators, "vs-number", "off");
+ setprop(Annunciators, "fpm", "off");
+
+
+ setprop(Settings, "target-alt-pressure",
+ getprop("/systems/static/pressure-inhg"));
+ }
+}
+
+
+dn_button = func {
+ #print("dn_button");
+ if (getprop(Locks, "pitch-mode") == "vs")
+ {
+ Target_VS = getprop(Settings, "target-pressure-rate");
+ setprop(Settings, "target-pressure-rate", Target_VS +
+ 0.0017241379310345);
+ }
+ elsif (getprop(Locks, "pitch-mode") == "alt")
+ {
+ Target_Pressure = getprop(Settings, "target-alt-pressure");
+ setprop(Settings, "target-alt-pressure", Target_Pressure + 0.0206);
+ }
+}
+
+
+up_button = func {
+ #print("up_button");
+ if (getprop(Locks, "pitch-mode") == "vs")
+ {
+ Target_VS = getprop(Settings, "target-pressure-rate");
+ setprop(Settings, "target-pressure-rate", Target_VS -
+ 0.0017241379310345);
+ }
+ elsif (getprop(Locks, "pitch-mode") == "alt")
+ {
+ Target_Pressure = getprop(Settings, "target-alt-pressure");
+ setprop(Settings, "target-alt-pressure", Target_Pressure - 0.0206);
+ }
+}
+
+ap_button();