APMSensorsComponent.qml 38.7 KB
Newer Older
1 2
/****************************************************************************
 *
Gus Grubba's avatar
Gus Grubba committed
3
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 5 6 7 8
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
Don Gagne's avatar
Don Gagne committed
9 10


11 12
import QtQuick                  2.3
import QtQuick.Controls         1.2
13
import QtQuick.Controls.Styles  1.4
14
import QtQuick.Dialogs          1.2
15
import QtQuick.Layouts          1.2
16

17
import QGroundControl               1.0
18 19 20 21 22 23
import QGroundControl.FactSystem    1.0
import QGroundControl.FactControls  1.0
import QGroundControl.Palette       1.0
import QGroundControl.Controls      1.0
import QGroundControl.ScreenTools   1.0
import QGroundControl.Controllers   1.0
24
import QGroundControl.ArduPilot     1.0
25 26 27 28

SetupPage {
    id:             sensorsPage
    pageComponent:  sensorsPageComponent
Don Gagne's avatar
Don Gagne committed
29

Don Gagne's avatar
Don Gagne committed
30
    Component {
31 32
        id:             sensorsPageComponent

33 34 35
        Item {
            width:  availableWidth
            height: availableHeight
36 37 38 39

            // Help text which is shown both in the status text area prior to pressing a cal button and in the
            // pre-calibration dialog.

40 41
            readonly property string orientationHelpSet:    qsTr("If mounted in the direction of flight, select None.")
            readonly property string orientationHelpCal:    qsTr("Before calibrating make sure rotation settings are correct. ") + orientationHelpSet
42
            readonly property string compassRotationText:   qsTr("If the compass or GPS module is mounted in flight direction, leave the default value (None)")
43

44 45 46 47
            readonly property string compassHelp:   qsTr("For Compass calibration you will need to rotate your vehicle through a number of positions.")
            readonly property string gyroHelp:      qsTr("For Gyroscope calibration you will need to place your vehicle on a surface and leave it still.")
            readonly property string accelHelp:     qsTr("For Accelerometer calibration you will need to place your vehicle on all six sides on a perfectly level surface and hold it still in each orientation for a few seconds.")
            readonly property string levelHelp:     qsTr("To level the horizon you need to place the vehicle in its level flight position and press OK.")
48

49
            readonly property string statusTextAreaDefaultText: qsTr("Start the individual calibration steps by clicking one of the buttons to the left.")
50 51 52 53 54 55 56

            // Used to pass help text to the preCalibrationDialog dialog
            property string preCalibrationDialogHelp

            property string _postCalibrationDialogText
            property var    _postCalibrationDialogParams

57 58
            readonly property string _badCompassCalText: qsTr("The calibration for Compass %1 appears to be poor. ") +
                                                         qsTr("Check the compass position within your vehicle and re-do the calibration.")
59 60 61 62 63 64

            readonly property int sideBarH1PointSize:  ScreenTools.mediumFontPointSize
            readonly property int mainTextH1PointSize: ScreenTools.mediumFontPointSize // Seems to be unused

            readonly property int rotationColumnWidth: 250

65
            property Fact noFact: Fact { }
66

67 68
            property bool accelCalNeeded:                   controller.accelSetupNeeded
            property bool compassCalNeeded:                 controller.compassSetupNeeded
69

70
            property Fact boardRot:                         controller.getParameterFact(-1, "AHRS_ORIENTATION")
71 72 73 74

            readonly property int _calTypeCompass:  1   ///< Calibrate compass
            readonly property int _calTypeAccel:    2   ///< Calibrate accel
            readonly property int _calTypeSet:      3   ///< Set orientations only
75
            readonly property int _buttonWidth:     ScreenTools.defaultFontPixelWidth * 15
76 77 78 79

            property bool   _orientationsDialogShowCompass: true
            property string _orientationDialogHelp:         orientationHelpSet
            property int    _orientationDialogCalType
80
            property real   _margins:                       ScreenTools.defaultFontPixelHeight / 2
81 82 83
            property bool   _compassAutoRotAvailable:       controller.parameterExists(-1, "COMPASS_AUTO_ROT")
            property Fact   _compassAutoRotFact:            controller.getParameterFact(-1, "COMPASS_AUTO_ROT", false /* reportMissing */)
            property bool   _compassAutoRot:                _compassAutoRotAvailable ? _compassAutoRotFact.rawValue == 2 : false
