2017-05-13 14:45:26 +00:00
|
|
|
##################################################################
|
|
|
|
# A3XX MCDU by Joshua Davidson (it0uchpods) and Jonathan Redpath #
|
|
|
|
##################################################################
|
|
|
|
|
|
|
|
var MCDU_init = func {
|
|
|
|
setprop("/MCDU[0]/brightness", "1.0");
|
|
|
|
MCDU_reset(); # Reset MCDU, clears data
|
|
|
|
}
|
|
|
|
|
|
|
|
var MCDU_reset = func {
|
2017-05-14 17:26:35 +00:00
|
|
|
setprop("/MCDU[0]/page", "STATUS");
|
2017-05-15 17:53:22 +00:00
|
|
|
setprop("/MCDU[0]/cost-index", 0);
|
|
|
|
setprop("/MCDU[0]/flight-num", 0);
|
2017-05-18 18:41:33 +00:00
|
|
|
setprop("/MCDU[0]/scratchpad", "");
|
2017-05-18 20:39:14 +00:00
|
|
|
setprop("/FMGC/internal/cost-index-set", 0);
|
2017-05-18 18:41:33 +00:00
|
|
|
setprop("/FMGC/internal/cruise-lvl-set", 0);
|
2017-05-13 17:08:49 +00:00
|
|
|
}
|
|
|
|
|
2017-05-18 18:41:33 +00:00
|
|
|
var lskbutton = func(btn) {
|
2017-05-19 13:36:39 +00:00
|
|
|
if (btn == "2") {
|
|
|
|
if (getprop("/MCDU[0]/page") == "INITA") {
|
|
|
|
PerfInput("L2");
|
|
|
|
}
|
|
|
|
} else if (btn == "4") {
|
2017-05-18 13:53:16 +00:00
|
|
|
if (getprop("/MCDU[0]/page") == "DATA") {
|
2017-05-18 22:28:36 +00:00
|
|
|
setprop("/MCDU[0]/page", "STATUS");
|
2017-05-18 13:53:16 +00:00
|
|
|
}
|
2017-05-18 20:39:14 +00:00
|
|
|
} else if (btn == "5") {
|
|
|
|
if (getprop("/MCDU[0]/page") == "INITA") {
|
|
|
|
initInputA("L5");
|
2017-05-19 13:36:39 +00:00
|
|
|
} else if (getprop("/MCDU[0]/page") == "CLB") {
|
2017-05-19 19:20:54 +00:00
|
|
|
perfCLBInput("L5");
|
2017-05-18 20:39:14 +00:00
|
|
|
}
|
2017-05-18 18:41:33 +00:00
|
|
|
} else if (btn == "6") {
|
|
|
|
if (getprop("/MCDU[0]/page") == "INITA") {
|
|
|
|
initInputA("L6");
|
2017-05-19 13:36:39 +00:00
|
|
|
} else if (getprop("/MCDU[0]/page") == "CLB") {
|
2017-05-19 19:20:54 +00:00
|
|
|
perfCLBInput("L6");
|
2017-05-19 16:20:08 +00:00
|
|
|
} else if (getprop("/MCDU[0]/page") == "CRZ") {
|
2017-05-19 19:20:54 +00:00
|
|
|
perfCRZInput("L6");
|
2017-05-18 18:41:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-05-19 13:36:39 +00:00
|
|
|
|
2017-05-18 18:41:33 +00:00
|
|
|
|
|
|
|
var initInputA = func(key) {
|
|
|
|
var scratchpad = getprop("/MCDU[0]/scratchpad");
|
2017-05-18 20:39:14 +00:00
|
|
|
if (key == "L5") {
|
|
|
|
if (scratchpad == "CLR") {
|
|
|
|
setprop("/FMGC/internal/cost-index", 0);
|
|
|
|
setprop("/FMGC/internal/cost-index-set", 0);
|
|
|
|
setprop("/MCDU[0]/scratchpad", "");
|
|
|
|
} else {
|
|
|
|
var ci = int(scratchpad);
|
|
|
|
var cis = size(scratchpad);
|
|
|
|
if (cis >= 1 and cis <= 3) {
|
|
|
|
if (cis >= 0 and cis <= 120) {
|
|
|
|
setprop("/FMGC/internal/cost-index", ci);
|
|
|
|
setprop("/FMGC/internal/cost-index-set", 1);
|
|
|
|
setprop("/MCDU[0]/scratchpad", "");
|
|
|
|
} else {
|
|
|
|
setprop("/MCDU[0]/scratchpad", "NOT ALLOWED");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
setprop("/MCDU[0]/scratchpad", "NOT ALLOWED");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (key == "L6") {
|
2017-05-18 18:41:33 +00:00
|
|
|
if (scratchpad == "CLR") {
|
|
|
|
setprop("/FMGC/internal/cruise-ft", 10000);
|
|
|
|
setprop("/FMGC/internal/cruise-fl", 100);
|
|
|
|
setprop("/FMGC/internal/cruise-lvl-set", 0);
|
|
|
|
setprop("/MCDU[0]/scratchpad", "");
|
|
|
|
} else {
|
|
|
|
var crz = int(scratchpad);
|
|
|
|
var crzs = size(scratchpad);
|
|
|
|
if (crzs >= 1 and crzs <= 3) {
|
2017-05-18 20:04:05 +00:00
|
|
|
if (crz > 0 and crz <= 430) {
|
|
|
|
setprop("/FMGC/internal/cruise-ft", crz * 100);
|
|
|
|
setprop("/FMGC/internal/cruise-fl", crz);
|
|
|
|
setprop("/FMGC/internal/cruise-lvl-set", 1);
|
|
|
|
setprop("/MCDU[0]/scratchpad", "");
|
|
|
|
} else {
|
|
|
|
setprop("/MCDU[0]/scratchpad", "NOT ALLOWED");
|
|
|
|
}
|
2017-05-18 18:41:33 +00:00
|
|
|
} else {
|
|
|
|
setprop("/MCDU[0]/scratchpad", "NOT ALLOWED");
|
|
|
|
}
|
|
|
|
}
|
2017-05-18 13:53:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-19 19:20:54 +00:00
|
|
|
var perfCLBInput = func(key) {
|
2017-05-19 13:36:39 +00:00
|
|
|
var scratchpad = getprop("/MCDU[0]/scratchpad");
|
|
|
|
if (key == "L5") {
|
|
|
|
if (scratchpad == "CLR") {
|
|
|
|
setprop("/FMGC/internal/cost-index", 0);
|
|
|
|
setprop("/FMGC/internal/cost-index-set", 0);
|
|
|
|
setprop("/MCDU[0]/scratchpad", "");
|
|
|
|
} else {
|
|
|
|
var ci = int(scratchpad);
|
|
|
|
var cis = size(scratchpad);
|
|
|
|
if (cis >= 1 and cis <= 3) {
|
|
|
|
if (cis >= 0 and cis <= 120) {
|
|
|
|
setprop("/FMGC/internal/cost-index", ci);
|
|
|
|
setprop("/FMGC/internal/cost-index-set", 1);
|
|
|
|
setprop("/MCDU[0]/scratchpad", "");
|
|
|
|
} else {
|
|
|
|
setprop("/MCDU[0]/scratchpad", "NOT ALLOWED");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
setprop("/MCDU[0]/scratchpad", "NOT ALLOWED");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (key == "L6") {
|
|
|
|
setprop("/MCDU[0]/page", "TO");
|
2017-05-19 16:20:08 +00:00
|
|
|
} else if (key == "R6") {
|
|
|
|
setprop("/MCDU[0]/page", "CRZ");
|
2017-05-19 13:36:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var PerfTOInput = func(key) {
|
|
|
|
if (key == "R6") {
|
|
|
|
setprop("/MCDU[0]/page", "CLB");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-19 19:20:54 +00:00
|
|
|
var perfCRZInput = func(key) {
|
2017-05-19 16:20:08 +00:00
|
|
|
if (key == "L6") {
|
|
|
|
setprop("/MCDU[0]/page", "CLB");
|
|
|
|
}
|
|
|
|
# if (key == "R6") {
|
|
|
|
# setprop("/MCDU[0]/page", "DES");
|
|
|
|
# }
|
|
|
|
}
|
|
|
|
|
2017-05-18 18:41:33 +00:00
|
|
|
var rskbutton = func(btn) {
|
2017-05-19 13:36:39 +00:00
|
|
|
if (btn == "6") {
|
|
|
|
if (getprop("/MCDU[0]/page") == "TO") {
|
|
|
|
PerfTOInput("R6");
|
2017-05-19 16:20:08 +00:00
|
|
|
} else if (getprop("/MCDU[0]/page") == "CLB") {
|
2017-05-19 19:20:54 +00:00
|
|
|
perfCLBInput("R6");
|
2017-05-19 16:20:08 +00:00
|
|
|
} # else if (getprop("/MCDU[0]/page") == "CRZ") {
|
2017-05-19 19:20:54 +00:00
|
|
|
# perfCRZInput("R6");
|
2017-05-19 16:20:08 +00:00
|
|
|
#}
|
2017-05-19 13:36:39 +00:00
|
|
|
}
|
2017-05-18 13:53:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var arrowbutton = func(btn) {
|
|
|
|
if (btn == "left") {
|
|
|
|
if (getprop("/MCDU[0]/page") == "DATA") {
|
2017-05-18 22:28:36 +00:00
|
|
|
setprop("/MCDU[0]/page", "DATA2");
|
2017-05-18 13:53:16 +00:00
|
|
|
} else if (getprop("/MCDU[0]/page") == "DATA2") {
|
2017-05-18 22:28:36 +00:00
|
|
|
setprop("/MCDU[0]/page", "DATA");
|
2017-05-18 13:53:16 +00:00
|
|
|
}
|
2017-05-18 18:52:02 +00:00
|
|
|
if (getprop("/MCDU[0]/page") == "INITA") {
|
2017-05-18 22:28:36 +00:00
|
|
|
setprop("/MCDU[0]/page", "INITB");
|
2017-05-18 18:52:02 +00:00
|
|
|
} else if (getprop("/MCDU[0]/page") == "INITB") {
|
2017-05-18 22:28:36 +00:00
|
|
|
setprop("/MCDU[0]/page", "INITA");
|
2017-05-18 18:52:02 +00:00
|
|
|
}
|
2017-05-18 13:53:16 +00:00
|
|
|
} else if (btn == "right") {
|
|
|
|
if (getprop("/MCDU[0]/page") == "DATA") {
|
2017-05-18 22:28:36 +00:00
|
|
|
setprop("/MCDU[0]/page", "DATA2");
|
2017-05-18 13:53:16 +00:00
|
|
|
} else if (getprop("/MCDU[0]/page") == "DATA2") {
|
2017-05-18 22:28:36 +00:00
|
|
|
setprop("/MCDU[0]/page", "DATA");
|
2017-05-18 13:53:16 +00:00
|
|
|
}
|
2017-05-18 18:52:02 +00:00
|
|
|
if (getprop("/MCDU[0]/page") == "INITA") {
|
2017-05-18 22:28:36 +00:00
|
|
|
setprop("/MCDU[0]/page", "INITB");
|
2017-05-18 18:52:02 +00:00
|
|
|
} else if (getprop("/MCDU[0]/page") == "INITB") {
|
2017-05-18 22:28:36 +00:00
|
|
|
setprop("/MCDU[0]/page", "INITA");
|
2017-05-18 18:52:02 +00:00
|
|
|
}
|
2017-05-18 13:53:16 +00:00
|
|
|
} else if (btn == "up") {
|
|
|
|
# Nothing for now
|
|
|
|
} else if (btn == "down") {
|
|
|
|
# Nothing for now
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-15 22:38:20 +00:00
|
|
|
var pagebutton = func(btn) {
|
2017-05-18 13:53:16 +00:00
|
|
|
if (btn == "perf") {
|
|
|
|
if (getprop("/FMGC/status/phase") == 0 or getprop("/FMGC/status/phase") == 1) {
|
2017-05-18 22:28:36 +00:00
|
|
|
setprop("/MCDU[0]/page", "TO");
|
2017-05-18 13:53:16 +00:00
|
|
|
}
|
|
|
|
} else if (btn == "init") {
|
2017-05-18 22:28:36 +00:00
|
|
|
setprop("/MCDU[0]/page", "INITA");
|
2017-05-18 13:53:16 +00:00
|
|
|
} else if (btn == "data") {
|
2017-05-18 22:28:36 +00:00
|
|
|
setprop("/MCDU[0]/page", "DATA");
|
2017-05-15 22:38:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-13 17:08:49 +00:00
|
|
|
var button = func(btn) {
|
|
|
|
var scratchpad = getprop("/MCDU[0]/scratchpad");
|
|
|
|
if (btn == "A") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "A");
|
|
|
|
} else if (btn == "B") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "B");
|
|
|
|
} else if (btn == "C") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "C");
|
|
|
|
} else if (btn == "D") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "D");
|
|
|
|
} else if (btn == "E") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "E");
|
|
|
|
} else if (btn == "F") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "F");
|
|
|
|
} else if (btn == "G") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "G");
|
|
|
|
} else if (btn == "H") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "H");
|
|
|
|
} else if (btn == "I") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "I");
|
|
|
|
} else if (btn == "J") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "J");
|
|
|
|
} else if (btn == "K") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "K");
|
|
|
|
} else if (btn == "L") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "L");
|
|
|
|
} else if (btn == "M") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "M");
|
|
|
|
} else if (btn == "N") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "N");
|
|
|
|
} else if (btn == "O") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "O");
|
|
|
|
} else if (btn == "P") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "P");
|
|
|
|
} else if (btn == "Q") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "Q");
|
|
|
|
} else if (btn == "R") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "R");
|
|
|
|
} else if (btn == "S") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "S");
|
|
|
|
} else if (btn == "T") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "T");
|
|
|
|
} else if (btn == "U") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "U");
|
|
|
|
} else if (btn == "V") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "V");
|
|
|
|
} else if (btn == "W") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "W");
|
|
|
|
} else if (btn == "X") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "X");
|
|
|
|
} else if (btn == "Y") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "Y");
|
|
|
|
} else if (btn == "Z") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "Z");
|
|
|
|
} else if (btn == "SLASH") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "/");
|
|
|
|
} else if (btn == "SP") {
|
2017-05-18 18:41:33 +00:00
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ " ");
|
2017-05-15 22:38:20 +00:00
|
|
|
} else if (btn == "CLR") {
|
|
|
|
var scratchpad = getprop("/MCDU[0]/scratchpad");
|
2017-05-18 18:41:33 +00:00
|
|
|
if (size(scratchpad) == 0) {
|
2017-05-16 11:35:52 +00:00
|
|
|
setprop("/MCDU[0]/scratchpad", "CLR");
|
2017-05-16 14:29:05 +00:00
|
|
|
} else if (scratchpad == "CLR") {
|
2017-05-18 18:41:33 +00:00
|
|
|
setprop("/MCDU[0]/scratchpad", "");
|
|
|
|
} else if (scratchpad == "NOT ALLOWED") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", "");
|
2017-05-16 14:29:05 +00:00
|
|
|
} else if (size(scratchpad) > 0) {
|
|
|
|
setprop("/MCDU[0]/scratchpad", left(scratchpad, size(scratchpad)-1));
|
2017-05-15 22:38:20 +00:00
|
|
|
}
|
2017-05-13 17:08:49 +00:00
|
|
|
} else if (btn == "0") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "0");
|
|
|
|
} else if (btn == "1") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "1");
|
|
|
|
} else if (btn == "2") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "2");
|
|
|
|
} else if (btn == "3") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "3");
|
|
|
|
} else if (btn == "4") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "4");
|
|
|
|
} else if (btn == "5") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "5");
|
|
|
|
} else if (btn == "6") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "6");
|
|
|
|
} else if (btn == "7") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "7");
|
|
|
|
} else if (btn == "8") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "8");
|
|
|
|
} else if (btn == "9") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ "9");
|
|
|
|
} else if (btn == "DOT") {
|
|
|
|
setprop("/MCDU[0]/scratchpad", scratchpad ~ ".");
|
|
|
|
}
|
2017-05-18 18:41:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var screenFlash = func(time) {
|
|
|
|
var page = getprop("/MCDU[0]/page");
|
|
|
|
setprop("/MCDU[0]/page", "NONE");
|
|
|
|
settimer(func {
|
|
|
|
setprop("/MCDU[0]/page", page);
|
|
|
|
}, time);
|
|
|
|
}
|