-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlogic.lua
973 lines (814 loc) · 33.4 KB
/
logic.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
-- Comments and credits
--[[
Garmin G1000 Overlay for Air Manager 4.0 for Flight Simulator 2020.
Ovwerlay Version 0.5.0 Jan 09 2020.
This G1000 Overlay is a Work in Progress and is based upon RUSS BARLOW's Excellent earlier work for XPlane 10 & 11.
This Overlay is for Microsoft Flight Simulator 2020 only. It was originally tested against MSFS 2020 ver 1.12.13.0
This panel depends upon the MOBIFLIGHT Events WASM Module being installed into the community folder of MSFS2020.
Currently only the G1000 PFD is operational. Upcoming Work:
-Autopilot Button Array
-MFD
-Comms Panel
Contact: Phil Lewis jplewis02@gmail.com
--]]
-- PFD /MFD Selection
displayunit_label = user_prop_add_boolean("Display Unit Label", true, "Display the instrument type label on the LCD") -- Show or hide the unit type onscreen
display_pos = user_prop_add_enum("Display unit function","Pilot PFD,Copilot PFD,MFD","Pilot PFD","Select unit functional position")
local g_unitpos = "1"
local pos = user_prop_get(display_pos)
bezel_prop = user_prop_add_boolean("Autopilot", true, "Show autopilot controls") -- Show or hide the autopilot controls
-- Altimeter Setting - Preovides a way for the user to decide which Altimeter reference to adjust withthe Baro Knob
set_alt = user_prop_add_enum("Set Altimeter","Kohlsman,G1000,Both","Kohlsman","Choose Altimeter reference to set with the Baro Knob")
if pos == "Pilot PFD" then
g_unitpos= "1"
elseif pos == "Copilot PFD" then
g_unitpos= "2"
else
g_unitpos= "3"
end
if user_prop_get(bezel_prop) then
img_add_fullscreen("background.png")
else
img_add_fullscreen("background_noap.png")
end
--print("g_unitpos: " .. g_unitpos)
-- Show the G1000 Unit Type
if user_prop_get(displayunit_label) then
if g_unitpos == "1" then
--print("in display unit PFD")
image_pfd = img_add("pfd.png",195,110,40,30)
elseif g_unitpos == "3" then
--print("in display unit MFD")
image_mfd = img_add("mfd.png",195,110,40,30)
end
end
-- End PFD/MFD Selection
-- FS2020 Top Bezel Logo
image_id = img_add("fs2020logo.png",565,11,200,23)
click_snd = sound_add("knobclick.wav")
-- End Bezel Logo
--GPS DRIVES NAV1 / NAV Selected
function nav_selected_callback(navindex)
return navindex
end
function gps_selected_callback(gpsbool)
--print ("GPS Selected State :".. tostring(gpsbool))
return gpsbool
end
function ap_heading_bug_callback(heading)
HDG_Degrees = heading
--print("CB Heading:" .. tostring(heading))
return HDG_Degrees
end
fs2020_variable_subscribe("AUTOPILOT NAV SELECTED", "Number", nav_selected_callback)
fs2020_variable_subscribe("GPS DRIVES NAV1", "boolean", gps_selected_callback)
fs2020_variable_subscribe("AUTOPILOT HEADING LOCK DIR", "Degrees", ap_heading_bug_callback)
--End of GPS Selected
-- NAV Radio Functions
--NAV Swap - Stby Active Freqs on selected radio
function nav_ff()
--fs2020_event("NAV1_RADIO_SWAP")
fs2020_event("MOBIFLIGHT.AS1000_PFD_NAV_Switch")
sound_play(click_snd)
end
button_add(nil,"ff_button.png", 102,107,50,32, nav_ff)
-- Nav Radio Knob
function nav_outer_turn( direction)
if direction == -1 then
if g_unitpos == "1" then
fs2020_event("MOBIFLIGHT.AS1000_PFD_NAV_Large_DEC")
elseif g_unitpos == "3" then
fs2020_event("MOBIFLIGHT.AS1000_MFD_NAV_Large_DEC")
end
elseif direction == 1 then
if g_unitpos == "1" then
fs2020_event("MOBIFLIGHT.AS1000_PFD_NAV_Large_INC")
elseif g_unitpos == "3" then
fs2020_event("MOBIFLIGHT.AS1000_MFD_NAV_Large_INC")
end
end
end
nav_dial_outer = dial_add("plain_knob_outer.png", 47,173,79,79, nav_outer_turn)
dial_click_rotate(nav_dial_outer, 6)
function nav_inner_turn( direction)
if direction == -1 then
if g_unitpos == "1" then
fs2020_event("MOBIFLIGHT.AS1000_PFD_NAV_Small_DEC")
elseif g_unitpos == "3" then
fs2020_event("MOBIFLIGHT.AS1000_MFD_NAV_Small_DEC")
end
elseif direction == 1 then
if g_unitpos == "1" then
fs2020_event("MOBIFLIGHT.AS1000_PFD_NAV_Small_INC")
elseif g_unitpos == "3" then
fs2020_event("MOBIFLIGHT.AS1000_MFD_NAV_Small_INC")
end
end
end
nav_dial_inner = dial_add("plain_knob_inner.png", 63,189,47,47, nav_inner_turn)
dial_click_rotate(nav_dial_outer, 6)
--Selected Nav - 1 or 2
function nav_swap_click()
if g_unitpos == "1" then
fs2020_event("Mobiflight.AS1000_PFD_NAV_Push")
elseif g_unitpos == "3" then
fs2020_event("Mobiflight.AS1000_MFD_NAV_Push")
end
sound_play(click_snd)
end
button_add(nil,nil, 75,204,13,13, nav_swap_click)
--End Selected NAV
-- NAV VOL Knob add click to select ????
function nav_vol_turn( direction)
if direction == -1 then
if g_unitpos == "1" then
print("in PFD NAV Vol turn CCW")
fs2020_event("MOBIFLIGHT_AS1000_PFD_VOL_1_DEC")
fs2020_event("MOBIFLIGHT_AS1000_PFD_VOL_2_DEC")
elseif g_unitpos == "3" then
fs2020_event("MOBIFLIGHT_AS1000_MFD_VOL_1_DEC")
fs2020_event("MOBIFLIGHT_AS1000_MFD_VOL_2_DEC")
end
elseif direction == 1 then
if g_unitpos == "1" then
print("in PFD NAV Vol turn CW")
fs2020_event("MOBIFLIGHT_AS1000_PFD_VOL_1_INC")
fs2020_event("MOBIFLIGHT_AS1000_PFD_VOL_2_INC")
elseif g_unitpos == "3" then
fs2020_event("MOBIFLIGHT_AS1000_MFD_VOL_1_INC")
fs2020_event("MOBIFLIGHT_AS1000_MFD_VOL_2_INC")
end
sound_play(click_snd)
end
end
nav_vol_dial_turn = dial_add("vol_knob.png", 62,44,50,50, nav_vol_turn)
function nav_vol_press()
if g_unitpos == "1" then
print("in PFD Nav Vol Press")
fs2020_event("MOBIFLIGHT_AS1000_PFD_VOL_1_INC")
elseif g_unitpos == "3" then
fs2020_event("MOBIFLIGHT_AS1000_PFD_VOL_1_INC")
end
sound_play(click_snd)
end
--button_add(nil,nil, 67,49,40,40, nav_vol_press)
-- End NAV Radio
-- COM Radio Functions
--COM Swap Stby Active Freqs on selected radio
function com_ff()
fs2020_event("MOBIFLIGHT.AS1000_PFD_COM_Switch")
--fs2020_event("COM_STBY_RADIO_SWAP")
sound_play(click_snd)
end
button_add(nil,"ff_button.png", 1260,107,50,32, com_ff)
-- COM Radio Knob
function com_outer_turn( direction)
if direction == -1 then
if g_unitpos == "1" then
fs2020_event("Mobiflight.AS1000_PFD_COM_Large_DEC")
elseif g_unitpos == "3" then
fs2020_event("Mobiflight.AS1000_MFD_COM_Large_DEC")
end
elseif direction == 1 then
if g_unitpos == "1" then
fs2020_event("Mobiflight.AS1000_PFD_COM_Large_INC")
elseif g_unitpos == "3" then
fs2020_event("Mobiflight.AS1000_MFD_COM_Large_INC")
end
end
end
com_dial_outer = dial_add("plain_knob_outer.png", 1283,173,79,79, com_outer_turn)
dial_click_rotate( com_dial_outer, 6)
function com_inner_turn( direction)
if direction == -1 then
if g_unitpos == "1" then
fs2020_event("Mobiflight.AS1000_PFD_COM_Small_DEC")
elseif g_unitpos == "3" then
fs2020_event("Mobiflight.AS1000_MFD_COM_Small_DEC")
end
elseif direction == 1 then
if g_unitpos == "1" then
fs2020_event("Mobiflight.AS1000_PFD_COM_Small_INC")
elseif g_unitpos == "3" then
fs2020_event("Mobiflight.AS1000_MFD_COM_Small_INC")
end
end
end
com_dial_inner = dial_add("plain_knob_inner.png", 1299,189,47,47, com_inner_turn)
dial_click_rotate( com_dial_inner, 6)
--Selected COM - 1 or 2
function com_swap_click()
if g_unitpos == "1" then
fs2020_event("Mobiflight.AS1000_PFD_COM_Push")
sound_play(click_snd)
elseif g_unitpos == "3" then
fs2020_event("Mobiflight.AS1000_MFD_COM_Push")
--fs2020_event("COM_STBY_RADIO_SWAP")
sound_play(click_snd)
end
end
-- End Selected Nav
button_add(nil,nil, 1313,204,13,13, com_swap_click)
-- COM VOL Knob add click to select ????
function com_vol_press()
if g_unitpos == "1" then
print("in PFD Nav Vol Press")
fs2020_event("MOBIFLIGHT_AS1000_PFD_VOL_1_INC")
elseif g_unitpos == "3" then
fs2020_event("MOBIFLIGHT_AS1000_MFD_VOL_1_INC")
end
sound_play(click_snd)
end
--button_add(nil,nil, 1304,48,40,40, nav_vol_press)
function com_vol_turn()
if direction == -1 then
if g_unitpos == "1" then
--print("in PFD COM Vol turn CCW")
fs2020_event("MOBIFLIGHT_AS1000_PFD_VOL_1_DEC")
fs2020_event("MOBIFLIGHT_AS1000_PFD_VOL_2_DEC")
elseif g_unitpos == "3" then
--print("in MFD COM Vol turn CW")
fs2020_event("MOBIFLIGHT_AS1000_MFD_VOL_1_DEC")
fs2020_event("MOBIFLIGHT_AS1000_MFD_VOL_2_DEC")
end
elseif direction == 1 then
if g_unitpos == "1" then
--print("in MFD NAV Vol turn CW")
fs2020_event("MOBIFLIGHT_AS1000_PFD_VOL_1_INC")
fs2020_event("MOBIFLIGHT_AS1000_PFD_VOL_2_INC")
elseif g_unitpos == "3" then
fs2020_event("MOBIFLIGHT_AS1000_MFD_VOL_1_INC")
fs2020_event("MOBIFLIGHT_AS1000_MFD_VOL_2_INC")
end
sound_play(click_snd)
end
end
com_vol_dial_turn = dial_add("vol_knob.png", 1299,43,50,50, com_vol_turn)
--comvol_dial = button_add("vol_knob.png","vol_knob_prs.png", 1299,43,50,50, com_vol_press)
-- End COM Radio
-- Altitude Target Knob
function alt_callback(altitude)
--fs2020_event("AP_ALT_VAR_SET_ENGLISH",altitude)
TargetAlt = altitude
return TargetAlt
end
fs2020_variable_subscribe("AUTOPILOT ALTITUDE LOCK VAR", "feet", alt_callback)
function alt_large_callback(direction)
StepVal = 1000
-- Direction will have the value
if direction == 1 then
TargetAlt = TargetAlt + StepVal
elseif direction == -1 then
TargetAlt = TargetAlt - StepVal
end
fs2020_event("AP_ALT_VAR_SET_ENGLISH",TargetAlt)
end
function alt_small_callback(direction)
StepVal = 100 -- altdirection will have the value
if direction == 1 then
TargetAlt = TargetAlt + StepVal
elseif direction == -1 then
TargetAlt = TargetAlt - StepVal
end
fs2020_event("AP_ALT_VAR_SET_ENGLISH",TargetAlt)
end
alt_dial_outer = dial_add("plain_knob_outer.png", 47,793,79,79, alt_large_callback)
dial_click_rotate( alt_dial_outer, 6)
alt_dial_inner = dial_add("plain_knob_inner.png", 63,809,47,47, alt_small_callback)
dial_click_rotate( alt_dial_inner, 6)
-- End Altitude Target Knob
-- Heading Knob
function hdg_turn_inner( direction)
if direction == -1 then
HDG_Degrees = HDG_Degrees - 1
if HDG_Degrees <= 0 then
NewHdg = 360
else
NewHdg = HDG_Degrees
end
print("Heading Degrees CCW: " .. tostring(HDG_Degrees))
print("New Heading: " .. tostring(NewHdg))
fs2020_event("HEADING_BUG_SET", NewHdg)
elseif direction == 1 then
HDG_Degrees = HDG_Degrees + 1
if HDG_Degrees >= 361 then
NewHdg = HDG_Degrees - 360
else
NewHdg = HDG_Degrees
end
print("Heading Degrees CW: " .. tostring(HDG_Degrees))
print("New Heading: " .. tostring(NewHdg))
fs2020_event("HEADING_BUG_SET", NewHdg)
end
end
--[[
function hdg_turn_outer( direction)
if direction == -1 then
NewHdg = HDG_Degrees -10
if NewHdg < 1 then
NewHdg = 360 + NewHdg
end
print("Heading Degrees CCW: " .. tostring(HDG_Degrees))
print("New Heading: " .. tostring(NewHdg))
fs2020_event("HEADING_BUG_SET", NewHdg)
elseif direction == 1 then
NewHdg = HDG_Degrees + 10
if NewHdg > 360 then
NewHdg = 0 + (NewHdg - 360)
end
print("Heading Degrees CW: " .. tostring(HDG_Degrees))
print("New Heading: " .. tostring(NewHdg))
fs2020_event("HEADING_BUG_SET", NewHdg)
end
end
--]]
hdg_dial = dial_add("hdg_knob.png", 47,340,80,80,3, hdg_turn_inner)
--hdg_dial = dial_add("hdg_knob.png", 67,360,40,40,10, hdg_turn_inner)
dial_click_rotate( hdg_dial, 6)
function hdg_click()--_hdg_down
fs2020_event("AP_HDG_HOLD")
sound_play(click_snd)
end
button_add(nil,nil, 77,370,20,20,hdg_click)
-- End Heading Knob
-- AutoPilot functions
-- AP Mode VARs
function flc_callback(flcstate)
FLCState = flcstate
return FLCState
end
function vs_callback(vsenabled)
VSenabled = vsenabled
return VSenabled
end
function aspd_callback(asindicated)
--print ("asindicated: " ..tostring(asindicated))
AirspeedIndicated = asindicated
return AirspeedIndicated
end
fs2020_variable_subscribe("AUTOPILOT FLIGHT LEVEL CHANGE", "bool", flc_callback)
fs2020_variable_subscribe("AUTOPILOT VERTICAL HOLD", "bool", vs_callback)
fs2020_variable_subscribe("AIRSPEED INDICATED", "knots", aspd_callback)
-- AIRSPEED_INDICATED
-- fs2020_event("")
function ap_click()
fs2020_event("AP_Master")
sound_play(click_snd)
end
button_ap = button_add(nil,"ap_button.png", 28,470,50,32, ap_click)
visible(button_ap, user_prop_get(bezel_prop))
function hdg_click()
fs2020_event("AP_PANEL_HEADING_HOLD")
sound_play(click_snd)
end
button_hdg = button_add(nil,"hdg_button.png", 28,520,50,32, hdg_click)
visible(button_hdg, user_prop_get(bezel_prop))
function nav_click()
fs2020_event("AP_NAV1_HOLD_ON")
sound_play(click_snd)
end
button_nav = button_add(nil,"nav_button.png", 28,570,50,32, nav_click)
visible(button_nav, user_prop_get(bezel_prop))
function apr_click()
fs2020_event("AP_APR_HOLD")
sound_play(click_snd)
end
button_apr = button_add(nil,"apr_button.png", 28,621,50,32, apr_click)
visible(button_apr, user_prop_get(bezel_prop))
function vs_click()
fs2020_event("AP_PANEL_VS_HOLD")
sound_play(click_snd)
end
button_vs = button_add(nil,"vs_button.png", 28,671,50,32, vs_click)
visible(button_vs, user_prop_get(bezel_prop))
function flc_click()
if FLCState then
fs2020_event("FLIGHT_LEVEL_CHANGE_OFF")
else
AirspeedDecimal = math.floor(AirspeedIndicated)
fs2020_event("FLIGHT_LEVEL_CHANGE_ON")
fs2020_event("AP_SPD_VAR_SET", AirspeedDecimal)
end
sound_play(click_snd)
end
button_flc = button_add(nil,"flc_button.png", 26,721,54,32, flc_click)
visible(button_flc, user_prop_get(bezel_prop))
function fd_click()
fs2020_event("TOGGLE_FLIGHT_DIRECTOR")
sound_play(click_snd)
end
button_fd = button_add(nil,"fd_button.png", 100,470,50,32, fd_click)
visible(button_fd, user_prop_get(bezel_prop))
function alt_click()
fs2020_event("AP_ALT_HOLD")
sound_play(click_snd)
end
button_alt = button_add(nil,"alt_button.png", 100,520,50,32, alt_click)
visible(button_alt, user_prop_get(bezel_prop))
function vnv_click()
--MOBIFLIGHT_AS530_VNAV_Push
fs2020_event("MOBIFLIGHT_AS530_VNAV_Push")
sound_play(click_snd)
end
button_vnv = button_add(nil,"vnv_button.png", 98,570,54,32, vnv_click)
visible(button_vnv, user_prop_get(bezel_prop))
function bc_click()
fs2020_event("AP_BC_HOLD_ON")
sound_play(click_snd)
end
button_bc = button_add(nil,"bc_button.png", 98,621,54,32, bc_click)
visible(button_bc, user_prop_get(bezel_prop))
function nosup_click()
if VSenabled then
fs2020_event("AP_VS_VAR_INC")
elseif FLCState then
-- Create a hard Airspeed Set event
print ("Nose Up - asindicated: " ..tostring(asindicated))
--fs2020_event("AP_SPD_VAR_INC") -- Leave this commented place in case it ever gets flipped with Nose DN in FS Code again
fs2020_event("AP_SPD_VAR_DEC")
end
sound_play(click_snd)
end
button_nosup = button_add(nil,"nsup_button.png", 100,671,50,32, nosup_click)
visible(button_nosup, user_prop_get(bezel_prop))
function nosdn_click()
if VSenabled then
fs2020_event("AP_VS_VAR_DEC")
elseif FLCState then
-- Create a hard Airspeed Set event
print ("Nose Dn - asindicated: " ..tostring(asindicated))
--fs2020_event("AP_SPD_VAR_DEC") -- Leave this commented place in case it ever gets flipped with Nose UP up in FS Code again
fs2020_event("AP_SPD_VAR_INC")
end
sound_play(click_snd)
end
button_nosdn = button_add(nil,"nsdn_button.png", 100,721,50,32, nosdn_click)
visible(button_nosdn, user_prop_get(bezel_prop))
-- End of AutoPilot
--]]
-- Softkey Functions
-- PFD side
if g_unitpos == "1" then
function sc_1_click()
fs2020_event("MobiFlight.AS1000_PFD_SOFTKEYS_1")
sound_play(click_snd)
end
button_add(nil,"uparrow_button.png", 213,852,50,32, sc_1_click)
function sc_2_click()
fs2020_event("MobiFlight.AS1000_PFD_SOFTKEYS_2")
sound_play(click_snd)
end
button_add(nil,"uparrow_button.png", 297,852,50,32, sc_2_click)
function sc_3_click()
fs2020_event("MobiFlight.AS1000_PFD_SOFTKEYS_3")
sound_play(click_snd)
end
button_add(nil,"uparrow_button.png", 383,852,50,32, sc_3_click)
function sc_4_click()
fs2020_event("MobiFlight.AS1000_PFD_SOFTKEYS_4")
sound_play(click_snd)
end
button_add(nil,"uparrow_button.png", 468,852,50,32, sc_4_click)
function sc_5_click()
fs2020_event("MobiFlight.AS1000_PFD_SOFTKEYS_5")
sound_play(click_snd)
end
button_add(nil,"uparrow_button.png", 554,852,50,32, sc_5_click)
function sc_6_click()
--fs2020_event("TOGGLE_GPS_DRIVES_NAV1")
fs2020_event("MobiFlight.AS1000_PFD_SOFTKEYS_6")
sound_play(click_snd)
end
button_add(nil,"uparrow_button.png", 640,852,50,32, sc_6_click)
function sc_7_click()
fs2020_event("MobiFlight.AS1000_PFD_SOFTKEYS_7")
sound_play(click_snd)
end
button_add(nil,"uparrow_button.png", 724,852,50,32, sc_7_click)
function sc_8_click()
fs2020_event("MobiFlight.AS1000_PFD_SOFTKEYS_8")
sound_play(click_snd)
end
button_add(nil,"uparrow_button.png", 808,852,50,32, sc_8_click)
function sc_9_click()
fs2020_event("MobiFlight.AS1000_PFD_SOFTKEYS_9")
sound_play(click_snd)
end
button_add(nil,"uparrow_button.png", 892,852,50,32, sc_9_click)
function sc_10_click()
fs2020_event("MobiFlight.AS1000_PFD_SOFTKEYS_10")
sound_play(click_snd)
end
button_add(nil,"uparrow_button.png", 979,852,50,32, sc_10_click)
function sc_11_click()
fs2020_event("MobiFlight.AS1000_PFD_SOFTKEYS_11")
sound_play(click_snd)
end
button_add(nil,"uparrow_button.png", 1064,852,50,32, sc_11_click)
function sc_12_click()
fs2020_event("MobiFlight.AS1000_PFD_SOFTKEYS_12")
sound_play(click_snd)
end
button_add(nil,"uparrow_button.png", 1149,852,50,32, sc_12_click)
-- End PFD
-- MFD
elseif g_unitpos == "3" then
function sc_1_click()
fs2020_event("MobiFlight.AS1000_MFD_SOFTKEYS_1")
sound_play(click_snd)
end
button_add(nil,"uparrow_button.png", 213,852,50,32, sc_1_click)
function sc_2_click()
fs2020_event("MobiFlight.AS1000_MFD_SOFTKEYS_2")
sound_play(click_snd)
end
button_add(nil,"uparrow_button.png", 297,852,50,32, sc_2_click)
function sc_3_click()
fs2020_event("MobiFlight.AS1000_MFD_SOFTKEYS_3")
sound_play(click_snd)
end
button_add(nil,"uparrow_button.png", 383,852,50,32, sc_3_click)
function sc_4_click()
fs2020_event("MobiFlight.AS1000_MFD_SOFTKEYS_4")
sound_play(click_snd)
end
button_add(nil,"uparrow_button.png", 468,852,50,32, sc_4_click)
function sc_5_click()
fs2020_event("MobiFlight.AS1000_MFD_SOFTKEYS_5")
sound_play(click_snd)
end
button_add(nil,"uparrow_button.png", 554,852,50,32, sc_5_click)
function sc_6_click()
--fs2020_event("TOGGLE_GPS_DRIVES_NAV1")
fs2020_event("MobiFlight.AS1000_MFD_SOFTKEYS_6")
sound_play(click_snd)
end
button_add(nil,"uparrow_button.png", 640,852,50,32, sc_6_click)
function sc_7_click()
fs2020_event("MobiFlight.AS1000_MFD_SOFTKEYS_7")
sound_play(click_snd)
end
button_add(nil,"uparrow_button.png", 724,852,50,32, sc_7_click)
function sc_8_click()
fs2020_event("MobiFlight.AS1000_MFD_SOFTKEYS_8")
sound_play(click_snd)
end
button_add(nil,"uparrow_button.png", 808,852,50,32, sc_8_click)
function sc_9_click()
fs2020_event("MobiFlight.AS1000_MFD_SOFTKEYS_9")
sound_play(click_snd)
end
button_add(nil,"uparrow_button.png", 892,852,50,32, sc_9_click)
function sc_10_click()
fs2020_event("MobiFlight.AS1000_MFD_SOFTKEYS_10")
sound_play(click_snd)
end
button_add(nil,"uparrow_button.png", 979,852,50,32, sc_10_click)
function sc_11_click()
fs2020_event("MobiFlight.AS1000_MFD_SOFTKEYS_11")
sound_play(click_snd)
end
button_add(nil,"uparrow_button.png", 1064,852,50,32, sc_11_click)
function sc_12_click()
fs2020_event("MobiFlight.AS1000_MFD_SOFTKEYS_12")
sound_play(click_snd)
end
button_add(nil,"uparrow_button.png", 1149,852,50,32, sc_12_click)
end
-- End MFD
-- End MFD
-- End of SoftKeys
-- FMS Functions
-- DIRECT TO
function dir_click()
if g_unitpos == "1" then
fs2020_event("MobiFlight.AS1000_PFD_DIRECTTO")
elseif g_unitpos == "3" then
fs2020_event("MobiFlight.AS1000_MFD_DIRECTTO")
end
sound_play(click_snd)
end
button_add(nil,"dir_button.png", 1262,621,50,32, dir_click)
-- MENU
function menu_click()
if g_unitpos == "1" then
fs2020_event("MobiFlight.AS1000_PFD_MENU_Push")
elseif g_unitpos == "3" then
fs2020_event("MobiFlight.AS1000_MFD_MENU_Push")
end
sound_play(click_snd)
end
button_add(nil,"menu_button.png", 1334,621,50,32, menu_click)
-- FPL
function fpl_click()
if g_unitpos == "1" then
fs2020_event("MobiFlight.AS1000_PFD_FPL_Push")
elseif g_unitpos == "3" then
fs2020_event("MobiFlight.AS1000_MFD_FPL_Push")
end
sound_play(click_snd)
end
button_add(nil,"fpl_button.png", 1262,673,50,32, fpl_click)
-- PROC
function proc_click()
if g_unitpos == "1" then
fs2020_event("MobiFlight.AS1000_PFD_PROC_Push")
elseif g_unitpos == "3" then
fs2020_event("MobiFlight.AS1000_MFD_PROC_Push")
end
sound_play(click_snd)
end
button_add(nil,"proc_button.png", 1334,673,50,32, proc_click)
-- CLR
function clr_click_down()
if g_unitpos == "1" then
fs2020_event("MobiFlight.AS1000_PFD_CLR")
elseif g_unitpos == "3" then
fs2020_event("MobiFlight.AS1000_MFD_CLR")
end
sound_play(click_snd)
end
function clr_click_up()
if g_unitpos == "1" then
fs2020_event("MobiFlight.AS1000_PFD_CLR")
elseif g_unitpos == "3" then
fs2020_event("MobiFlight.AS1000_MFD_CLR")
end
sound_play(click_snd)
end
button_add(nil,"clr_button.png", 1262,725,50,32, clr_click_down, clr_click_up)
-- ENT
function ent_click()
if g_unitpos == "1" then
fs2020_event("MobiFlight.AS1000_PFD_ENT_Push")
elseif g_unitpos == "3" then
fs2020_event("MobiFlight.AS1000_MFD_ENT_Push")
end
sound_play(click_snd)
end
button_add(nil,"ent_button.png", 1334,725,50,32, ent_click)
--End of FMS Functions
-- FMS
function fms_outer_turn( direction)
if g_unitpos == "1" then
if direction == -1 then
fs2020_event("MOBIFLIGHT.AS1000_PFD_FMS_Lower_DEC")
elseif direction == 1 then
fs2020_event("MOBIFLIGHT.AS1000_PFD_FMS_Lower_INC")
end
elseif g_unitpos == "3" then
if direction == -1 then
fs2020_event("MOBIFLIGHT.AS1000_MFD_FMS_Lower_DEC")
elseif direction == 1 then
fs2020_event("MOBIFLIGHT.AS1000_MFD_FMS_Lower_INC")
end
end
end
fms_dial_outer = dial_add("fms_knob.png", 1284,792,79,79, fms_outer_turn)
dial_click_rotate( fms_dial_outer, 6)
function fms_inner_turn( direction)
if g_unitpos == "1" then
if direction == -1 then
print ("FMS Inner CCW Turn -")
fs2020_event("MOBIFLIGHT.AS1000_PFD_FMS_Upper_DEC")
elseif direction == 1 then
print ("FMS Inner CW Turn +")
fs2020_event("MOBIFLIGHT.AS1000_PFD_FMS_Upper_INC")
end
elseif g_unitpos == "3" then
if direction == -1 then
print ("FMS Inner CCW Turn -")
fs2020_event("MOBIFLIGHT.AS1000_MFD_FMS_Upper_DEC")
elseif direction == 1 then
print ("FMS Inner CW Turn +")
fs2020_event("MOBIFLIGHT.AS1000_MFD_FMS_Upper_INC")
end
end
end
fms_dial_inner = dial_add("Vol_knob.png", 1300,808,47,47, fms_inner_turn)
dial_click_rotate( fms_dial_outer, 6)
function cursor_click()
if g_unitpos == "1" then
fs2020_event("MOBIFLIGHT.AS1000_PFD_FMS_Upper_PUSH")
elseif g_unitpos == "3" then
fs2020_event("MOBIFLIGHT.AS1000_MFD_FMS_Upper_PUSH")
end
sound_play(click_snd)
end
button_add(nil,nil, 1311,821,13,13, cursor_click)
-- End of FMS
--[[
-- Pan pallette
-- add pan controls
local pal_x = 1229
local pal_y = 432
function up_prs()
xpl_command("sim/GPS/g1000n"..g_unitpos.."_pan_up")
end
up_press = button_add(nil, "up_arrow.png", pal_x + 69, pal_y + 0, 49,42, up_prs)
function up_rt_prs()
xpl_command("sim/GPS/g1000n"..g_unitpos.."_pan_up_right")
end
uprt_press = button_add(nil, "uprt_arrow.png", pal_x + 118, pal_y + 25, 46,48, up_rt_prs)
function up_lt_prs()
xpl_command("sim/GPS/g1000n"..g_unitpos.."_pan_up_left")
end
uplt_press = button_add(nil, "uplt_arrow.png", pal_x + 22, pal_y + 25, 47,47, up_lt_prs)
function lt_prs()
xpl_command("sim/GPS/g1000n"..g_unitpos.."_pan_left")
end
lt_press = button_add(nil, "lt_arrow.png", pal_x + 0, pal_y + 74, 44,46, lt_prs)
function rt_prs()
xpl_command("sim/GPS/g1000n"..g_unitpos.."_pan_right")
end
rt_press = button_add(nil, "rt_arrow.png", pal_x + 146, pal_y + 74, 44,46, rt_prs)
function dn_prs()
xpl_command("sim/GPS/g1000n"..g_unitpos.."_pan_down")
end
dn_press = button_add(nil, "down_arrow.png", pal_x + 69, pal_y + 148, 49,42, dn_prs)
function dnrt_prs()
xpl_command("sim/GPS/g1000n"..g_unitpos.."_pan_down_right")
end
dnrt_press = button_add(nil, "downrt_arrow.png", pal_x + 118, pal_y + 120, 46,48, dnrt_prs)
function dnlt_prs()
xpl_command("sim/GPS/g1000n"..g_unitpos.."_pan_down_left")
end
dnlt_press = button_add(nil, "downlt_arrow.png", pal_x + 22, pal_y + 120, 47,47, dnlt_prs)
pan_background = img_add("pan_background.png", pal_x ,pal_y,190,190)
local pan_vis = false
visible(pan_background, pan_vis)
function pansel_click()
pan_vis = not pan_vis
visible(pan_background, pan_vis)
sound_play(click_snd)
end
button_add(nil,nil, 1313,519,21,21, pansel_click)
--]]
-- Range Knob
-- PFD
if g_unitpos == "1" then
function pfd_range_turn( direction)
if direction == -1 then
fs2020_event("Mobiflight.AS1000_PFD_RANGE_DEC")
elseif direction == 1 then
fs2020_event("Mobiflight.AS1000_PFD_RANGE_INC")
end
end
--End PFD
-- MFD
elseif g_unitpos == "3" then
function mfd_range_turn( direction)
if direction == -1 then
fs2020_event("Mobiflight.AS1000_MFD_RANGE_DEC")
elseif direction == 1 then
fs2020_event("Mobiflight.AS1000_MFD_RANGE_INC")
end
end
--End MFD
end
pfdrng_dial = dial_add("rng_knob.png", 1292,496,65,65, pfd_range_turn)
mfdrng_dial = dial_add("rng_knob.png", 1292,496,65,65, mfd_range_turn)
dial_click_rotate( pfdrng_dial, 6)
dial_click_rotate( mfdrng_dial, 6)
-- End Range Knob
-- Barometric / CRS Knob
function baro_turn( direction)
if user_prop_get(set_altimeter) == "Kohlsman" then
if direction == -1 then
fs2020_event("KOHLSMAN_DEC")
elseif direction == 1 then
fs2020_event("KOHLSMAN_INC")
end
elseif user_prop_get(set_altimeter) == "G1000" then
if direction == -1 then
fs2020_event("MOBIFLIGHT.AS1000_PFD_BARO_DEC")
elseif direction == 1 then
fs2020_event("MOBIFLIGHT.AS1000_PFD_BARO_INC")
end
else -- Set Both Kohlsman & G1000
if direction == -1 then
fs2020_event("MOBIFLIGHT.AS1000_PFD_BARO_DEC")
fs2020_event("KOHLSMAN_DEC")
elseif direction == 1 then
fs2020_event("MOBIFLIGHT.AS1000_PFD_BARO_INC")
fs2020_event("KOHLSMAN_INC")
end
end
end
baro_dial = dial_add("baro_knob.png", 1284,334,80,80, baro_turn)
dial_click_rotate( baro_dial, 6)
function crs_turn( direction)
if direction == -1 then
fs2020_event("MOBIFLIGHT.AS1000_PFD_CRS_DEC")
elseif direction == 1 then
fs2020_event("MOBIFLIGHT.AS1000_PFD_CRS_INC")
end
end
crs_dial = dial_add("crs_knob.png", 1298,350,51,51,3, crs_turn)
dial_click_rotate( crs_dial, 6)
function crs_click()
-- Add Custom Logic to provide a feedback variable to cover whichever VOR is active ???
sound_play(click_snd)
end
button_add(nil,nil, 1315,370,13,13, crs_click)
-- End Baro / CRS