84 85 86 87 88 89 90 91 92 93

            function showOrientationsDialog(calType) {
                var dialogTitle
                var buttons = StandardButton.Ok

                _orientationDialogCalType = calType
                switch (calType) {
                case _calTypeCompass:
                    _orientationsDialogShowCompass = true
                    _orientationDialogHelp = orientationHelpCal
94
                    _singleCompassSettingsComponentShowPriority = false
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
                    dialogTitle = qsTr("Calibrate Compass")
                    buttons |= StandardButton.Cancel
                    break
                case _calTypeAccel:
                    _orientationsDialogShowCompass = false
                    _orientationDialogHelp = orientationHelpCal
                    dialogTitle = qsTr("Calibrate Accelerometer")
                    buttons |= StandardButton.Cancel
                    break
                case _calTypeSet:
                    _orientationsDialogShowCompass = true
                    _orientationDialogHelp = orientationHelpSet
                    dialogTitle = qsTr("Sensor Settings")
                    break
                }
Don Gagne's avatar
Don Gagne committed
110

111
                mainWindow.showComponentDialog(orientationsDialogComponent, dialogTitle, mainWindow.showDialogDefaultWidth, buttons)
112
            }
Don Gagne's avatar
Don Gagne committed
113

114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
            function compassLabel(index) {
                var label = qsTr("Compass %1 ").arg(index+1)
                var addOpenParan = true
                var addComma = false
                if (sensorParams.compassPrimaryFactAvailable) {
                    label += sensorParams.rgCompassPrimary[index] ? qsTr("(primary") : qsTr("(secondary")
                    addComma = true
                    addOpenParan = false
                }
                if (sensorParams.rgCompassExternalParamAvailable[index]) {
                    if (addOpenParan) {
                        label += "("
                    }
                    if (addComma) {
                        label += qsTr(", ")
                    }
                    label += sensorParams.rgCompassExternal[index] ? qsTr("external") : qsTr("internal")
                }
                label += ")"
                return label
            }

136 137 138 139 140
            APMSensorParams {
                id:                     sensorParams
                factPanelController:    controller
            }

141 142 143 144 145 146 147 148
            APMSensorsComponentController {
                id:                         controller
                statusLog:                  statusTextArea
                progressBar:                progressBar
                nextButton:                 nextButton
                cancelButton:               cancelButton
                orientationCalAreaHelpText: orientationCalAreaHelpText

149 150
                property var rgCompassCalFitness: [ controller.compass1CalFitness, controller.compass2CalFitness, controller.compass3CalFitness ]

151 152 153 154
                onResetStatusTextArea: statusLog.text = statusTextAreaDefaultText

                onWaitingForCancelChanged: {
                    if (controller.waitingForCancel) {
155
                        mainWindow.showComponentDialog(waitForCancelDialogComponent, qsTr("Calibration Cancel"), mainWindow.showDialogDefaultWidth, 0)
156 157
                    }
                }
Don Gagne's avatar
Don Gagne committed
158

159
                onCalibrationComplete: {
160 161
                    switch (calType) {
                    case APMSensorsComponentController.CalTypeAccel:
162
                        mainWindow.showComponentDialog(postCalibrationComponent, qsTr("Accelerometer calibration complete"), mainWindow.showDialogDefaultWidth, StandardButton.Ok)
163 164
                        break
                    case APMSensorsComponentController.CalTypeOffboardCompass:
165
                        mainWindow.showComponentDialog(postCalibrationComponent, qsTr("Compass calibration complete"), mainWindow.showDialogDefaultWidth, StandardButton.Ok)
166 167
                        break
                    case APMSensorsComponentController.CalTypeOnboardCompass:
168
                        _singleCompassSettingsComponentShowPriority = true
169
                        mainWindow.showComponentDialog(postOnboardCompassCalibrationComponent, qsTr("Calibration complete"), mainWindow.showDialogDefaultWidth, StandardButton.Ok)
170
                        break
Don Gagne's avatar
Don Gagne committed
171 172
                    }
                }
173 174 175 176

                onSetAllCalButtonsEnabled: {
                    buttonColumn.enabled = enabled
                }
Don Gagne's avatar
Don Gagne committed
177 178
            }

179 180
            Component.onCompleted: {
                var usingUDP = controller.usingUDPLink()
181 182
                var isSub = QGroundControl.multiVehicleManager.activeVehicle.sub;
                if (usingUDP && !isSub) {
183
                    mainWindow.showMessageDialog(qsTr("Sensor Calibration"), qsTr("Performing sensor calibration over a WiFi connection can be unreliable. If you run into problems try using a direct USB connection instead."))
Don Gagne's avatar
Don Gagne committed
184
                }
185
            }
Don Gagne's avatar
Don Gagne committed
186

187
            QGCPalette { id: qgcPal; colorGroupEnabled: true }
Don Gagne's avatar
Don Gagne committed
188

189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
            Component {
                id: waitForCancelDialogComponent

                QGCViewMessage {
                    message: qsTr("Waiting for Vehicle to response to Cancel. This may take a few seconds.")

                    Connections {
                        target: controller

                        onWaitingForCancelChanged: {
                            if (!controller.waitingForCancel) {
                                hideDialog()
                            }
                        }
                    }
                }
            }

207
            Component {
208
                id: singleCompassOnboardResultsComponent
Don Gagne's avatar
Don Gagne committed
209

210 211 212 213
                Column {
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    spacing:        Math.round(ScreenTools.defaultFontPixelHeight / 2)
214
                    visible:        sensorParams.rgCompassAvailable[index] && sensorParams.rgCompassUseFact[index].value
215

216 217
                    property int _index: index

218 219 220 221 222
                    property real greenMaxThreshold:   8 * (sensorParams.rgCompassExternal[index] ? 1 : 2)
                    property real yellowMaxThreshold:  15 * (sensorParams.rgCompassExternal[index] ? 1 : 2)
                    property real fitnessRange:        25 * (sensorParams.rgCompassExternal[index] ? 1 : 2)

                    Item {
223 224
                        anchors.left:   parent.left
                        anchors.right:  parent.right
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
                        height:         ScreenTools.defaultFontPixelHeight

                        Row {
                            id:             fitnessRow
                            anchors.fill:   parent

                            Rectangle {
                                width:  parent.width * (greenMaxThreshold / fitnessRange)
                                height: parent.height
                                color:  "green"
                            }
                            Rectangle {
                                width:  parent.width * ((yellowMaxThreshold - greenMaxThreshold) / fitnessRange)
                                height: parent.height
                                color:  "yellow"
                            }
                            Rectangle {
                                width:  parent.width * ((fitnessRange - yellowMaxThreshold) / fitnessRange)
                                height: parent.height
                                color:  "red"
                            }
                        }

                        Rectangle {
                            height:                 fitnessRow.height * 0.66
                            width:                  height
                            anchors.verticalCenter: fitnessRow.verticalCenter
                            x:                      (fitnessRow.width * (Math.min(Math.max(controller.rgCompassCalFitness[index], 0.0), fitnessRange) / fitnessRange)) - (width / 2)
                            radius:                 height / 2
                            color:                  "white"
                            border.color:           "black"
                        }
Don Gagne's avatar
Don Gagne committed
257
                    }
Don Gagne's avatar
Don Gagne committed
258

259
                    Loader {
260 261 262
                        anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2
                        anchors.left:       parent.left
                        anchors.right:      parent.right
263
                        sourceComponent:    singleCompassSettingsComponent
264

265
                        property int index: _index
Don Gagne's avatar
Don Gagne committed
266
                    }
267 268
                }
            }
Don Gagne's avatar
Don Gagne committed
269

270 271
            Component {
                id: postOnboardCompassCalibrationComponent
272

273 274 275 276 277 278 279 280 281 282 283
                QGCViewDialog {
                    Column {
                        anchors.margins:    ScreenTools.defaultFontPixelWidth
                        anchors.left:       parent.left
                        anchors.right:      parent.right
                        spacing:            ScreenTools.defaultFontPixelHeight

                        Repeater {
                            model:      3
                            delegate:   singleCompassOnboardResultsComponent
                        }
284

285 286 287 288 289 290 291 292 293 294
                        QGCLabel {
                            anchors.left:   parent.left
                            anchors.right:  parent.right
                            wrapMode:       Text.WordWrap
                            text:           qsTr("Shown in the indicator bars is the quality of the calibration for each compass.\n\n") +
                                            qsTr("- Green indicates a well functioning compass.\n") +
                                            qsTr("- Yellow indicates a questionable compass or calibration.\n") +
                                            qsTr("- Red indicates a compass which should not be used.\n\n") +
                                            qsTr("YOU MUST REBOOT YOUR VEHICLE AFTER EACH CALIBRATION.")
                        }
295 296 297

                        QGCButton {
                            text:       qsTr("Reboot Vehicle")
298 299 300 301
                            onClicked: {
                                controller.vehicle.rebootVehicle()
                                hideDialog()
                            }
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325
                        }
                    }
                }
            }

            Component {
                id: postCalibrationComponent

                QGCViewDialog {
                    Column {
                        anchors.margins:    ScreenTools.defaultFontPixelWidth
                        anchors.left:       parent.left
                        anchors.right:      parent.right
                        spacing:            ScreenTools.defaultFontPixelHeight

                        QGCLabel {
                            anchors.left:   parent.left
                            anchors.right:  parent.right
                            wrapMode:       Text.WordWrap
                            text:           qsTr("YOU MUST REBOOT YOUR VEHICLE AFTER EACH CALIBRATION.")
                        }

                        QGCButton {
                            text:       qsTr("Reboot Vehicle")
326 327 328 329
                            onClicked: {
                                controller.vehicle.rebootVehicle()
                                hideDialog()
                            }
330
                        }
331 332 333
                    }
                }
            }
334

335
            property bool _singleCompassSettingsComponentShowPriority: true
336 337
            Component {
                id: singleCompassSettingsComponent
338

339 340 341 342 343
                Column {
                    spacing: Math.round(ScreenTools.defaultFontPixelHeight / 2)
                    visible: sensorParams.rgCompassAvailable[index]

                    QGCLabel {
344
                        text: compassLabel(index)
345 346 347 348 349 350 351
                    }

                    Column {
                        anchors.margins:    ScreenTools.defaultFontPixelWidth * 2
                        anchors.left:       parent.left
                        spacing:            Math.round(ScreenTools.defaultFontPixelHeight / 4)

352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391
                        RowLayout {
                            spacing: ScreenTools.defaultFontPixelWidth

                            FactCheckBox {
                                id:         useCompassCheckBox
                                text:       qsTr("Use Compass")
                                fact:       sensorParams.rgCompassUseFact[index]
                                visible:    sensorParams.rgCompassUseParamAvailable[index] && !sensorParams.rgCompassPrimary[index]
                            }

                            QGCComboBox {
                                model:      [ qsTr("Priority 1"), qsTr("Priority 2"), qsTr("Priority 3"), qsTr("Not Set") ]
                                visible:    _singleCompassSettingsComponentShowPriority && sensorParams.compassPrioFactsAvailable && useCompassCheckBox.visible && useCompassCheckBox.checked

                                property int _compassIndex: index

                                function selectPriorityfromParams() {
                                    if (visible) {
                                        currentIndex = 3
                                        var compassId = sensorParams.rgCompassId[_compassIndex].rawValue
                                        for (var prioIndex=0; prioIndex<3; prioIndex++) {
                                            if (compassId == sensorParams.rgCompassPrio[prioIndex].rawValue) {
                                                currentIndex = prioIndex
                                                break
                                            }
                                        }
                                    }
                                }

                                Component.onCompleted: selectPriorityfromParams()

                                onActivated: {
                                    if (index == 3) {
                                        // User cannot select Not Set
                                        selectPriorityfromParams()
                                    } else {
                                        sensorParams.rgCompassPrio[index].rawValue = sensorParams.rgCompassId[_compassIndex].rawValue
                                    }
                                }
                            }
392 393 394
                        }

                        Column {
395
                            visible: !_compassAutoRot && sensorParams.rgCompassExternal[index] && sensorParams.rgCompassRotParamAvailable[index]
396 397 398 399 400 401 402

                            QGCLabel { text: qsTr("Orientation:") }

                            FactComboBox {
                                width:      rotationColumnWidth
                                indexModel: false
                                fact:       sensorParams.rgCompassRotFact[index]
Don Gagne's avatar
Don Gagne committed
403 404 405
                            }
                        }
                    }
406 407
                }
            }
408

409 410
            Component {
                id: orientationsDialogComponent
411

412 413 414 415 416 417 418 419
                QGCViewDialog {
                    id: orientationsDialog

                    function accept() {
                        if (_orientationDialogCalType == _calTypeAccel) {
                            controller.calibrateAccel()
                        } else if (_orientationDialogCalType == _calTypeCompass) {
                            controller.calibrateCompass()
420
                        }
421 422 423 424 425 426 427
                        orientationsDialog.hideDialog()
                    }

                    QGCFlickable {
                        anchors.fill:   parent
                        contentHeight:  columnLayout.height
                        clip:           true
428

429
                        Column {
430 431 432 433 434 435
                            id:                 columnLayout
                            anchors.margins:    ScreenTools.defaultFontPixelWidth
                            anchors.left:       parent.left
                            anchors.right:      parent.right
                            anchors.top:        parent.top
                            spacing:            ScreenTools.defaultFontPixelHeight
Don Gagne's avatar
Don Gagne committed
436 437

                            QGCLabel {
438 439 440
                                width:      parent.width
                                wrapMode:   Text.WordWrap
                                text:       _orientationDialogHelp
Don Gagne's avatar
Don Gagne committed
441 442
                            }

443
                            Column {
444
                                QGCLabel { text: qsTr("Autopilot Rotation:") }
445 446 447 448 449 450

                                FactComboBox {
                                    width:      rotationColumnWidth
                                    indexModel: false
                                    fact:       boardRot
                                }
Don Gagne's avatar
Don Gagne committed
451 452
                            }

453 454 455
                            Repeater {
                                model:      _orientationsDialogShowCompass ? 3 : 0
                                delegate:   singleCompassSettingsComponent
456 457 458 459 460
                            }
                        } // Column
                    } // QGCFlickable
                } // QGCViewDialog
            } // Component - orientationsDialogComponent
461

462 463
            Component {
                id: compassMotDialogComponent
464

465 466
                QGCViewDialog {
                    id: compassMotDialog
467

468 469 470
                    function accept() {
                        controller.calibrateMotorInterference()
                        compassMotDialog.hideDialog()
471 472
                    }

473 474 475 476
                    QGCFlickable {
                        anchors.fill:   parent
                        contentHeight:  columnLayout.height
                        clip:           true
477

478 479 480 481 482 483 484
                        Column {
                            id:                 columnLayout
                            anchors.margins:    ScreenTools.defaultFontPixelWidth
                            anchors.left:       parent.left
                            anchors.right:      parent.right
                            anchors.top:        parent.top
                            spacing:            ScreenTools.defaultFontPixelHeight
485

486 487 488 489
                            QGCLabel {
                                anchors.left:   parent.left
                                anchors.right:  parent.right
                                wrapMode:       Text.WordWrap
490 491 492
                                text:           qsTr("This is recommended for vehicles that have only an internal compass and on vehicles where there is significant interference on the compass from the motors, power wires, etc. ") +
                                                qsTr("CompassMot only works well if you have a battery current monitor because the magnetic interference is linear with current drawn. ") +
                                                qsTr("It is technically possible to set-up CompassMot using throttle but this is not recommended.")
493
                            }
Don Gagne's avatar
Don Gagne committed
494

495 496 497 498
                            QGCLabel {
                                anchors.left:   parent.left
                                anchors.right:  parent.right
                                wrapMode:       Text.WordWrap
499 500
                                text:           qsTr("Disconnect your props, flip them over and rotate them one position around the frame. ") +
                                                qsTr("In this configuration they should push the copter down into the ground when the throttle is raised.")
501
                            }
Don Gagne's avatar
Don Gagne committed
502

503 504 505 506
                            QGCLabel {
                                anchors.left:   parent.left
                                anchors.right:  parent.right
                                wrapMode:       Text.WordWrap
507
                                text:           qsTr("Secure the copter (perhaps with tape) so that it does not move.")
508
                            }
Don Gagne's avatar
Don Gagne committed
509

510 511 512 513
                            QGCLabel {
                                anchors.left:   parent.left
                                anchors.right:  parent.right
                                wrapMode:       Text.WordWrap
514
                                text:           qsTr("Turn on your transmitter and keep throttle at zero.")
515
                            }
Don Gagne's avatar
Don Gagne committed
516

517 518 519 520
                            QGCLabel {
                                anchors.left:   parent.left
                                anchors.right:  parent.right
                                wrapMode:       Text.WordWrap
521
                                text:           qsTr("Click Ok to start CompassMot calibration.")
522 523 524 525 526
                            }
                        } // Column
                    } // QGCFlickable
                } // QGCViewDialog
            } // Component - compassMotDialogComponent
