QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
APMLightsComponentSummary.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Layouts
4
5import QGroundControl
6import QGroundControl.FactControls
7import QGroundControl.Controls
8
9Item {
10 implicitWidth: mainLayout.implicitWidth
11 implicitHeight: mainLayout.implicitHeight
12 width: parent.width // grows when Loader is wider than implicitWidth
13
14 FactPanelController { id: controller; }
15
16 property Fact _rc5Function: controller.getParameterFact(-1, "SERVO5_FUNCTION")
17 property Fact _rc6Function: controller.getParameterFact(-1, "SERVO6_FUNCTION")
18 property Fact _rc7Function: controller.getParameterFact(-1, "SERVO7_FUNCTION")
19 property Fact _rc8Function: controller.getParameterFact(-1, "SERVO8_FUNCTION")
20 property Fact _rc9Function: controller.getParameterFact(-1, "SERVO9_FUNCTION")
21 property Fact _rc10Function: controller.getParameterFact(-1, "SERVO10_FUNCTION")
22 property Fact _rc11Function: controller.getParameterFact(-1, "SERVO11_FUNCTION")
23 property Fact _rc12Function: controller.getParameterFact(-1, "SERVO12_FUNCTION")
24 property Fact _rc13Function: controller.getParameterFact(-1, "SERVO13_FUNCTION")
25 property Fact _rc14Function: controller.getParameterFact(-1, "SERVO14_FUNCTION")
26
27 readonly property int _rcFunctionRCIN9: 59
28 readonly property int _rcFunctionRCIN10: 60
29 readonly property int _firstLightsOutChannel: 5
30 readonly property int _lastLightsOutChannel: 14
31
32 Component.onCompleted: {
33 calcLightOutValues()
34 }
35
36 /// Light output channels are stored in SERVO#_FUNCTION parameters. We need to loop through those
37 /// to find them and setup the ui accordindly.
38 function calcLightOutValues() {
39 lightsLoader.lights1OutIndex = 0
40 lightsLoader.lights2OutIndex = 0
41 for (var channel=_firstLightsOutChannel; channel<=_lastLightsOutChannel; channel++) {
42 var functionFact = controller.getParameterFact(-1, "SERVO" + channel + "_FUNCTION")
43 if (functionFact.value == _rcFunctionRCIN9) {
44 lightsLoader.lights1OutIndex = channel - 4
45 } else if (functionFact.value == _rcFunctionRCIN10) {
46 lightsLoader.lights2OutIndex = channel - 4
47 }
48 }
49 }
50
51 // Whenever any SERVO#_FUNCTION parameters chagnes we need to go looking for light output channels again
52 Connections { target: _rc5Function; onValueChanged: calcLightOutValues() }
53 Connections { target: _rc6Function; onValueChanged: calcLightOutValues() }
54 Connections { target: _rc7Function; onValueChanged: calcLightOutValues() }
55 Connections { target: _rc8Function; onValueChanged: calcLightOutValues() }
56 Connections { target: _rc9Function; onValueChanged: calcLightOutValues() }
57 Connections { target: _rc10Function; onValueChanged: calcLightOutValues() }
58 Connections { target: _rc11Function; onValueChanged: calcLightOutValues() }
59 Connections { target: _rc12Function; onValueChanged: calcLightOutValues() }
60 Connections { target: _rc13Function; onValueChanged: calcLightOutValues() }
61 Connections { target: _rc14Function; onValueChanged: calcLightOutValues() }
62
63 ListModel {
64 id: lightsOutModel
65 ListElement { text: qsTr("Disabled"); value: 0 }
66 ListElement { text: qsTr("Channel 5"); value: 5 }
67 ListElement { text: qsTr("Channel 6"); value: 6 }
68 ListElement { text: qsTr("Channel 7"); value: 7 }
69 ListElement { text: qsTr("Channel 8"); value: 8 }
70 ListElement { text: qsTr("Channel 9"); value: 9 }
71 ListElement { text: qsTr("Channel 10"); value: 10 }
72 ListElement { text: qsTr("Channel 11"); value: 11 }
73 ListElement { text: qsTr("Channel 12"); value: 12 }
74 ListElement { text: qsTr("Channel 13"); value: 13 }
75 ListElement { text: qsTr("Channel 14"); value: 14 }
76 }
77
78 Loader {
79 id: lightsLoader
80
81 property int lights1OutIndex: 0
82 property int lights2OutIndex: 0
83 property int lights1Function: _rcFunctionRCIN9
84 property int lights2Function: _rcFunctionRCIN10
85 }
86
87 ColumnLayout {
88 id: mainLayout
89 spacing: 0
90
91 VehicleSummaryRow {
92 labelText: qsTr("Lights Output 1")
93 valueText: lightsOutModel.get(lightsLoader.lights1OutIndex).text
94 }
95
96 VehicleSummaryRow {
97 labelText: qsTr("Lights Output 2")
98 valueText: lightsOutModel.get(lightsLoader.lights2OutIndex).text
99 }
100 }
101}