QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
MotorComponent.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Dialogs
4
5import QGroundControl
6import QGroundControl.Controls
7
8SetupPage {
9 id: motorPage
10 pageComponent: pageComponent
11
12 property bool userLetterMotorIndices: false
13
14 readonly property int _barHeight: 10
15 readonly property int _barWidth: 5
16 readonly property int _sliderWidth: 15
17 readonly property int _motorTimeoutSecs: 3
18
19 function motorIndexToString(motorIndex) {
20 let asciiA = 65;
21 if (userLetterMotorIndices) {
22 return String.fromCharCode(asciiA + motorIndex);
23 } else {
24 return motorIndex + 1;
25 }
26 }
27
28 FactPanelController {
29 id: controller
30 }
31
32 Component {
33 id: pageComponent
34
35 Column {
36 spacing: ScreenTools.defaultFontPixelHeight
37
38 QGCLabel {
39 text: qsTr("Warning: Unable to determine motor count")
40 color: qgcPal.warningText
41 visible: controller.vehicle.motorCount == -1
42 }
43
44 Row {
45 id: motorSlider
46 enabled: safetySwitch.checked
47 spacing: ScreenTools.defaultFontPixelWidth * 4
48
49 ValueSlider {
50 id: sliderThrottle
51 width: motorButtons.width
52 label: qsTr("Throttle")
53 from: 0
54 to: 100
55 majorTickStepSize: 5
56 decimalPlaces: 0
57 unitsString: qsTr("%")
58 }
59 } // Row
60
61 QGCLabel {
62 anchors.left: parent.left
63 anchors.right: parent.right
64 wrapMode: Text.WordWrap
65 text: qsTr("Make sure you remove all props.")
66 }
67
68 Row {
69 id: motorButtons
70 enabled: safetySwitch.checked
71 spacing: ScreenTools.defaultFontPixelWidth * 4
72
73 Repeater {
74 id: buttonRepeater
75 model: controller.vehicle.motorCount === -1 ? 8 : controller.vehicle.motorCount
76
77 QGCButton {
78 id: button
79 anchors.verticalCenter: parent.verticalCenter
80 text: motorIndexToString(index)
81 onClicked: {
82 controller.vehicle.motorTest(index + 1, sliderThrottle.value, sliderThrottle.value === 0 ? 0 : _motorTimeoutSecs, true)
83 }
84 }
85 } // Repeater
86
87 QGCButton {
88 id: allButton
89 text: qsTr("All")
90 onClicked: {
91 for (var motorIndex=0; motorIndex<buttonRepeater.count; motorIndex++) {
92 controller.vehicle.motorTest(motorIndex + 1, sliderThrottle.value, sliderThrottle.value === 0 ? 0 : _motorTimeoutSecs, true)
93 }
94 }
95 }
96
97 QGCButton {
98 id: allStopButton
99 text: qsTr("Stop")
100 onClicked: {
101 for (var motorIndex=0; motorIndex<buttonRepeater.count; motorIndex++) {
102 controller.vehicle.motorTest(motorIndex + 1, 0, 0, true)
103 }
104 }
105 }
106 } // Row
107
108 Row {
109 spacing: ScreenTools.defaultFontPixelWidth
110
111 Switch {
112 id: safetySwitch
113 onClicked: {
114 if (!checked) {
115 sliderThrottle.setValue(0);
116 }
117 }
118 }
119
120 QGCLabel {
121 anchors.verticalCenter: parent.verticalCenter
122 color: qgcPal.warningText
123 text: safetySwitch.checked ? qsTr("Careful : Motors are enabled") : qsTr("Propellers are removed - Enable slider and motors")
124 }
125 } // Row
126 } // Column
127 } // Component
128} // SetupPage