Skip to content

Commit b348e8b

Browse files
author
Luiz Renault
committed
UFCP NAV MODES and TTD.
1 parent b0f524a commit b348e8b

File tree

9 files changed

+296
-88
lines changed

9 files changed

+296
-88
lines changed

Cockpit/Scripts/CMFD/materials.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ materials["CMFD_IND_W_BASE"] = {255, 255, 255, 255}
7373
-- textures["hud_tex_ind1_r"] = {IND_TEX_PATH .. "Indication_HUD_1.dds", materials["HUD_IND_RED"]}
7474
-- textures["hud_tex_ind1_y"] = {IND_TEX_PATH .. "Indication_HUD_1.dds", materials["HUD_IND_YELLOW"]}
7575

76-
textures["hud_tex_ind2"] = {IND_TEX_PATH .. "Indication_HUD_2.dds", materials["HUD_IND_DEF"]}
77-
textures["hud_tex_ind2_r"] = {IND_TEX_PATH .. "Indication_HUD_2.dds", materials["HUD_IND_RED"]}
78-
textures["hud_tex_ind2_y"] = {IND_TEX_PATH .. "Indication_HUD_2.dds", materials["HUD_IND_YELLOW"]}
76+
textures["hud_tex_ind2"] = {nil, materials["HUD_IND_DEF"]}
77+
textures["hud_tex_ind2_r"] = {nil, materials["HUD_IND_RED"]}
78+
textures["hud_tex_ind2_y"] = {nil, materials["HUD_IND_YELLOW"]}
7979

8080
-- textures["hud_tex_clip"] = {IND_TEX_PATH .. "Indication_HUD_clip.dds", materials["HUD_IND_CLIP"]}
8181

Cockpit/Scripts/HUD/Indicator/HUD_GRID.lua

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -739,10 +739,9 @@ object.element_params = {"HUD_RANGE", "HUD_BRIGHT"}
739739
object.controllers = {{"text_using_parameter", 0, 0}, {"parameter_in_range",0,-0.05, 9999}, {"opacity_using_parameter", 1}}
740740

741741
-- Time indicator
742-
object = addStrokeText("HUD_Time", "00:00", STROKE_FNT_DFLT_120, "CenterCenter", {74, -88}, nil, nil, {"%02.0f:","%02.0f"})
743-
object.element_params = {"HUD_TIME_MIN", "HUD_TIME_SEC", "HUD_BRIGHT"}
744-
object.controllers = {{"text_using_parameter", 0, 0}, {"text_using_parameter", 1, 1}, {"parameter_in_range",1,-0.05, 60}, {"opacity_using_parameter", 2}}
745-
742+
object = addStrokeText("HUD_Time", "00:00", STROKE_FNT_DFLT_120, "CenterCenter", {74, -88}, nil, nil, {"%s"})
743+
object.element_params = {"HUD_TIME", "HUD_BRIGHT"}
744+
object.controllers = {{"text_using_parameter", 0, 0}, {"opacity_using_parameter", 2}}
746745

747746
-- FTY distance indicator
748747
object = addStrokeText("HUD_FTI_Dist", "22.3>08", STROKE_FNT_DFLT_120, "CenterCenter", {80, -99}, nil, nil, {"%02.1f>","%02.0f"})