Don Gagne's avatar
Don Gagne committed
527

Don Gagne's avatar
Don Gagne committed
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547
            Component {
                id: levelHorizonDialogComponent

                QGCViewDialog {
                    id: levelHorizonDialog

                    function accept() {
                        controller.levelHorizon()
                        levelHorizonDialog.hideDialog()
                    }

                    QGCLabel {
                        anchors.left:   parent.left
                        anchors.right:  parent.right
                        wrapMode:       Text.WordWrap
                        text:           qsTr("To level the horizon you need to place the vehicle in its level flight position and press Ok.")
                    }
                } // QGCViewDialog
            } // Component - levelHorizonDialogComponent

548 549 550 551 552 553 554 555 556 557 558 559 560 561 562
            Component {
                id: calibratePressureDialogComponent

                QGCViewDialog {
                    id: calibratePressureDialog

                    function accept() {
                        controller.calibratePressure()
                        calibratePressureDialog.hideDialog()
                    }

                    QGCLabel {
                        anchors.left:   parent.left
                        anchors.right:  parent.right
                        wrapMode:       Text.WordWrap
563 564
                        text:           _helpText

565
                        readonly property string _altText:      activeVehicle.sub ? qsTr("depth") : qsTr("altitude")
566
                        readonly property string _helpText:     qsTr("Pressure calibration will set the %1 to zero at the current pressure reading. %2").arg(_altText).arg(_helpTextFW)
567
                        readonly property string _helpTextFW:   activeVehicle.fixedWing ? qsTr("To calibrate the airspeed sensor shield it from the wind. Do not touch the sensor or obstruct any holes during the calibration.") : ""
568 569 570 571
                    }
                } // QGCViewDialog
            } // Component - calibratePressureDialogComponent

572 573 574 575 576 577 578
            QGCFlickable {
                id:             buttonFlickable
                anchors.left:   parent.left
                anchors.top:    parent.top
                anchors.bottom: parent.bottom
                width:          _buttonWidth
                contentHeight:  nextCancelColumn.y + nextCancelColumn.height + _margins
Don Gagne's avatar
Don Gagne committed
579

580 581 582 583 584 585
                // Calibration button column - Calibratin buttons are kept in a separate column from Next/Cancel buttons
                // so we can enable/disable them all as a group
                Column {
                    id:                 buttonColumn
                    spacing:            _margins
                    Layout.alignment:   Qt.AlignLeft | Qt.AlignTop
586

587 588 589 590
                    IndicatorButton {
                        width:          _buttonWidth
                        text:           qsTr("Accelerometer")
                        indicatorGreen: !accelCalNeeded
591

592 593 594 595 596 597 598
                        onClicked: showOrientationsDialog(_calTypeAccel)
                    }

                    IndicatorButton {
                        width:          _buttonWidth
                        text:           qsTr("Compass")
                        indicatorGreen: !compassCalNeeded
599

600 601
                        onClicked: {
                            if (controller.accelSetupNeeded) {
602
                                mainWindow.showMessageDialog(qsTr("Calibrate Compass"), qsTr("Accelerometer must be calibrated prior to Compass."))
603 604 605
                            } else {
                                showOrientationsDialog(_calTypeCompass)
                            }
606
                        }
Don Gagne's avatar
Don Gagne committed
607 608
                    }

609 610 611
                    QGCButton {
                        width:  _buttonWidth
                        text:   _levelHorizonText
Don Gagne's avatar
Don Gagne committed
612

613
                        readonly property string _levelHorizonText: qsTr("Level Horizon")
Don Gagne's avatar
Don Gagne committed
614

615 616
                        onClicked: {
                            if (controller.accelSetupNeeded) {
617
                                mainWindow.showMessageDialog(_levelHorizonText, qsTr("Accelerometer must be calibrated prior to Level Horizon."))
618
                            } else {
619
                                mainWindow.showComponentDialog(levelHorizonDialogComponent, _levelHorizonText, mainWindow.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok)
620
                            }
Don Gagne's avatar
Don Gagne committed
621 622 623
                        }
                    }

624 625 626
                    QGCButton {
                        width:      _buttonWidth
                        text:       _calibratePressureText
627
                        onClicked:  mainWindow.showComponentDialog(calibratePressureDialogComponent, _calibratePressureText, mainWindow.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok)
628

629
                        readonly property string _calibratePressureText: activeVehicle.fixedWing ? qsTr("Cal Baro/Airspeed") : qsTr("Calibrate Pressure")
630
                    }
631

632 633 634
                    QGCButton {
                        width:      _buttonWidth
                        text:       qsTr("CompassMot")
635
                        visible:    activeVehicle ? activeVehicle.supportsMotorInterference : false
636

637
                        onClicked:  mainWindow.showComponentDialog(compassMotDialogComponent, qsTr("CompassMot - Compass Motor Interference Calibration"), mainWindow.showDialogFullWidth, StandardButton.Cancel | StandardButton.Ok)
638
                    }
639

640 641 642 643 644 645
                    QGCButton {
                        width:      _buttonWidth
                        text:       qsTr("Sensor Settings")
                        onClicked:  showOrientationsDialog(_calTypeSet)
                    }
                } // Column - Cal Buttons
Don Gagne's avatar
Don Gagne committed
646

647 648 649 650 651 652 653 654 655 656 657 658 659 660
                Column {
                    id:                 nextCancelColumn
                    anchors.topMargin:  buttonColumn.spacing
                    anchors.top:        buttonColumn.bottom
                    anchors.left:       buttonColumn.left
                    spacing:            buttonColumn.spacing

                    QGCButton {
                        id:         nextButton
                        width:      _buttonWidth
                        text:       qsTr("Next")
                        enabled:    false
                        onClicked:  controller.nextClicked()
                    }
Don Gagne's avatar
Don Gagne committed
661

662 663 664 665 666 667 668
                    QGCButton {
                        id:         cancelButton
                        width:      _buttonWidth
                        text:       qsTr("Cancel")
                        enabled:    false
                        onClicked:  controller.cancelCalibration()
                    }
669
                }
670
            } // QGCFlickable - buttons
