Nasal interface: COM, NAV, ADF frequency setters.

parent 1b90c532
......@@ -704,7 +704,7 @@ PrepareNPK = func () {
# @brief Prepare all instruments.
PrepareInstruments = func () {
QNH = math.floor(getprop("/environment/metar/pressure-sea-level-inhg") * 25.4);
QNH = int(getprop("/environment/metar/pressure-sea-level-inhg") * 25.4);
setprop("/sim/crew/orders/altimeter-mmHg", QNH);
SetQNHAll(QNH);
for(var ii = 0; ii < 2; ii += 1){
......@@ -904,6 +904,67 @@ PTT = func(seat, ptt) {
setprop("/fdm/jsbsim/systems/comm/SPU/SPU[0]/panel/button/ptt", ptt);
}
# @brief Set COM frequency
# @param id 0: COM1, 1: COM2
# @param freq frequency, 118.0..135.975 MHz
COM = func(id, freq) {
freq = math.min(math.max(freq, 118.0), 135.975);
freq -= 118.0;
var channel = [0, 0];
channel[0] = math.round(math.mod(freq * 40.0, 40), 1.0);
channel[1] = int(freq);
for(var ich = 0; ich < 2; ich += 1){
setprop("/fdm/jsbsim/systems/comm/Landysh/UKW[" ~ id ~ "]/panel/switch/channel[" ~ ich ~ "]", channel[ich]);
}
}
# @brief Set NAV frequency
# @param id 0: NAV1, 1: NAV2
# @param freq frequency, 108.0..118.0 MHz
NAV = func(id, freq) {
freq = math.min(math.max(freq, 108.0), 118.0);
freq -= 108.0;
var channel = [0, 0];
channel[0] = math.round(math.mod(freq * 20.0, 20), 1.0);
channel[1] = int(freq);
for(var ich = 0; ich < 2; ich += 1){
setprop("/fdm/jsbsim/fcs/NPK/instr/SDK[" ~ id ~ "]/switch/channel[" ~ ich ~ "]", channel[ich]);
}
}
# @brief Set ADF frequency
# @param beacon 0: outer beacon, 1: inner beacon
# @param freq frequency, 150.0..1799.5 kHz
ADF = func(beacon, freq) {
freq = math.min(math.max(freq, 150.0), 1799.5);
freq -= 100.0;
var channel = [0, 0, 0];
channel[0] = math.round(math.mod(freq * 2.0, 20), 1.0);
channel[1] = math.mod(int(freq * 0.1), 10) - 5;
# 0 is after 9 on the dial, not before 1:
if(channel[1] == -5){
channel[1] = 5;
}
channel[2] = int(freq * 0.01);
for(var ich = 0; ich < 3; ich += 1){
setprop("/fdm/jsbsim/fcs/NPK/instr/ARK/switch/channel" ~ beacon ~ "[" ~ ich ~ "]", channel[ich]);
}
}
# @brief Set RSBN channel
# @param ch Channel, 1..88
RSBN = func(ch) {
ch = math.min(math.max(int(ch), 1), 88);
setprop("/fdm/jsbsim/fcs/NPK/instr/RSBN/switch/RSBN-ch", ch);
}
# @brief Set Katet channel
# @param ch Channel, 1..40
Katet = func(ch) {
ch = math.min(math.max(int(ch), 1), 40);
setprop("/fdm/jsbsim/fcs/NPK/instr/RSBN/switch/Katet-ch", ch);
}
# @brief Chocks
Chocks = func (on) {
......@@ -1089,7 +1150,7 @@ var _fgcom_timer = maketimer(0.1, func{
setprop("/controls/radios/comm-radio-selected", select);
_fgcom_select = select;
}
for(var ii = 0; ii < 2; ii += 1){
for(var ii = 0; ii < 2; ii = ii + 1){
var ptt = getprop("/instrumentation/comm[" ~ ii ~ "]/ptt_jsbsim") or 0;
var ptt_diff = ptt - getprop("/instrumentation/comm[" ~ ii ~ "]/ptt");
if(ptt_diff > 0.5){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment