| 1 |
# Copyright 2018 Stuart Buchanan |
| 2 |
# This file is part of FlightGear. |
| 3 |
# |
| 4 |
# FlightGear is free software: you can redistribute it and/or modify |
| 5 |
# it under the terms of the GNU General Public License as published by |
| 6 |
# the Free Software Foundation, either version 2 of the License, or |
| 7 |
# (at your option) any later version. |
| 8 |
# |
| 9 |
# FlightGear is distributed in the hope that it will be useful, |
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
# GNU General Public License for more details. |
| 13 |
# |
| 14 |
# You should have received a copy of the GNU General Public License |
| 15 |
# along with FlightGear. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
# |
| 17 |
# Constants to define the display area, for placement of elements. We |
| 18 |
# could try to do something with a layout, but the position and size of |
| 19 |
# elements is fixed. Can't be member variables of MFD as they are |
| 20 |
# self-referential. |
| 21 |
|
| 22 |
var DISPLAY = { WIDTH : 1024, HEIGHT : 768 }; |
| 23 |
var HEADER_HEIGHT = 56; |
| 24 |
var FOOTER_HEIGHT = 25; |
| 25 |
var EIS_WIDTH = 150; |
| 26 |
|
| 27 |
# Size of data display on the right hand side of the MFD |
| 28 |
var DATA_DISPLAY = { |
| 29 |
WIDTH : 300, |
| 30 |
HEIGHT : DISPLAY.HEIGHT - HEADER_HEIGHT - FOOTER_HEIGHT, |
| 31 |
X : DISPLAY.WIDTH - 300, |
| 32 |
Y : HEADER_HEIGHT, |
| 33 |
}; |
| 34 |
|
| 35 |
# Map dimensions when the data display is not present |
| 36 |
var MAP_FULL = { |
| 37 |
CENTER : { X : ((DISPLAY.WIDTH - EIS_WIDTH) / 2 + EIS_WIDTH), |
| 38 |
Y : ((DISPLAY.HEIGHT - HEADER_HEIGHT - FOOTER_HEIGHT) / 2 + HEADER_HEIGHT), }, |
| 39 |
X : EIS_WIDTH, |
| 40 |
Y : HEADER_HEIGHT, |
| 41 |
WIDTH : DISPLAY.WIDTH - EIS_WIDTH, |
| 42 |
HEIGHT : DISPLAY.HEIGHT - HEADER_HEIGHT - FOOTER_HEIGHT, |
| 43 |
}; |
| 44 |
|
| 45 |
# Map dimensions when the data display is present |
| 46 |
var MAP_PARTIAL = { |
| 47 |
X : EIS_WIDTH, |
| 48 |
Y : HEADER_HEIGHT, |
| 49 |
WIDTH : DISPLAY.WIDTH - EIS_WIDTH - DATA_DISPLAY.WIDTH, |
| 50 |
HEIGHT : DISPLAY.HEIGHT - HEADER_HEIGHT - FOOTER_HEIGHT, |
| 51 |
CENTER : { X : ((DISPLAY.WIDTH - EIS_WIDTH - DATA_DISPLAY.WIDTH) / 2 + EIS_WIDTH), |
| 52 |
Y : ((DISPLAY.HEIGHT - HEADER_HEIGHT - FOOTER_HEIGHT) / 2 + HEADER_HEIGHT), }, |
| 53 |
}; |
| 54 |
|
| 55 |
# Frequency limits. We're assuming we're on 8.33kHz |
| 56 |
var MIN_COM_FREQ = 118.000; |
| 57 |
var MAX_COM_FREQ = 137.000; |
| 58 |
|
| 59 |
var COM_833_SPACING = [ |
| 60 |
0.000, 0.005, 0.010, 0.015, 0.025, 0.030, 0.035, 0.040, 0.050, 0.055, 0.060, 0.065, 0.075, 0.080, 0.085, 0.090, |
| 61 |
0.100, 0.105, 0.110, 0.115, 0.125, 0.130, 0.135, 0.140, 0.150, 0.155, 0.160, 0.165, 0.175, 0.180, 0.185, 0.190, |
| 62 |
0.200, 0.205, 0.210, 0.215, 0.225, 0.230, 0.235, 0.240, 0.250, 0.255, 0.260, 0.265, 0.275, 0.280, 0.285, 0.290, |
| 63 |
0.300, 0.305, 0.310, 0.315, 0.325, 0.330, 0.335, 0.340, 0.350, 0.355, 0.360, 0.365, 0.375, 0.380, 0.385, 0.390, |
| 64 |
0.400, 0.405, 0.410, 0.415, 0.425, 0.430, 0.435, 0.440, 0.450, 0.455, 0.460, 0.465, 0.475, 0.480, 0.485, 0.490, |
| 65 |
0.500, 0.505, 0.510, 0.515, 0.525, 0.530, 0.535, 0.540, 0.550, 0.555, 0.560, 0.565, 0.575, 0.580, 0.585, 0.590, |
| 66 |
0.600, 0.605, 0.610, 0.615, 0.625, 0.630, 0.635, 0.640, 0.650, 0.655, 0.660, 0.665, 0.675, 0.680, 0.685, 0.690, |
| 67 |
0.700, 0.705, 0.710, 0.715, 0.725, 0.730, 0.735, 0.740, 0.750, 0.755, 0.760, 0.765, 0.775, 0.780, 0.785, 0.790, |
| 68 |
0.800, 0.805, 0.810, 0.815, 0.825, 0.830, 0.835, 0.840, 0.850, 0.855, 0.860, 0.865, 0.875, 0.880, 0.885, 0.890, |
| 69 |
0.900, 0.905, 0.910, 0.915, 0.925, 0.930, 0.935, 0.940, 0.950, 0.955, 0.960, 0.965, 0.975, 0.980, 0.985, 0.990, |
| 70 |
]; |
| 71 |
|
| 72 |
var NAV_SPACING = [ |
| 73 |
0.000, 0.025, 0.050, 0.075, |
| 74 |
0.100, 0.125, 0.150, 0.175, |
| 75 |
0.200, 0.225, 0.250, 0.275, |
| 76 |
0.300, 0.325, 0.350, 0.375, |
| 77 |
0.400, 0.425, 0.450, 0.475, |
| 78 |
0.500, 0.525, 0.550, 0.575, |
| 79 |
0.600, 0.625, 0.650, 0.675, |
| 80 |
0.700, 0.725, 0.750, 0.775, |
| 81 |
0.800, 0.825, 0.850, 0.875, |
| 82 |
0.900, 0.925, 0.950, 0.975, |
| 83 |
]; |
| 84 |
|
| 85 |
var MIN_NAV_FREQ = 108.000; |
| 86 |
var MAX_NAV_FREQ = 118.000; |
| 87 |
|
| 88 |
# Constants for the hard-buttons on the fascia |
| 89 |
var FASCIA = { |
| 90 |
NAV_VOL : 0, |
| 91 |
NAV_ID : 1, |
| 92 |
NAV_FREQ_TRANSFER :2, |
| 93 |
NAV_OUTER : 3, |
| 94 |
NAV_INNER : 4, |
| 95 |
NAV_TOGGLE : 5, |
| 96 |
HEADING : 6, |
| 97 |
HEADING_PRESS : 7, |
| 98 |
|
| 99 |
# Joystick |
| 100 |
RANGE : 8, |
| 101 |
JOYSTICK_HORIZONTAL : 9, |
| 102 |
JOYSTICK_VERTICAL : 10, |
| 103 |
|
| 104 |
#CRS/BARO |
| 105 |
BARO : 11, |
| 106 |
CRS : 12, |
| 107 |
CRS_CENTER : 13, |
| 108 |
|
| 109 |
COM_OUTER : 14, |
| 110 |
COM_INNER : 15, |
| 111 |
COM_TOGGLE : 16, |
| 112 |
|
| 113 |
COM_FREQ_TRANSFER : 17, |
| 114 |
COM_FREQ_TRANSFER_HOLD :18, # Auto-tunes to 121.2 when pressed for 2 seconds |
| 115 |
|
| 116 |
COM_VOL: 19, |
| 117 |
COM_VOL_TOGGLE: 20, |
| 118 |
|
| 119 |
DTO : 21, |
| 120 |
FPL : 22, |
| 121 |
CLR : 23, |
| 122 |
CLR_HOLD: 24, # Holding the CLR button for 2 seconds on the MFD displays the Nav Map |
| 123 |
|
| 124 |
FMS_OUTER : 25, |
| 125 |
FMS_INNER : 26, |
| 126 |
FMS_CRSR : 27, |
| 127 |
|
| 128 |
MENU : 28, |
| 129 |
PROC : 29, |
| 130 |
ENT : 30, |
| 131 |
|
| 132 |
ALT_OUTER : 31, |
| 133 |
ALT_INNER : 32, |
| 134 |
|
| 135 |
# Autopilot controls |
| 136 |
AP : 33, |
| 137 |
HDG : 34, |
| 138 |
NAV : 35, |
| 139 |
APR : 36, |
| 140 |
VS : 37, |
| 141 |
FLC : 38, |
| 142 |
FD : 39, |
| 143 |
ALT : 40, |
| 144 |
VNV : 41, |
| 145 |
BC : 42, |
| 146 |
NOSE_UP : 43, |
| 147 |
NOSE_DOWN : 44, |
| 148 |
|
| 149 |
JOYSTICK_PRESS : 45, |
| 150 |
|
| 151 |
# GDU 1045 Autopilot keys |
| 152 |
YD : 46, |
| 153 |
|
| 154 |
# Useability helpers to avoid having to use the FMS knobs to spell airport IDs etc. |
| 155 |
KEY_INPUT : 47, |
| 156 |
STRING_INPUT: 48, |
| 157 |
|
| 158 |
# GMA 1347 buttons |
| 159 |
COM1MIC: 49, |
| 160 |
COM2MIC: 50, |
| 161 |
COM3MIC: 51, |
| 162 |
COM12 : 52, |
| 163 |
PA : 53, |
| 164 |
MKRMUTE: 54, |
| 165 |
DME : 55, |
| 166 |
ADF : 56, |
| 167 |
AUX : 57, |
| 168 |
MANSQ : 58, |
| 169 |
PILOT : 59, |
| 170 |
COM1 : 60, |
| 171 |
COM2 : 61, |
| 172 |
COM3 : 62, |
| 173 |
TEL : 63, |
| 174 |
SPKR : 64, |
| 175 |
HISENS : 65, |
| 176 |
NAV1 : 66, |
| 177 |
NAV2 : 67, |
| 178 |
PLAY : 68, |
| 179 |
COPLT : 69 |
| 180 |
}; |
| 181 |
|
| 182 |
var get_SURFACE_TYPES = func(type) { |
| 183 |
if (type <= 2 or (type >= 20 and type <= 38) or (type >= 50 and type <= 57)) { |
| 184 |
return "HARD SURFACE"; |
| 185 |
} |
| 186 |
if (type == 3) { |
| 187 |
return "TURF"; |
| 188 |
} |
| 189 |
if (type == 4) { |
| 190 |
return "DIRT"; |
| 191 |
} |
| 192 |
if (type == 5) { |
| 193 |
return "GRAVEL"; |
| 194 |
} |
| 195 |
}; |
| 196 |
|
| 197 |
# Vertical ranges, and labels. |
| 198 |
# 28 ranges from 500ft to 2000nm, measuring the vertical map distance. |
| 199 |
# Vertical size of the map (once the nav box and softkey area is removed) is 689px. |
| 200 |
# 2000nm = 12,152,000ft. |
| 201 |
var RANGES = [{range: 500/6076.12, label: "500ft"}, |
| 202 |
{range: 750/6076.12, label: "750ft"}, |
| 203 |
{range: 1000/6076.12, label: "1000ft"}, |
| 204 |
{range: 1500/6076.12, label: "1500ft"}, |
| 205 |
{range: 2000/6076.12, label: "2000ft"}, |
| 206 |
{range: 0.5, label: "0.5nm"}, |
| 207 |
{range: 0.75, label: "0.75nm"}, |
| 208 |
{range: 1, label: "1nm"}, |
| 209 |
{range: 2, label: "2nm"}, |
| 210 |
{range: 3, label: "3nm"}, |
| 211 |
{range: 4, label: "4nm"}, |
| 212 |
{range: 6, label: "6nm"}, |
| 213 |
{range: 8, label: "8nm"}, |
| 214 |
{range: 10, label: "10nm"}, |
| 215 |
{range: 12, label: "12nm"}, |
| 216 |
{range: 15, label: "15nm"}, |
| 217 |
{range: 20, label: "20nm"}, |
| 218 |
{range: 25, label: "25nm"}, |
| 219 |
{range: 30, label: "30nm"}, |
| 220 |
{range: 40, label: "40nm"}, |
| 221 |
{range: 50, label: "50nm"}, |
| 222 |
{range: 75, label: "75nm"}, |
| 223 |
{range: 100, label: "100nm"}, |
| 224 |
{range: 200, label: "200nm"}, |
| 225 |
{range: 500, label: "500nm"}, |
| 226 |
{range: 1000, label: "1000nm"}, |
| 227 |
{range: 1500, label: "1500nm"}, |
| 228 |
{range: 2000, label: "2000nm"}, ]; |
| 229 |
|
| 230 |
var ORIENTATIONS = [ |
| 231 |
{ label: "NORTH UP" }, |
| 232 |
{ label: "TRK UP" }, |
| 233 |
{ label: "DTK UP" }, |
| 234 |
{ label: "HDG UP" }, |
| 235 |
]; |
| 236 |
|
| 237 |
# Mapping from transponder mode integer values to transponder mode strings, as an array. |
| 238 |
# Index values can be found in http://wiki.flightgear.org/Transponder#Knob.2FFunctional_Modes |
| 239 |
# String values are menuitem labels on the PFD itself. |
| 240 |
var TRANSPONDER_MODES = [ "OFF", "STBY", "TEST", "GND", "ON", "ALT"]; |