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 title: qsTr("Configuration")
60 visible: _motPwmTypeAvailable
61
62 ColumnLayout {
63 spacing: _margins
64
65 LabelledFactComboBox {
66 label: qsTr("Output type")
67 fact: _motPwmType
68 indexModel: false
69 comboBoxPreferredWidth: _comboWidth
70 }
71
72 QGCLabel {
73 text: _restartRequired
74 font.pointSize: ScreenTools.smallFontPointSize
75 }
76
77 LabelledFactTextField {
78 label: qsTr("Output PWM min")
79 fact: _motPwmMin
80 textFieldPreferredWidth: _fieldWidth
81 visible: _motPwmMinAvailable
82 }
83
84 LabelledFactTextField {
85 label: qsTr("Output PWM max")
86 fact: _motPwmMax
87 textFieldPreferredWidth: _fieldWidth
88 visible: _motPwmMaxAvailable
89 }
90
91 LabelledFactTextField {
92 label: qsTr("Spin when armed")
93 fact: _motSpinArm
94 textFieldPreferredWidth: _fieldWidth
95 visible: _motSpinArmAvailable
96 }
97
98 LabelledFactTextField {
99 label: qsTr("Spin minimum")
100 fact: _motSpinMin
101 textFieldPreferredWidth: _fieldWidth
102 visible: _motSpinMinAvailable
103 }
104
105 LabelledFactTextField {
106 label: qsTr("Spin maximum")
107 fact: _motSpinMax
108 textFieldPreferredWidth: _fieldWidth
109 visible: _motSpinMaxAvailable
110 }
111
112 // DShot settings - visible when a DShot protocol is selected
113 LabelledFactComboBox {
114 label: qsTr("DShot ESC type")
115 fact: _servoDshotEsc
116 indexModel: false
117 comboBoxPreferredWidth: _comboWidth
118 visible: _isDshot && _servoDshotEscAvailable
119 }
120
121 LabelledFactComboBox {
122 label: qsTr("DShot output rate")
123 fact: _servoDshotRate
124 indexModel: false
125 comboBoxPreferredWidth: _comboWidth
126 visible: _isDshot && _servoDshotRateAvailable
127 }
128 }
129 }
130
131 QGCGroupBox {
132 title: qsTr("Calibration")
133 visible: _escCalibrationAvailable
134
135 ColumnLayout {
136 spacing: _margins
137
138 QGCLabel {
139 text: qsTr("WARNING: Remove props prior to calibration!")
140 color: qgcPal.warningText
141 }
142
143 RowLayout {
144 spacing: _margins
145
146 QGCButton {
147 text: qsTr("Calibrate")
148 enabled: _escCalibration && _escCalibration.rawValue === 0
149 onClicked: if(_escCalibration) _escCalibration.rawValue = 3
150 }
151
152 ColumnLayout {
153 enabled: _escCalibration && _escCalibration.rawValue === 3
154 QGCLabel { text: _escCalibration ? (_escCalibration.rawValue === 3 ? qsTr("Now perform these steps:") : qsTr("Click Calibrate to start, then:")) : "" }
155 QGCLabel { text: qsTr("- Disconnect USB and battery so flight controller powers down") }
156 QGCLabel { text: qsTr("- Connect the battery") }
157 QGCLabel { text: qsTr("- The arming tone will be played (if the vehicle has a buzzer attached)") }
158 QGCLabel { text: qsTr("- If using a flight controller with a safety button press it until it displays solid red") }
159 QGCLabel { text: qsTr("- You will hear a musical tone then two beeps") }
160 QGCLabel { text: qsTr("- A few seconds later you should hear a number of beeps (one for each battery cell you're using)") }
161 QGCLabel { text: qsTr("- And finally a single long beep indicating the end points have been set and the ESC is calibrated") }
162 QGCLabel { text: qsTr("- Disconnect the battery and power up again normally") }
163 }
164 }
165 }
166 }
167 } // ColumnLayout
168 } // Component - escPageComponent
169
170} // SetupPage