lua: Fix VS/pitch mode changes for DH8D
This commit is contained in:
@@ -182,32 +182,60 @@ else
|
|||||||
if app_report_good and app_report[2] ~= 0xffff then
|
if app_report_good and app_report[2] ~= 0xffff then
|
||||||
ap_alt = app_report[2]
|
ap_alt = app_report[2]
|
||||||
end
|
end
|
||||||
-- vertical speed
|
-- vertical speed or pitch
|
||||||
local enter_mode_vs = false
|
local enter_mode_vs = false
|
||||||
local exit_mode_vs = false
|
local exit_mode_vs = false
|
||||||
|
local enter_mode_pitch = false
|
||||||
|
local exit_mode_pitch = false
|
||||||
|
local mode_vs = false
|
||||||
|
local mode_pitch = false
|
||||||
if ac_icao == "DH8D" then
|
if ac_icao == "DH8D" then
|
||||||
if q4xp_status_altmode == 3 and prev_status_altmode ~= 3 then
|
if q4xp_status_altmode == 3 and prev_status_altmode ~= 3 then
|
||||||
enter_mode_vs = true
|
enter_mode_vs = true
|
||||||
elseif q4xp_status_altmode ~= 3 and prev_status_altmode == 3 then
|
elseif q4xp_status_altmode ~= 3 and prev_status_altmode == 3 then
|
||||||
exit_mode_vs = true
|
exit_mode_vs = true
|
||||||
end
|
end
|
||||||
|
if q4xp_status_altmode == 3 then
|
||||||
|
mode_vs = true
|
||||||
|
end
|
||||||
|
if q4xp_status_altmode == 1 and prev_status_altmode ~= 1 then
|
||||||
|
enter_mode_pitch = true
|
||||||
|
elseif q4xp_status_altmode ~= 1 and prev_status_altmode == 1 then
|
||||||
|
exit_mode_pitch = true
|
||||||
|
end
|
||||||
|
if q4xp_status_altmode == 1 then
|
||||||
|
mode_pitch = true
|
||||||
|
end
|
||||||
else
|
else
|
||||||
if status_altmode == 4 and prev_status_altmode ~= 4 then
|
if status_altmode == 4 and prev_status_altmode ~= 4 then
|
||||||
enter_mode_vs = true
|
enter_mode_vs = true
|
||||||
elseif status_altmode ~= 4 and prev_status_altmode == 4 then
|
elseif status_altmode ~= 4 and prev_status_altmode == 4 then
|
||||||
exit_mode_vs = true
|
exit_mode_vs = true
|
||||||
end
|
end
|
||||||
|
if status_altmode == 4 then
|
||||||
|
mode_vs = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if enter_mode_vs then
|
if enter_mode_vs then
|
||||||
send_vs = math.floor(cur_vvi + 0.5)
|
send_vs = math.floor(cur_vvi + 0.5)
|
||||||
elseif exit_mode_vs then
|
elseif enter_mode_pitch then
|
||||||
|
send_vs = math.floor(q4xp_ap_pitch + 0.5)*100
|
||||||
|
elseif exit_mode_vs or exit_mode_pitch then
|
||||||
send_vs = -2
|
send_vs = -2
|
||||||
elseif app_report_good and app_report[3] ~= 0xffff then
|
elseif app_report_good and app_report[3] ~= 0xffff then
|
||||||
|
if mode_vs then
|
||||||
if bit.band(app_report[3], 0x8000) ~= 0 then
|
if bit.band(app_report[3], 0x8000) ~= 0 then
|
||||||
ap_vs = -bit.band(bit.bnot(app_report[3]), 0x7fff) - 1
|
ap_vs = -bit.band(bit.bnot(app_report[3]), 0x7fff) - 1
|
||||||
else
|
else
|
||||||
ap_vs = app_report[3]
|
ap_vs = app_report[3]
|
||||||
end
|
end
|
||||||
|
elseif mode_pitch then
|
||||||
|
if bit.band(app_report[3], 0x8000) ~= 0 then
|
||||||
|
q4xp_ap_pitch = (-bit.band(bit.bnot(app_report[3]), 0x7fff) - 1)/100
|
||||||
|
else
|
||||||
|
q4xp_ap_pitch = app_report[3]/100
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
-- airspeed
|
-- airspeed
|
||||||
local enter_mode_flc = false
|
local enter_mode_flc = false
|
||||||
@@ -257,27 +285,6 @@ else
|
|||||||
ap_as_kt_mach = app_report[4]
|
ap_as_kt_mach = app_report[4]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
--pitch
|
|
||||||
local enter_mode_pitch = false
|
|
||||||
local exit_mode_pitch = false
|
|
||||||
if ac_icao == "DH8D" then
|
|
||||||
if q4xp_status_altmode == 1 and prev_status_altmode ~= 1 then
|
|
||||||
enter_mode_pitch = true
|
|
||||||
elseif q4xp_status_altmode ~= 1 and prev_status_altmode == 1 then
|
|
||||||
exit_mode_pitch = true
|
|
||||||
end
|
|
||||||
if enter_mode_pitch then
|
|
||||||
send_vs = math.floor(q4xp_ap_pitch + 0.5)*100
|
|
||||||
elseif exit_mode_pitch then
|
|
||||||
send_vs = -2
|
|
||||||
elseif app_report_good and app_report[3] ~= 0xffff then
|
|
||||||
if bit.band(app_report[3], 0x8000) ~= 0 then
|
|
||||||
q4xp_ap_pitch = (-bit.band(bit.bnot(app_report[3]), 0x7fff) - 1)/100
|
|
||||||
else
|
|
||||||
q4xp_ap_pitch = app_report[3]/100
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
send_app_report(device, send_hdg, build_leds(), send_alt, send_vs, send_as, status_machmode == 1)
|
send_app_report(device, send_hdg, build_leds(), send_alt, send_vs, send_as, status_machmode == 1)
|
||||||
if ac_icao == "DH8D" then
|
if ac_icao == "DH8D" then
|
||||||
prev_status_altmode = q4xp_status_altmode
|
prev_status_altmode = q4xp_status_altmode
|
||||||
|
|||||||
Reference in New Issue
Block a user