diff --git a/A320-main.xml b/A320-main.xml index 22a4c231..e646cdb0 100644 --- a/A320-main.xml +++ b/A320-main.xml @@ -239,7 +239,7 @@ -0.30 0.30 - -0.05 + -0.04 10.0 0.0001 -0.07 @@ -250,7 +250,7 @@ 0.025 0.07 0.30 - -0.35 + -0.60 0.10 diff --git a/Nasal/it-autoflight.nas b/Nasal/it-autoflight.nas index 891161c1..03b04754 100644 --- a/Nasal/it-autoflight.nas +++ b/Nasal/it-autoflight.nas @@ -1,5 +1,5 @@ # IT AUTOFLIGHT System Controller by Joshua Davidson (it0uchpods/411). -# V3.0.0 Build 127 +# V3.0.0 Build 130 # This program is 100% GPL! print("IT-AUTOFLIGHT: Please Wait!"); @@ -161,19 +161,23 @@ var lateral = func { if (latset == 0) { alandt.stop(); alandt1.stop(); + lnavwptt.stop(); setprop("/it-autoflight/output/loc-armed", 0); setprop("/it-autoflight/output/appr-armed", 0); setprop("/it-autoflight/output/lat", 0); setprop("/it-autoflight/mode/lat", "HDG"); setprop("/it-autoflight/mode/arm", " "); } else if (latset == 1) { - alandt.stop(); - alandt1.stop(); - setprop("/it-autoflight/output/loc-armed", 0); - setprop("/it-autoflight/output/appr-armed", 0); - setprop("/it-autoflight/output/lat", 1); - setprop("/it-autoflight/mode/lat", "LNAV"); - setprop("/it-autoflight/mode/arm", " "); + if (getprop("/autopilot/route-manager/route/num") > 0) { + alandt.stop(); + alandt1.stop(); + lnavwptt.start(); + setprop("/it-autoflight/output/loc-armed", 0); + setprop("/it-autoflight/output/appr-armed", 0); + setprop("/it-autoflight/output/lat", 1); + setprop("/it-autoflight/mode/lat", "LNAV"); + setprop("/it-autoflight/mode/arm", " "); + } } else if (latset == 2) { setprop("/instrumentation/nav/signal-quality-norm", 0); setprop("/it-autoflight/output/loc-armed", 1); @@ -182,6 +186,7 @@ var lateral = func { } else if (latset == 3) { alandt.stop(); alandt1.stop(); + lnavwptt.stop(); setprop("/it-autoflight/output/loc-armed", 0); setprop("/it-autoflight/output/appr-armed", 0); var hdgnow = int(getprop("/orientation/heading-magnetic-deg")+0.5); @@ -190,9 +195,11 @@ var lateral = func { setprop("/it-autoflight/mode/lat", "HDG"); setprop("/it-autoflight/mode/arm", " "); } else if (latset == 4) { + lnavwptt.stop(); setprop("/it-autoflight/output/lat", 4); setprop("/it-autoflight/mode/lat", "ALGN"); } else if (latset == 5) { + lnavwptt.stop(); setprop("/it-autoflight/output/lat", 5); } } @@ -340,6 +347,18 @@ var vertical = func { } } +# Helpers +var lnavwpt = func { + if (getprop("/autopilot/route-manager/route/num") > 0) { + if (getprop("/autopilot/route-manager/wp/dist") <= 1.0) { + var wptnum = getprop("/autopilot/route-manager/current-wp"); + if ((wptnum + 1) < getprop("/autopilot/route-manager/route/num")) { + setprop("/autopilot/route-manager/current-wp", wptnum + 1); + } + } + } +} + var flch_on = func { setprop("/it-autoflight/output/appr-armed", 0); setprop("/it-autoflight/output/vert", 4); @@ -376,6 +395,14 @@ setlistener("/it-autoflight/input/kts-mach", func { } }); +# Takeoff Modes +# Lat Active +var latarms = func { + if (getprop("/position/gear-agl-ft") >= getprop("/it-autoflight/settings/lat-agl-ft")) { + setprop("/it-autoflight/input/lat", getprop("/it-autoflight/input/lat-arm")); + } +} + # TOGA setlistener("/it-autoflight/input/toga", func { if (getprop("/it-autoflight/input/toga") == 1) { @@ -417,12 +444,6 @@ var toga_reduc = func { } } -var latarms = func { - if (getprop("/position/gear-agl-ft") >= getprop("/it-autoflight/settings/lat-agl-ft")) { - setprop("/it-autoflight/input/lat", getprop("/it-autoflight/input/lat-arm")); - } -} - # Altitude Capture and FPA Timer Logic setlistener("/it-autoflight/output/vert", func { var vertm = getprop("/it-autoflight/output/vert"); @@ -482,6 +503,24 @@ var altcapt = func { setprop("/it-autoflight/internal/alt", altinput); } +# Min and Max Pitch Reset +var minmax = func { + var calt = getprop("/instrumentation/altimeter/indicated-altitude-ft"); + var alt = getprop("/it-autoflight/internal/alt"); + var dif = calt - alt; + if (dif < 100 and dif > -100) { + setprop("/it-autoflight/internal/max-pitch", 8); + setprop("/it-autoflight/internal/min-pitch", -5); + var vertmode = getprop("/it-autoflight/output/vert"); + if (vertmode == 1 or vertmode == 2 or vertmode == 4 or vertmode == 5 or vertmode == 6 or vertmode == 7) { + # Do not change the vertical mode because we are not trying to capture altitude. + } else { + setprop("/it-autoflight/mode/vert", "ALT HLD"); + } + minmaxtimer.stop(); + } +} + # Thrust Mode Selector var thrustmode = func { var calt = getprop("/instrumentation/altimeter/indicated-altitude-ft"); @@ -511,24 +550,7 @@ var thrustmode = func { } } -# Min and Max Pitch Reset -var minmax = func { - var calt = getprop("/instrumentation/altimeter/indicated-altitude-ft"); - var alt = getprop("/it-autoflight/internal/alt"); - var dif = calt - alt; - if (dif < 100 and dif > -100) { - setprop("/it-autoflight/internal/max-pitch", 8); - setprop("/it-autoflight/internal/min-pitch", -5); - var vertmode = getprop("/it-autoflight/output/vert"); - if (vertmode == 1 or vertmode == 2 or vertmode == 4 or vertmode == 5 or vertmode == 6 or vertmode == 7) { - # Do not change the vertical mode because we are not trying to capture altitude. - } else { - setprop("/it-autoflight/mode/vert", "ALT HLD"); - } - minmaxtimer.stop(); - } -} - +# ILS and Autoland # Retard setlistener("/controls/flight/flaps", func { var flapc = getprop("/controls/flight/flaps"); @@ -575,11 +597,6 @@ var atoffchk = func{ } } -# For Canvas Nav Display. -setlistener("/it-autoflight/input/hdg", func { - setprop("/autopilot/settings/heading-bug-deg", getprop("/it-autoflight/input/hdg")); -}); - # LOC and G/S arming var update_arms = func { update_locarmelec(); @@ -706,6 +723,11 @@ var cwspitch = func { } } +# For Canvas Nav Display. +setlistener("/it-autoflight/input/hdg", func { + setprop("/autopilot/settings/heading-bug-deg", getprop("/it-autoflight/input/hdg")); +}); + # Timers var altcaptt = maketimer(0.5, altcapt); var thrustmodet = maketimer(0.5, thrustmode); @@ -719,3 +741,4 @@ var cwspitcht = maketimer(0.1, cwspitch); var reduct = maketimer(0.5, toga_reduc); var latarmt = maketimer(0.5, latarms); var fpa_calct = maketimer(0.1, fpa_calc); +var lnavwptt = maketimer(1, lnavwpt); diff --git a/Systems/it-autoflight.xml b/Systems/it-autoflight.xml index 16021bf0..69ff142f 100644 --- a/Systems/it-autoflight.xml +++ b/Systems/it-autoflight.xml @@ -313,7 +313,7 @@ 1 - -30 + -20 @@ -331,7 +331,7 @@ 1 - 30 + 20 @@ -369,6 +369,19 @@ + + IT-CONTROLLER: TARGET ROLL CMD + false + true + output + + /it-autoflight/internal/target-roll-deg + + /it-autoflight/internal/roll-deg-cmd + noise-spike + 10 + + IT-CONTROLLER: ROLL false @@ -390,7 +403,7 @@ /orientation/roll-deg - /it-autoflight/internal/target-roll-deg + /it-autoflight/internal/roll-deg-cmd /it-autoflight/internal/aileron-cmd @@ -465,7 +478,7 @@ /controls/flight/aileron noise-spike - 0.9 + 0.8 @@ -692,7 +705,7 @@ /it-autoflight/internal/lookahead-10-sec-mach - 1000.0 + 500.0 @@ -711,7 +724,7 @@ /it-autoflight/input/spd-mach - 1000.0 + 500.0 /it-autoflight/internal/target-pitch-deg @@ -732,7 +745,7 @@ /instrumentation/altimeter/indicated-altitude-ft - 1.5 + 2 @@ -811,13 +824,26 @@ 10.0 0.00001 - 1.5 + 2 25.0 + + + IT-CONTROLLER: TARGET PITCH CMD + false + true + output + + /it-autoflight/internal/target-pitch-deg + + /it-autoflight/internal/pitch-deg-cmd + noise-spike + 10 + IT-CONTROLLER: PITCH @@ -840,7 +866,7 @@ /orientation/pitch-deg - /it-autoflight/internal/target-pitch-deg + /it-autoflight/internal/pitch-deg-cmd /it-autoflight/internal/elevator-cmd @@ -1260,7 +1286,7 @@ - /it-autoflight/internal/target-roll-deg + /it-autoflight/internal/roll-deg-cmd /orientation/roll-deg @@ -1277,7 +1303,7 @@ - /it-autoflight/internal/target-pitch-deg + /it-autoflight/internal/pitch-deg-cmd /orientation/pitch-deg