Don Gagne's avatar
Don Gagne committed
671

672
            /// Right column - cal area
673
            Column {
674
                anchors.leftMargin: _margins
675 676
                anchors.top:        parent.top
                anchors.bottom:     parent.bottom
677 678
                anchors.left:       buttonFlickable.right
                anchors.right:      parent.right
Don Gagne's avatar
Don Gagne committed
679

680 681 682 683 684
                ProgressBar {
                    id:             progressBar
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                }
Don Gagne's avatar
Don Gagne committed
685

686
                Item { height: ScreenTools.defaultFontPixelHeight; width: 10 } // spacer
Don Gagne's avatar
Don Gagne committed
687

688 689 690 691
                Item {
                    id:     centerPanel
                    width:  parent.width
                    height: parent.height - y
Don Gagne's avatar
Don Gagne committed
692

693 694 695 696 697 698
                    TextArea {
                        id:             statusTextArea
                        anchors.fill:   parent
                        readOnly:       true
                        frameVisible:   false
                        text:           statusTextAreaDefaultText
Don Gagne's avatar
Don Gagne committed
699

700 701 702 703
                        style: TextAreaStyle {
                            textColor:          qgcPal.text
                            backgroundColor:    qgcPal.windowShade
                        }
Don Gagne's avatar
Don Gagne committed
704
                    }
Don Gagne's avatar
Don Gagne committed
705

706 707 708 709 710 711 712 713 714 715 716 717 718 719
                    Rectangle {
                        id:             orientationCalArea
                        anchors.fill:   parent
                        visible:        controller.showOrientationCalArea
                        color:          qgcPal.windowShade

                        QGCLabel {
                            id:                 orientationCalAreaHelpText
                            anchors.margins:    ScreenTools.defaultFontPixelWidth
                            anchors.top:        orientationCalArea.top
                            anchors.left:       orientationCalArea.left
                            width:              parent.width
                            wrapMode:           Text.WordWrap
                            font.pointSize:     ScreenTools.mediumFontPointSize
Don Gagne's avatar
Don Gagne committed
720
                        }
721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739

                        Flow {
                            anchors.topMargin:  ScreenTools.defaultFontPixelWidth
                            anchors.top:        orientationCalAreaHelpText.bottom
                            anchors.bottom:     parent.bottom
                            anchors.left:       parent.left
                            anchors.right:      parent.right
                            spacing:            ScreenTools.defaultFontPixelWidth

                            property real indicatorWidth:   (width / 3) - (spacing * 2)
                            property real indicatorHeight:  (height / 2) - spacing

                            VehicleRotationCal {
                                width:              parent.indicatorWidth
                                height:             parent.indicatorHeight
                                visible:            controller.orientationCalDownSideVisible
                                calValid:           controller.orientationCalDownSideDone
                                calInProgress:      controller.orientationCalDownSideInProgress
                                calInProgressText:  controller.orientationCalDownSideRotate ? qsTr("Rotate") : qsTr("Hold Still")
DonLakeFlyer's avatar
DonLakeFlyer committed
740
                                imageSource:        "qrc:///qmlimages/VehicleDown.png"
741 742 743 744
                            }
                            VehicleRotationCal {
                                width:              parent.indicatorWidth
                                height:             parent.indicatorHeight
DonLakeFlyer's avatar
DonLakeFlyer committed
745 746 747 748 749 750 751 752 753 754 755 756 757 758
                                visible:            controller.orientationCalLeftSideVisible
                                calValid:           controller.orientationCalLeftSideDone
                                calInProgress:      controller.orientationCalLeftSideInProgress
                                calInProgressText:  controller.orientationCalLeftSideRotate ? qsTr("Rotate") : qsTr("Hold Still")
                                imageSource:        "qrc:///qmlimages/VehicleLeft.png"
                            }
                            VehicleRotationCal {
                                width:              parent.indicatorWidth
                                height:             parent.indicatorHeight
                                visible:            controller.orientationCalRightSideVisible
                                calValid:           controller.orientationCalRightSideDone
                                calInProgress:      controller.orientationCalRightSideInProgress
                                calInProgressText:  controller.orientationCalRightSideRotate ? qsTr("Rotate") : qsTr("Hold Still")
                                imageSource:        "qrc:///qmlimages/VehicleRight.png"
759 760 761 762 763 764 765 766
                            }
                            VehicleRotationCal {
                                width:              parent.indicatorWidth
                                height:             parent.indicatorHeight
                                visible:            controller.orientationCalNoseDownSideVisible
                                calValid:           controller.orientationCalNoseDownSideDone
                                calInProgress:      controller.orientationCalNoseDownSideInProgress
                                calInProgressText:  controller.orientationCalNoseDownSideRotate ? qsTr("Rotate") : qsTr("Hold Still")
DonLakeFlyer's avatar
DonLakeFlyer committed
767
                                imageSource:        "qrc:///qmlimages/VehicleNoseDown.png"
768 769 770 771 772 773 774 775
                            }
                            VehicleRotationCal {
                                width:              parent.indicatorWidth
                                height:             parent.indicatorHeight
                                visible:            controller.orientationCalTailDownSideVisible
                                calValid:           controller.orientationCalTailDownSideDone
                                calInProgress:      controller.orientationCalTailDownSideInProgress
                                calInProgressText:  controller.orientationCalTailDownSideRotate ? qsTr("Rotate") : qsTr("Hold Still")
DonLakeFlyer's avatar
DonLakeFlyer committed
776
                                imageSource:        "qrc:///qmlimages/VehicleTailDown.png"
777 778 779 780
                            }
                            VehicleRotationCal {
                                width:              parent.indicatorWidth
                                height:             parent.indicatorHeight
DonLakeFlyer's avatar
DonLakeFlyer committed
781 782 783 784 785
                                visible:            controller.orientationCalUpsideDownSideVisible
                                calValid:           controller.orientationCalUpsideDownSideDone
                                calInProgress:      controller.orientationCalUpsideDownSideInProgress
                                calInProgressText:  controller.orientationCalUpsideDownSideRotate ? qsTr("Rotate") : qsTr("Hold Still")
                                imageSource:        "qrc:///qmlimages/VehicleUpsideDown.png"
786
                            }
Don Gagne's avatar
Don Gagne committed
787
                        }
Don Gagne's avatar
Don Gagne committed
788
                    }
789 790 791 792 793
                } // Item - Cal display area
            } // Column - cal display
        } // Row
    } // Component - sensorsPageComponent
} // SetupPage