6import QGroundControl.FactControls
7import QGroundControl.Controls
12 required property var controller
14 property Fact _ch7Opt: controller.getParameterFact(-1, "RC7_OPTION")
15 property Fact _ch8Opt: controller.getParameterFact(-1, "RC8_OPTION")
16 property Fact _ch9Opt: controller.getParameterFact(-1, "RC9_OPTION")
17 property Fact _ch10Opt: controller.getParameterFact(-1, "RC10_OPTION")
18 property Fact _ch11Opt: controller.getParameterFact(-1, "RC11_OPTION")
19 property Fact _ch12Opt: controller.getParameterFact(-1, "RC12_OPTION")
21 readonly property int _firstOptionChannel: 7
22 readonly property int _lastOptionChannel: 12
24 property int _autoTuneSwitchChannelIndex: 0
25 readonly property int _autoTuneOption: 17
27 Component.onCompleted: calcAutoTuneChannel()
29 function calcAutoTuneChannel() {
30 _autoTuneSwitchChannelIndex = 0
31 for (let channel = _firstOptionChannel; channel <= _lastOptionChannel; channel++) {
32 let optionFact = controller.getParameterFact(-1, "RC" + channel + "_OPTION")
33 if (optionFact.value === _autoTuneOption) {
34 _autoTuneSwitchChannelIndex = channel - _firstOptionChannel + 1
40 function setChannelAutoTuneOption(channel) {
41 for (let optionChannel = _firstOptionChannel; optionChannel <= _lastOptionChannel; optionChannel++) {
42 let optionFact = controller.getParameterFact(-1, "RC" + optionChannel + "_OPTION")
43 if (optionFact.value === _autoTuneOption) {
48 let optionFact = controller.getParameterFact(-1, "RC" + channel + "_OPTION")
49 optionFact.value = _autoTuneOption
53 Connections { target: _ch7Opt; function onValueChanged() { calcAutoTuneChannel() } }
54 Connections { target: _ch8Opt; function onValueChanged() { calcAutoTuneChannel() } }
55 Connections { target: _ch9Opt; function onValueChanged() { calcAutoTuneChannel() } }
56 Connections { target: _ch10Opt; function onValueChanged() { calcAutoTuneChannel() } }
57 Connections { target: _ch11Opt; function onValueChanged() { calcAutoTuneChannel() } }
58 Connections { target: _ch12Opt; function onValueChanged() { calcAutoTuneChannel() } }
61 Layout.fillWidth: true
62 comboBoxPreferredWidth: ScreenTools.defaultFontPixelWidth * 30
63 label: qsTr("Channel for AutoTune switch:")
64 model: [qsTr("None"), qsTr("Channel 7"), qsTr("Channel 8"), qsTr("Channel 9"), qsTr("Channel 10"), qsTr("Channel 11"), qsTr("Channel 12")]
65 currentIndex: _autoTuneSwitchChannelIndex
67 onActivated: (index) => {
72 setChannelAutoTuneOption(channel)