QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
APMESCComponent.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
9SetupPage {
10 id: escPage
11 pageComponent: escPageComponent
12
13 FactPanelController {
14 id: controller
15 }
16
17 Component {
18 id: escPageComponent
19
20 ColumnLayout {
21 width: availableWidth
22 spacing: _margins
23
24 // ESC Configuration properties - supports both MOT_* (Copter/Rover/Sub) and Q_M_* (QuadPlane) prefixes
25 property bool _isQuadPlane: !controller.parameterExists(-1, "MOT_PWM_TYPE") && controller.parameterExists(-1, "Q_M_PWM_TYPE")
26 property string _escPrefix: _isQuadPlane ? "Q_M_" : "MOT_"
27
28 property bool _motPwmTypeAvailable: controller.parameterExists(-1, _escPrefix + "PWM_TYPE")
29 property bool _motPwmMinAvailable: controller.parameterExists(-1, _escPrefix + "PWM_MIN")
30 property bool _motPwmMaxAvailable: controller.parameterExists(-1, _escPrefix + "PWM_MAX")
31 property bool _motSpinArmAvailable: controller.parameterExists(-1, _escPrefix + "SPIN_ARM")
32 property bool _motSpinMinAvailable: controller.parameterExists(-1, _escPrefix + "SPIN_MIN")
33 property bool _motSpinMaxAvailable: controller.parameterExists(-1, _escPrefix + "SPIN_MAX")
34 property bool _servoDshotEscAvailable: controller.parameterExists(-1, "SERVO_DSHOT_ESC")
35 property bool _servoDshotRateAvailable: controller.parameterExists(-1, "SERVO_DSHOT_RATE")
36
37 property Fact _motPwmType: controller.getParameterFact(-1, _escPrefix + "PWM_TYPE", false /* reportMissing */)
38 property Fact _motPwmMin: controller.getParameterFact(-1, _escPrefix + "PWM_MIN", false /* reportMissing */)
39 property Fact _motPwmMax: controller.getParameterFact(-1, _escPrefix + "PWM_MAX", false /* reportMissing */)
40 property Fact _motSpinArm: controller.getParameterFact(-1, _escPrefix + "SPIN_ARM", false /* reportMissing */)
41 property Fact _motSpinMin: controller.getParameterFact(-1, _escPrefix + "SPIN_MIN", false /* reportMissing */)
42 property Fact _motSpinMax: controller.getParameterFact(-1, _escPrefix + "SPIN_MAX", false /* reportMissing */)
43 property Fact _servoDshotEsc: controller.getParameterFact(-1, "SERVO_DSHOT_ESC", false /* reportMissing */)
44 property Fact _servoDshotRate: controller.getParameterFact(-1, "SERVO_DSHOT_RATE", false /* reportMissing */)
45
46 property bool _isDshot: _motPwmTypeAvailable && _motPwmType && _motPwmType.rawValue >= 4
47
48 property string _escCalParam: _isQuadPlane ? "Q_ESC_CAL" : "ESC_CALIBRATION"
49 property bool _escCalibrationAvailable: controller.parameterExists(-1, _escCalParam)
50 property Fact _escCalibration: controller.getParameterFact(-1, _escCalParam, false /* reportMissing */)
51
52 property string _restartRequired: qsTr("Requires vehicle reboot")
53 property real _fieldWidth: ScreenTools.defaultFontPixelWidth * 15
54 property real _comboWidth: ScreenTools.defaultFontPixelWidth * 30
55
56 QGCPalette { id: qgcPal; colorGroupEnabled: true }
57
58 QGCGroupBox {
59 Layout.fillWidth: false
60 heading: qsTr("Configuration")
61 visible: _motPwmTypeAvailable
62
63 ColumnLayout {
64 spacing: _margins
65
66 LabelledFactComboBox {
67 label: qsTr("Output type")
68 fact: _motPwmType
69 indexModel: false
70 comboBoxPreferredWidth: _comboWidth
71 }
72
73 QGCLabel {
74 text: _restartRequired
75 font.pointSize: ScreenTools.smallFontPointSize
76 }
77
78 LabelledFactTextField {
79 label: qsTr("Output PWM min")
80 fact: _motPwmMin
81 textFieldPreferredWidth: _fieldWidth
82 visible: _motPwmMinAvailable
83 }
84
85 LabelledFactTextField {
86 label: qsTr("Output PWM max")
87 fact: _motPwmMax
88 textFieldPreferredWidth: _fieldWidth
89 visible: _motPwmMaxAvailable
90 }
91
92 LabelledFactTextField {
93 label: qsTr("Spin when armed")
94 fact: _motSpinArm
95 textFieldPreferredWidth: _fieldWidth
96 visible: _motSpinArmAvailable
97 }
98
99 LabelledFactTextField {
100 label: qsTr("Spin minimum")
101 fact: _motSpinMin
102 textFieldPreferredWidth: _fieldWidth
103 visible: _motSpinMinAvailable
104 }
105
106 LabelledFactTextField {
107 label: qsTr("Spin maximum")
108 fact: _motSpinMax
109 textFieldPreferredWidth: _fieldWidth
110 visible: _motSpinMaxAvailable
111 }
112
113 // DShot settings - visible when a DShot protocol is selected
114 LabelledFactComboBox {
115 label: qsTr("DShot ESC type")
116 fact: _servoDshotEsc
117 indexModel: false
118 comboBoxPreferredWidth: _comboWidth
119 visible: _isDshot && _servoDshotEscAvailable
120 }
121
122 LabelledFactComboBox {
123 label: qsTr("DShot output rate")
124 fact: _servoDshotRate
125 indexModel: false
126 comboBoxPreferredWidth: _comboWidth
127 visible: _isDshot && _servoDshotRateAvailable
128 }
129 }
130 }
131
132 QGCGroupBox {
133 Layout.fillWidth: false
134 heading: qsTr("Calibration")
135 visible: _escCalibrationAvailable
136
137 ColumnLayout {
138 spacing: _margins
139
140 QGCLabel {
141 text: qsTr("WARNING: Remove props prior to calibration!")
142 color: qgcPal.warningText
143 }
144
145 RowLayout {
146 spacing: _margins
147
148 QGCButton {
149 text: qsTr("Calibrate")
150 enabled: _escCalibration && _escCalibration.rawValue === 0
151 onClicked: if(_escCalibration) _escCalibration.rawValue = 3
152 }
153
154 ColumnLayout {
155 enabled: _escCalibration && _escCalibration.rawValue === 3
156 QGCLabel { text: _escCalibration ? (_escCalibration.rawValue === 3 ? qsTr("Now perform these steps:") : qsTr("Click Calibrate to start, then:")) : "" }
157 QGCLabel { text: qsTr("- Disconnect USB and battery so flight controller powers down") }
158 QGCLabel { text: qsTr("- Connect the battery") }
159 QGCLabel { text: qsTr("- The arming tone will be played (if the vehicle has a buzzer attached)") }
160 QGCLabel { text: qsTr("- If using a flight controller with a safety button press it until it displays solid red") }
161 QGCLabel { text: qsTr("- You will hear a musical tone then two beeps") }
162 QGCLabel { text: qsTr("- A few seconds later you should hear a number of beeps (one for each battery cell you're using)") }
163 QGCLabel { text: qsTr("- And finally a single long beep indicating the end points have been set and the ESC is calibrated") }
164 QGCLabel { text: qsTr("- Disconnect the battery and power up again normally") }
165 }
166 }
167 }
168 }
169 } // ColumnLayout
170 } // Component - escPageComponent
171
172} // SetupPage