| 1 |
# |
| 2 |
# Helpers for Honeycomb input devices |
| 3 |
# |
| 4 |
|
| 5 |
# namespace |
| 6 |
var honeycomb = {}; |
| 7 |
|
| 8 |
# Helper for the Honeycomb Alpha Yoke |
| 9 |
honeycomb["alpha"] = { |
| 10 |
new: func(cfgnode) { |
| 11 |
var m = { |
| 12 |
parents: [me, input_helpers.config_manager.new(cfgnode)], |
| 13 |
}; |
| 14 |
m.magneto_switch = props.getNode(m.prefix~"/magneto_switch", 1); |
| 15 |
m.magneto_switch.alias("/controls/switches/magnetos"); |
| 16 |
m.starter = props.getNode(m.prefix~"/starter", 1); |
| 17 |
m.starter.alias("/controls/switches/starter"); |
| 18 |
return m; |
| 19 |
}, |
| 20 |
|
| 21 |
setMagnetos: func(value) { |
| 22 |
me.magneto_switch.setIntValue(value); |
| 23 |
props.setAll("/controls/engines/engine", "magnetos", value); |
| 24 |
}, |
| 25 |
|
| 26 |
setStarter: func(value) { |
| 27 |
(value) ? me.starter.setBoolValue(1) : me.starter.setBoolValue(0); |
| 28 |
props.setAll("/controls/engines/engine", "starter", value); |
| 29 |
}, |
| 30 |
|
| 31 |
# handle the hat button on the yoke |
| 32 |
adjustView: func(binding) { |
| 33 |
var delta = 0.2; |
| 34 |
var settingN = binding.getNode("setting", 1); |
| 35 |
var value = settingN.getValue(); |
| 36 |
var timer = maketimer(0.02, me, func(){ |
| 37 |
# 1 = up, 3 = right, 5 = down, 7 = left |
| 38 |
setting = settingN.getValue(); |
| 39 |
if (!setting or setting != value) { |
| 40 |
timer.stop(); |
| 41 |
return; |
| 42 |
} |
| 43 |
if (setting == 1 or setting == 2 or setting == 8) { |
| 44 |
view.panViewPitch(delta); |
| 45 |
} |
| 46 |
if (2 <= setting and setting <= 4) { |
| 47 |
view.panViewDir(-delta); |
| 48 |
} |
| 49 |
if (4 <= setting and setting <= 6) { |
| 50 |
view.panViewPitch(-delta); |
| 51 |
} |
| 52 |
if (6 <= setting and setting <= 8) { |
| 53 |
view.panViewDir(delta); |
| 54 |
} |
| 55 |
}); |
| 56 |
timer.start(); |
| 57 |
}, |
| 58 |
}; |
| 59 |
|
| 60 |
# Helper for the Honeycomb Bravo throttle quadrant |
| 61 |
honeycomb["bravo"] = { |
| 62 |
annunciators: props.getNode("/instrumentation/annunciators/serviceable", 1), |
| 63 |
_target_values: { |
| 64 |
"alt": props.getNode("/autopilot/settings/target-altitude-ft", 1), |
| 65 |
"vs": props.getNode("/autopilot/settings/vertical-speed-fpm", 1), |
| 66 |
"hdg": props.getNode("/autopilot/settings/heading-bug-deg", 1), |
| 67 |
"crs": props.getNode("/instrumentation/nav/radials/selected-deg", 1), |
| 68 |
"ias": props.getNode("/autopilot/settings/target-speed-kt", 1), |
| 69 |
}, |
| 70 |
|
| 71 |
new: func(cfgnode) { |
| 72 |
var m = { |
| 73 |
parents: [me, input_helpers.config_manager.new(cfgnode)], |
| 74 |
}; |
| 75 |
m['_ap_input_selector'] = props.getNode(m.prefix~"/ap-setting-selector", 1); |
| 76 |
m.enableAnnunciators(); |
| 77 |
return m; |
| 78 |
}, |
| 79 |
|
| 80 |
close: func(cfgnode) { |
| 81 |
print("Honeycomb Bravo shutdown"); |
| 82 |
me.disableAnnunciators(); |
| 83 |
me.parents[1].close(cfgnode); |
| 84 |
}, |
| 85 |
|
| 86 |
enableAnnunciators: func() { |
| 87 |
me.annunciators.setValue(1); |
| 88 |
}, |
| 89 |
|
| 90 |
disableAnnunciators: func() { |
| 91 |
me.annunciators.setValue(0); |
| 92 |
}, |
| 93 |
|
| 94 |
setIncDecSelector: func(name) { |
| 95 |
if (contains(me._target_values, name)) |
| 96 |
me._ap_input_selector.setValue(name); |
| 97 |
}, |
| 98 |
|
| 99 |
incAPSetting: func() { |
| 100 |
setting = me._ap_input_selector.getValue(); |
| 101 |
target = me._target_values[setting]; |
| 102 |
if (setting == "ias" ) { |
| 103 |
val = target.add(1, 500); |
| 104 |
gui.popupTip(sprintf("Target airspeed set to: %d kts", val)); |
| 105 |
} |
| 106 |
elsif (setting == "crs" ) { |
| 107 |
val = target.add(1, 360, 360); |
| 108 |
gui.popupTip(sprintf("Selected course: %d deg", val)); |
| 109 |
} |
| 110 |
elsif (setting == "hdg" ) { |
| 111 |
val = target.add(1, 359, 360); |
| 112 |
gui.popupTip(sprintf("Selected heading: %d deg", val)); |
| 113 |
} |
| 114 |
elsif (setting == "vs" ) { |
| 115 |
val = target.add(50, 3000); |
| 116 |
gui.popupTip(sprintf("Target vertical speed set to: %d fpm", val)); |
| 117 |
} |
| 118 |
elsif (setting == "alt" ) { |
| 119 |
val = target.add(100, 50000); |
| 120 |
gui.popupTip(sprintf("Target target altitude set to: %d ft", val)); |
| 121 |
} |
| 122 |
}, |
| 123 |
|
| 124 |
decAPSetting: func() { |
| 125 |
setting = me._ap_input_selector.getValue(); |
| 126 |
target = me._target_values[setting]; |
| 127 |
if (setting == "ias" ) { |
| 128 |
val = target.sub(1, 50); |
| 129 |
gui.popupTip(sprintf("Target airspeed set to: %d kts", val)); |
| 130 |
} |
| 131 |
elsif (setting == "crs" ) { |
| 132 |
val = target.sub(1, 0, 360); |
| 133 |
gui.popupTip(sprintf("Selected course: %d deg", val)); |
| 134 |
} |
| 135 |
elsif (setting == "hdg" ) { |
| 136 |
val = target.sub(1, 0, 360); |
| 137 |
gui.popupTip(sprintf("Selected heading: %d deg", val)); |
| 138 |
} |
| 139 |
elsif (setting == "vs" ) { |
| 140 |
val = target.sub(50, -3000); |
| 141 |
gui.popupTip(sprintf("Target vertical speed set to: %d fpm", val)); |
| 142 |
} |
| 143 |
elsif (setting == "alt" ) { |
| 144 |
val = target.sub(100, 300); |
| 145 |
gui.popupTip(sprintf("Target target altitude set to: %d ft", val)); |
| 146 |
} |
| 147 |
}, |
| 148 |
|
| 149 |
}; |