Cockpit/Scripts/HUD/materials.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ textures["hud_tex_ind1"] = {IND_TEX_PATH .. "Indication_HUD_1.dds", mate
3838
textures["hud_tex_ind1_r"] = {IND_TEX_PATH .. "Indication_HUD_1.dds", materials["HUD_IND_RED"]}
3939
textures["hud_tex_ind1_y"] = {IND_TEX_PATH .. "Indication_HUD_1.dds", materials["HUD_IND_YELLOW"]}
4040

41-
textures["hud_tex_ind2"] = {IND_TEX_PATH .. "Indication_HUD_2.dds", materials["HUD_IND_DEF"]}
42-
textures["hud_tex_ind2_r"] = {IND_TEX_PATH .. "Indication_HUD_2.dds", materials["HUD_IND_RED"]}
43-
textures["hud_tex_ind2_y"] = {IND_TEX_PATH .. "Indication_HUD_2.dds", materials["HUD_IND_YELLOW"]}
41+
textures["hud_tex_ind2"] = {nil, materials["HUD_IND_DEF"]}
42+
textures["hud_tex_ind2_r"] = {nil, materials["HUD_IND_RED"]}
43+
textures["hud_tex_ind2_y"] = {nil, materials["HUD_IND_YELLOW"]}
4444

4545
textures["hud_tex_clip"] = {IND_TEX_PATH .. "Indication_HUD_clip.dds", materials["HUD_IND_CLIP"]}
4646

Cockpit/Scripts/Systems/cmfd_nav.lua

Lines changed: 59 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
dofile(LockOn_Options.script_path.."CMFD/CMFD_NAV_ID_defs.lua")
2+
dofile(LockOn_Options.script_path.."Systems/ufcp_api.lua")
23

34

45
local CMFD_NAV_FYT_VALID = get_param_handle("CMFD_NAV_FYT_VALID")
@@ -22,6 +23,9 @@ local CMFD_NAV_FYT_OAP_MINS = get_param_handle("CMFD_NAV_FYT_OAP_MINS")
2223
local CMFD_NAV_FYT_OAP_SECS = get_param_handle("CMFD_NAV_FYT_OAP_SECS")
2324
local CMFD_NAV_FYT_OAP_AZIMUTH = get_param_handle("CMFD_NAV_FYT_OAP_AZIMUTH")
2425
local CMFD_NAV_FYT_OAP_ELEVATION = get_param_handle("CMFD_NAV_FYT_OAP_ELEVATION")
26+
local CMFD_NAV_FYT_OAP_STT = get_param_handle("CMFD_NAV_FYT_OAP_STT")
27+
local CMFD_NAV_FYT_OAP_TTD = get_param_handle("CMFD_NAV_FYT_OAP_TTD")
28+
local CMFD_NAV_FYT_OAP_DT = get_param_handle("CMFD_NAV_FYT_OAP_DT")
2529
local CMFD_NAV_ROUT_TEXT = get_param_handle("CMFD_NAV_ROUT_TEXT")
2630
local CMFD_NAV_ROUT_TEXT1 = get_param_handle("CMFD_NAV_ROUT_TEXT1")
2731
local CMFD_NAV_ROUT_TEXT2 = get_param_handle("CMFD_NAV_ROUT_TEXT2")
@@ -33,6 +37,7 @@ local CMFD_NAV_MARK_TEXT = get_param_handle("CMFD_NAV_MARK_TEXT")
3337

3438
local nav_format = CMFD_NAV_FORMAT_IDS.AC
3539
local nav_fyt = 1
40+
local nav_fyt_last = -1
3641
local route
3742
local nav_fyt_list = {}
3843

@@ -81,6 +86,33 @@ local function get_heading(x1, y1, x2, y2)
8186
hdg = hdg % 360
8287
return hdg
8388
end
89+
local function cmfd_nav_sel_next_wpt()
90+
local nav_fyt_next = (nav_fyt + 1) % 100
91+
local limit = 0
92+
while nav_fyt_list[nav_fyt_next+1]==nil do
93+
nav_fyt_next = (nav_fyt_next + 1) % 100
94+
limit = limit + 1
95+
if limit > 100 then
96+
nav_fyt_next = 0
97+
break
98+
end
99+
end
100+
return nav_fyt_next
101+
end
102+
103+
local function cmfd_nav_sel_prev_wpt()
104+
local nav_fyt_prev = (nav_fyt - 1) % 100
105+
local limit = 0
106+
while nav_fyt_list[nav_fyt_prev+1]==nil do
107+
nav_fyt_prev = (nav_fyt_prev - 1) % 100
108+
limit = limit + 1
109+
if limit > 100 then
110+
nav_fyt_prev = 0
111+
break
112+
end
113+
end
114+
return nav_fyt_prev
115+
end
84116

85117
local function update_wpt_list(wpt_list)
86118
if wpt_list == nil then return wpt_list end
@@ -124,6 +156,8 @@ end
124156

125157
local wpt_index = get_valid_wpt_list()
126158

159+
local distance_last = -1
160+
127161
function update_nav()
128162
count = count + 1
129163
CMFD_NAV_FORMAT:set(nav_format)
@@ -198,6 +232,12 @@ function update_nav()
198232
z = z - nav_fyt_list[nav_fyt+1].lon_m
199233
local distance = math.sqrt(x*x + z*z) * 0.000539957
200234
local elev = y * 3.28084
235+
if distance < 2 and distance > distance_last and nav_fyt_last == nav_fyt and UFCP_NAV_MODE:get() == UFCP_NAV_MODE_IDS.AUTO then
236+
local nav_fyt_next = cmfd_nav_sel_next_wpt()
237+
if nav_fyt_next > nav_fyt and nav_fyt_next < 79 then nav_fyt = nav_fyt_next end
238+
end
239+
distance_last = distance
240+
nav_fyt_last = nav_fyt
201241

202242
local hdg
203243
if x ~= 0 then
@@ -232,6 +272,18 @@ function update_nav()
232272
time_mins = 99
233273
time_secs = 59
234274
end
275+
276+
local speed_to_target = 0
277+
local tot = nav_fyt_list[nav_fyt+1].time or 0
278+
local diff_tot = tot - get_absolute_model_time()
279+
280+
if diff_tot > 0 then
281+
speed_to_target = distance / diff_tot * 3600
282+
if speed_to_target > 999 then speed_to_target = 999 end
283+
else
284+
speed_to_target = -1
285+
end
286+
local dt = diff_tot - time
235287

236288
local plane_hdg = math.deg(-sensor_data.getHeading())
237289
if plane_hdg < 0 then plane_hdg = 360 + plane_hdg end
@@ -256,6 +308,9 @@ function update_nav()
256308

257309
CMFD_NAV_FYT_OAP_MINS:set(time_mins)
258310
CMFD_NAV_FYT_OAP_SECS:set(time_secs)
311+
CMFD_NAV_FYT_OAP_STT:set(speed_to_target)
312+
CMFD_NAV_FYT_OAP_TTD:set(time)
313+
CMFD_NAV_FYT_OAP_DT:set(dt)
259314

260315
if nav_fyt_list[nav_fyt+1].lat >= 0 then CMFD_NAV_FYT_LAT_HEMIS:set("N") else CMFD_NAV_FYT_LAT_HEMIS:set("S") end
261316
CMFD_NAV_FYT_LAT_DEG:set(math.floor(math.abs(nav_fyt_list[nav_fyt+1].lat)))
@@ -410,31 +465,6 @@ end
410465
dev:listen_command(device_commands.NAV_INC_FYT)
411466
dev:listen_command(device_commands.NAV_DEC_FYT)
412467

413-
local function cmfd_nav_sel_next_wpt()
414-
nav_fyt = (nav_fyt + 1) % 100
415-
local limit = 0
416-
while nav_fyt_list[nav_fyt+1]==nil do
417-
nav_fyt = (nav_fyt + 1) % 100
418-
limit = limit + 1
419-
if limit > 100 then
420-
nav_fyt = 0
421-
break
422-
end
423-
end
424-
end
425-
426-
local function cmfd_nav_sel_prev_wpt()
427-
nav_fyt = (nav_fyt - 1) % 100
428-
local limit = 0
429-
while nav_fyt_list[nav_fyt+1]==nil do
430-
nav_fyt = (nav_fyt - 1) % 100
431-
limit = limit + 1
432-
if limit > 100 then
433-
nav_fyt = 0
434-
break
435-
end
436-
end
437-
end
438468

439469
function SetCommandNav(command,value, CMFD)
440470
if value == 1 then
@@ -451,15 +481,15 @@ function SetCommandNav(command,value, CMFD)
451481
elseif command==device_commands.CMFD1OSS7 or command==device_commands.CMFD2OSS7 then
452482
nav_format = CMFD_NAV_FORMAT_IDS.AC
453483
elseif (command==device_commands.CMFD1OSS27 or command==device_commands.CMFD2OSS27) and nav_format == CMFD_NAV_FORMAT_IDS.FYT then
454-
cmfd_nav_sel_next_wpt()
484+
nav_fyt = cmfd_nav_sel_next_wpt()
455485
elseif (command==device_commands.CMFD1OSS26 or command==device_commands.CMFD2OSS26) and nav_format == CMFD_NAV_FORMAT_IDS.FYT then
456-
cmfd_nav_sel_prev_wpt()
486+
nav_fyt = cmfd_nav_sel_prev_wpt()
457487
elseif command==device_commands.CMFD1OSS28 or command==device_commands.CMFD2OSS28 then
458488
nav_format = CMFD_NAV_FORMAT_IDS.AFLD
459489
elseif command==device_commands.NAV_INC_FYT and value == 1 then
460-
cmfd_nav_sel_next_wpt()
490+
nav_fyt = cmfd_nav_sel_next_wpt()
461491
elseif command==device_commands.NAV_DEC_FYT and value == 1 then
462-
cmfd_nav_sel_prev_wpt()
492+
nav_fyt = cmfd_nav_sel_prev_wpt()
463493
end
464494
end
465495
end

Cockpit/Scripts/Systems/hud.lua

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ dofile(LockOn_Options.script_path.."Systems/electric_system_api.lua")
55
dofile(LockOn_Options.script_path.."Systems/alarm_api.lua")
66
dofile(LockOn_Options.script_path.."Systems/avionics_api.lua")
77
dofile(LockOn_Options.script_path.."Systems/weapon_system_api.lua")
8+
dofile(LockOn_Options.script_path.."Systems/ufcp_api.lua")
89

910
startup_print("hud: load")
1011

@@ -62,8 +63,7 @@ local HUD_RDY = get_param_handle("HUD_RDY")
6263
local HUD_DOI = get_param_handle("HUD_DOI")
6364
local HUD_RADAR_ALT = get_param_handle("HUD_RADAR_ALT")
6465
local HUD_RANGE = get_param_handle("HUD_RANGE")
65-
local HUD_TIME_MIN = get_param_handle("HUD_TIME_MIN")
66-
local HUD_TIME_SEC = get_param_handle("HUD_TIME_SEC")
66+
local HUD_TIME = get_param_handle("HUD_TIME")
6767
local HUD_FTI_DIST = get_param_handle("HUD_FTI_DIST")
6868
local HUD_FTI_NUM = get_param_handle("HUD_FTI_NUM")
6969
local HUD_VOR_DIST = get_param_handle("HUD_VOR_DIST")
@@ -110,6 +110,9 @@ local WS_TARGET_RANGE = get_param_handle("WS_TARGET_RANGE")
110110
local CMFD_NAV_FYT_OAP_BRG = get_param_handle("CMFD_NAV_FYT_OAP_BRG")
111111
local CMFD_NAV_FYT_OAP_AZIMUTH = get_param_handle("CMFD_NAV_FYT_OAP_AZIMUTH")
112112
local CMFD_NAV_FYT_OAP_ELEVATION = get_param_handle("CMFD_NAV_FYT_OAP_ELEVATION")
113+
local CMFD_NAV_FYT_OAP_STT = get_param_handle("CMFD_NAV_FYT_OAP_STT")
114+
local CMFD_NAV_FYT_OAP_TTD = get_param_handle("CMFD_NAV_FYT_OAP_TTD")
115+
local CMFD_NAV_FYT_OAP_DT = get_param_handle("CMFD_NAV_FYT_OAP_DT")
113116

114117
function limit_xy(x, y, limit_x, limit_y, limit_x_down, limit_y_down)
115118
limit_x_down = limit_x_down or -limit_x
@@ -410,9 +413,16 @@ function update()
410413
local angleh = math.atan2(iasz, iasx) - math.atan2(speedz, speedx)
411414
angleh = math.rad(sensor_data.getAngleOfSlide())-angleh
412415

413-
if HUD_DRIFT_CO:get() == 0 then
414-
else
416+
417+
if get_avionics_master_mode_ag() then
418+
HUD_DRIFT_CO:set(1)
419+
else
420+
HUD_DRIFT_CO:set(0)
421+
end
422+
423+
if HUD_DRIFT_CO:get() == 1 then
415424
angleh = 0
425+
else
416426
end
417427

418428
local fpm_cross = 0
@@ -429,7 +439,9 @@ function update()
429439
end
430440

431441
local ias_des = -1
432-
442+
local nav_time = UFCP_NAV_TIME:get()
443+
if nav_time == UFCP_NAV_TIME_IDS.DT or nav_time == UFCP_NAV_TIME_IDS.ETA then ias_des = CMFD_NAV_FYT_OAP_STT:get() end
444+
if ias_des > 990 then ias_des = 990 end
433445

434446
if master_mode == AVIONICS_MASTER_MODE_ID.LANDING then ias_des = -1 end
435447

@@ -460,10 +472,21 @@ function update()
460472
if CMFDDoi:get() == 0 then hud_doi = 1 else hud_doi = 0 end
461473

462474
local radar_alt = get_avionics_ralt()
475+
local time_text = ""
476+
local ttd = CMFD_NAV_FYT_OAP_TTD:get()
477+
local dt = CMFD_NAV_FYT_OAP_DT:get()
478+
479+
if nav_time == UFCP_NAV_TIME_IDS.DT then
480+
if dt >= 0 then time_text = "A" else time_text = "D" end
481+
dt = math.abs(dt)
482+
time_text = time_text .. string.format("%02.0f:%02.0f ", math.floor(dt / 60), dt % 60 )
483+
elseif nav_time == UFCP_NAV_TIME_IDS.TTD then
484+
time_text = string.format("%02.0f:%02.0f", math.floor(ttd / 60), ttd % 60 )
485+
elseif nav_time == UFCP_NAV_TIME_IDS.ETA then
486+
local tot = get_absolute_model_time() + ttd
487+
time_text = string.format("%02.0f:%02.0f:%02.0f", math.floor(tot / 3600), math.floor((tot % 3600) / 60), math.floor(tot % 60) )
488+
end
463489

464-
local time_min = 5
465-
local time_sec = -1
466-
467490
local fti_dist = -1
468491
local fti_num = 0
469492
fti_dist = round_to(fti_dist, 0.1)
@@ -502,9 +525,8 @@ function update()
502525

503526
HUD_RADAR_ALT:set(radar_alt)
504527

505-
HUD_TIME_MIN:set(time_min)
506-
HUD_TIME_SEC:set(time_sec)
507-
528+
HUD_TIME:set(time_text)
529+
508530
HUD_FTI_DIST:set(fti_dist)
509531
HUD_FTI_NUM:set(fti_num)
510532

0 commit comments

Comments
 (0)