@@ -122,6 +122,32 @@ local buttons = {
122122 ICP_DN = { 17 , 3035 , - 1 },
123123 ICP_INC = { 17 , 3030 },
124124 ICP_DEC = { 17 , 3031 },
125+
126+ -- F-14B
127+ RIO_CAP_BTN_1 = { 23 , 3518 },
128+ RIO_CAP_BTN_2 = { 23 , 3519 },
129+ RIO_CAP_BTN_3 = { 23 , 3520 },
130+ RIO_CAP_BTN_4 = { 23 , 3521 },
131+ RIO_CAP_BTN_5 = { 23 , 3522 },
132+ RIO_CAP_BTN_6 = { 23 , 3523 },
133+ RIO_CAP_BTN_7 = { 23 , 3524 },
134+ RIO_CAP_BTN_8 = { 23 , 3525 },
135+ RIO_CAP_BTN_9 = { 23 , 3526 },
136+ RIO_CAP_BTN_10 = { 23 , 3527 },
137+ RIO_CAP_BRG_0 = { 23 , 3535 },
138+ RIO_CAP_LAT_1 = { 23 , 3536 },
139+ RIO_CAP_NBR_2 = { 23 , 3537 },
140+ RIO_CAP_SPD_3 = { 23 , 3538 },
141+ RIO_CAP_ALT_4 = { 23 , 3539 },
142+ RIO_CAP_RNG_5 = { 23 , 3540 },
143+ RIO_CAP_LONG_6 = { 23 , 3541 },
144+ RIO_CAP_7 = { 23 , 3542 },
145+ RIO_CAP_HDG_8 = { 23 , 3543 },
146+ RIO_CAP_9 = { 23 , 3544 },
147+ RIO_CAP_SW = { 23 , 3532 },
148+ RIO_CAP_NE = { 23 , 3533 },
149+ RIO_CAP_CLEAR = { 23 , 3531 },
150+ RIO_CAP_ENTER = { 23 , 3534 },
125151}
126152
127153local cdu_map = {
@@ -197,6 +223,23 @@ local icp_map = {
197223 [" W" ] = buttons .ICP_4 ,
198224}
199225
226+ local cap_map = {
227+ [" 0" ] = buttons .RIO_CAP_BRG_0 ,
228+ [" 1" ] = buttons .RIO_CAP_LAT_1 ,
229+ [" 2" ] = buttons .RIO_CAP_NBR_2 ,
230+ [" 3" ] = buttons .RIO_CAP_SPD_3 ,
231+ [" 4" ] = buttons .RIO_CAP_ALT_4 ,
232+ [" 5" ] = buttons .RIO_CAP_RNG_5 ,
233+ [" 6" ] = buttons .RIO_CAP_LONG_6 ,
234+ [" 7" ] = buttons .RIO_CAP_7 ,
235+ [" 8" ] = buttons .RIO_CAP_HDG_8 ,
236+ [" 9" ] = buttons .RIO_CAP_9 ,
237+ [" E" ] = buttons .RIO_CAP_NE ,
238+ [" N" ] = buttons .RIO_CAP_NE ,
239+ [" S" ] = buttons .RIO_CAP_SW ,
240+ [" W" ] = buttons .RIO_CAP_SW ,
241+ }
242+
200243local log = function (str )
201244 logFile :write (str .. " \n " )
202245 logFile :flush ()
@@ -270,6 +313,10 @@ function charToIcpButton(char)
270313 return icp_map [char ]
271314end
272315
316+ function charToCapButton (char )
317+ return cap_map [char ]
318+ end
319+
273320function enterScratch (str )
274321 str = str :upper ()
275322 for i = 1 , # str do
@@ -369,6 +416,31 @@ function addIcpWaypoint(latitude, longitude, elevation, tot)
369416 pushButton (buttons .ICP_INC )
370417end
371418
419+ function enterCap (str )
420+ for i = 1 , # str do
421+ local button = charToCapButton (str :sub (i , i ))
422+ if button then
423+ pushButton (button )
424+ end
425+ end
426+ pushButton (buttons .RIO_CAP_ENTER )
427+ end
428+
429+ function addCapWaypoint (wpButton , latitude , longitude , elevation )
430+ pushButton (wpButton )
431+ pushButton (buttons .RIO_CAP_CLEAR )
432+ pushButton (buttons .RIO_CAP_LAT_1 )
433+ enterCap (latitude )
434+ pushButton (buttons .RIO_CAP_CLEAR )
435+ pushButton (buttons .RIO_CAP_LONG_6 )
436+ enterCap (longitude )
437+ if elevation ~= " " then
438+ pushButton (buttons .RIO_CAP_CLEAR )
439+ pushButton (buttons .RIO_CAP_ALT_4 )
440+ enterCap (elevation )
441+ end
442+ end
443+
372444programA10Flightplan = function (time )
373445 log (" Start programming A-10C..." )
374446 selectWaypointPage ()
@@ -450,13 +522,37 @@ programF16Flightplan = function(time)
450522 log (" programming DONE!" )
451523end
452524
525+ programF14Flightplan = function (time )
526+ log (" Start programming F-14 ..." )
527+
528+ local wp_btn_map = {
529+ [1 ] = buttons .RIO_CAP_BTN_1 ,
530+ [2 ] = buttons .RIO_CAP_BTN_2 ,
531+ [3 ] = buttons .RIO_CAP_BTN_3 ,
532+ }
533+
534+ for i , wp in ipairs (mdc .waypoints ) do
535+ local wp_btn = wp_btn_map [i ]
536+ if wp_btn ~= nil then
537+ log (" Add Waypoint ... " .. wp .cdu )
538+ local parts = {}
539+ for part in string.gmatch (wp .cdu , " %S+" ) do
540+ table.insert (parts , part )
541+ end
542+ addCapWaypoint (wp_btn , parts [1 ], parts [2 ], wp .alt )
543+ end
544+ end
545+ log (" programming DONE!" )
546+ end
547+
453548mdc = nil
454549
455550function loadMdc ()
456551 dofile (dataPath .. ' mdc.lua' )
457552end
458553
459554LuaExportActivityNextEvent = function (current )
555+ log (" LuaExportActivityNextEvent" )
460556 local data = LoGetSelfData ()
461557 if data ~= nil then
462558 if theRoutine == nil then
@@ -476,6 +572,11 @@ LuaExportActivityNextEvent = function(current)
476572 loadMdc ()
477573 theRoutine = coroutine.create (programF16Flightplan )
478574 end
575+ elseif unit == " F-14B" then
576+ if GetDevice (0 ):get_argument_value (1814 ) == 1 then -- RIO_CCM_VGS
577+ loadMdc ()
578+ theRoutine = coroutine.create (programF14Flightplan )
579+ end
479580 end
480581 elseif coroutine.status (theRoutine ) == " suspended" then
481582 coroutine.resume (theRoutine )
0 commit comments