JoystickConfig.qml 34.8 KB
Newer Older
1 2 3 4 5 6 7 8
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
9 10 11 12 13 14


import QtQuick          2.2
import QtQuick.Controls 1.2
import QtQuick.Dialogs  1.2

15
import QGroundControl               1.0
16 17 18 19
import QGroundControl.Palette       1.0
import QGroundControl.Controls      1.0
import QGroundControl.ScreenTools   1.0
import QGroundControl.Controllers   1.0
20
import QGroundControl.FactSystem    1.0
21
import QGroundControl.FactControls  1.0
22 23

/// Joystick Config
Don Gagne's avatar
Don Gagne committed
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
SetupPage {
    id:                 joystickPage
    pageComponent:      pageComponent
    pageName:           qsTr("Joystick")
    pageDescription:    qsTr("Joystick Setup is used to configure a calibrate joysticks.")

    Component {
        id: pageComponent

        Item {
            width:  availableWidth
            height: Math.max(leftColumn.height, rightColumn.height)

            property bool controllerCompleted:      false
            property bool controllerAndViewReady:   false

            readonly property real labelToMonitorMargin: defaultTextWidth * 3

            property var _activeVehicle:    QGroundControl.multiVehicleManager.activeVehicle
            property var _activeJoystick:   joystickManager.activeJoystick

            JoystickConfigController {
                id:             controller
                factPanel:      joystickPage.viewPanel
                statusText:     statusText
                cancelButton:   cancelButton
                nextButton:     nextButton
                skipButton:     skipButton

                Component.onCompleted: {
                    controllerCompleted = true
                    if (joystickPage.completedSignalled) {
                        controllerAndViewReady = true
                        controller.start()
                    }
                }
60 61
            }

Don Gagne's avatar
Don Gagne committed
62 63 64 65 66 67
            Component.onCompleted: {
                if (controllerCompleted) {
                    controllerAndViewReady = true
                    controller.start()
                }
            }
68

Don Gagne's avatar
Don Gagne committed
69 70 71
            // Live axis monitor control component
            Component {
                id: axisMonitorDisplayComponent
72

Don Gagne's avatar
Don Gagne committed
73 74
                Item {
                    property int axisValue: 0
Gregory Dymarek's avatar
Gregory Dymarek committed
75
                    property int deadbandValue: 0
76

Don Gagne's avatar
Don Gagne committed
77 78 79
                    property int            __lastAxisValue:        0
                    readonly property int   __axisValueMaxJitter:   100
                    property color          __barColor:             qgcPal.windowShade
80

Don Gagne's avatar
Don Gagne committed
81 82 83 84 85 86 87 88
                    // Bar
                    Rectangle {
                        id:                     bar
                        anchors.verticalCenter: parent.verticalCenter
                        width:                  parent.width
                        height:                 parent.height / 2
                        color:                  __barColor
                    }
89

Gregory Dymarek's avatar
Gregory Dymarek committed
90 91 92 93 94 95 96 97 98 99 100 101 102 103
                    // Deadband
                    Rectangle {
                        id:                     deadbandBar
                        anchors.verticalCenter: parent.verticalCenter
                        x:                      _deadbandPosition
                        width:                  _deadbandWidth
                        height:                 parent.height / 2
                        color:                  "#8c161a"

                        property real _percentDeadband:    ((2 * deadbandValue) / (32768.0 * 2))
                        property real _deadbandWidth:   parent.width * _percentDeadband
                        property real _deadbandPosition:   (parent.width - _deadbandWidth) / 2
                    }

Don Gagne's avatar
Don Gagne committed
104 105 106 107 108 109 110
                    // Center point
                    Rectangle {
                        anchors.horizontalCenter:   parent.horizontalCenter
                        width:                      defaultTextWidth / 2
                        height:                     parent.height
                        color:                      qgcPal.window
                    }
111

Don Gagne's avatar
Don Gagne committed
112 113 114 115 116 117 118 119 120 121 122 123 124
                    // Indicator
                    Rectangle {
                        anchors.verticalCenter: parent.verticalCenter
                        width:                  parent.height * 0.75
                        height:                 width
                        x:                      (reversed ? (parent.width - _indicatorPosition) : _indicatorPosition) - (width / 2)
                        radius:                 width / 2
                        color:                  qgcPal.text
                        visible:                mapped

                        property real _percentAxisValue:    ((axisValue + 32768.0) / (32768.0 * 2))
                        property real _indicatorPosition:   parent.width * _percentAxisValue
                    }
125

Don Gagne's avatar
Don Gagne committed
126 127 128 129 130 131 132
                    QGCLabel {
                        anchors.fill:           parent
                        horizontalAlignment:    Text.AlignHCenter
                        verticalAlignment:      Text.AlignVCenter
                        text:                   qsTr("Not Mapped")
                        visible:                !mapped
                    }
133

Don Gagne's avatar
Don Gagne committed
134 135 136 137 138 139 140 141
                    ColorAnimation {
                        id:         barAnimation
                        target:     bar
                        property:   "color"
                        from:       "yellow"
                        to:         __barColor
                        duration:   1500
                    }
142

Gregory Dymarek's avatar
Gregory Dymarek committed
143

Don Gagne's avatar
Don Gagne committed
144
                    // Axis value debugger
Gregory Dymarek's avatar
Gregory Dymarek committed
145
                    /*
Don Gagne's avatar
Don Gagne committed
146 147 148 149 150
                    QGCLabel {
                        anchors.fill: parent
                        text: axisValue
                    }
                    */
Gregory Dymarek's avatar
Gregory Dymarek committed
151

152
                }
Don Gagne's avatar
Don Gagne committed
153
            } // Component - axisMonitorDisplayComponent
154

Don Gagne's avatar
Don Gagne committed
155 156 157 158 159 160 161 162 163
            // Main view Qml starts here

            // Left side column
            Column {
                id:                     leftColumn
                anchors.rightMargin:    ScreenTools.defaultFontPixelWidth
                anchors.left:           parent.left
                anchors.right:          rightColumn.left
                spacing:                10
164

Don Gagne's avatar
Don Gagne committed
165 166 167 168
                // Attitude Controls
                Column {
                    width:      parent.width
                    spacing:    5
169

Don Gagne's avatar
Don Gagne committed
170
                    QGCLabel { text: qsTr("Attitude Controls") }
171

Don Gagne's avatar
Don Gagne committed
172 173 174
                    Item {
                        width:  parent.width
                        height: defaultTextHeight * 2
175

Don Gagne's avatar
Don Gagne committed
176 177 178
                        QGCLabel {
                            id:     rollLabel
                            width:  defaultTextWidth * 10
179
                            text:   _activeVehicle.sub ? qsTr("Lateral") : qsTr("Roll")
Don Gagne's avatar
Don Gagne committed
180
                        }
181

Don Gagne's avatar
Don Gagne committed
182 183 184 185 186 187 188 189 190 191 192 193
                        Loader {
                            id:                 rollLoader
                            anchors.left:       rollLabel.right
                            anchors.right:      parent.right
                            height:             ScreenTools.defaultFontPixelHeight
                            width:              100
                            sourceComponent:    axisMonitorDisplayComponent

                            property real defaultTextWidth: ScreenTools.defaultFontPixelWidth
                            property bool mapped:           controller.rollAxisMapped
                            property bool reversed:         controller.rollAxisReversed
                        }
194

Don Gagne's avatar
Don Gagne committed
195 196
                        Connections {
                            target: controller
197

Don Gagne's avatar
Don Gagne committed
198
                            onRollAxisValueChanged: rollLoader.item.axisValue = value
Gregory Dymarek's avatar
Gregory Dymarek committed
199 200

                            onRollAxisDeadbandChanged: rollLoader.item.deadbandValue = value
Don Gagne's avatar
Don Gagne committed
201
                        }
202 203
                    }

Don Gagne's avatar
Don Gagne committed
204 205 206
                    Item {
                        width:  parent.width
                        height: defaultTextHeight * 2
207

Don Gagne's avatar
Don Gagne committed
208 209 210
                        QGCLabel {
                            id:     pitchLabel
                            width:  defaultTextWidth * 10
211
                            text:   _activeVehicle.sub ? qsTr("Forward") : qsTr("Pitch")
Don Gagne's avatar
Don Gagne committed
212
                        }
213

Don Gagne's avatar
Don Gagne committed
214 215 216 217 218 219 220 221 222 223 224 225
                        Loader {
                            id:                 pitchLoader
                            anchors.left:       pitchLabel.right
                            anchors.right:      parent.right
                            height:             ScreenTools.defaultFontPixelHeight
                            width:              100
                            sourceComponent:    axisMonitorDisplayComponent

                            property real defaultTextWidth: ScreenTools.defaultFontPixelWidth
                            property bool mapped:           controller.pitchAxisMapped
                            property bool reversed:         controller.pitchAxisReversed
                        }
226

Don Gagne's avatar
Don Gagne committed
227 228
                        Connections {
                            target: controller
229

Don Gagne's avatar
Don Gagne committed
230
                            onPitchAxisValueChanged: pitchLoader.item.axisValue = value
Gregory Dymarek's avatar
Gregory Dymarek committed
231 232 233

                            onPitchAxisDeadbandChanged: pitchLoader.item.deadbandValue = value

Don Gagne's avatar
Don Gagne committed
234
                        }
235 236
                    }

Don Gagne's avatar
Don Gagne committed
237 238 239
                    Item {
                        width:  parent.width
                        height: defaultTextHeight * 2
240

Don Gagne's avatar
Don Gagne committed
241 242 243 244 245
                        QGCLabel {
                            id:     yawLabel
                            width:  defaultTextWidth * 10
                            text:   qsTr("Yaw")
                        }
246

Don Gagne's avatar
Don Gagne committed
247 248 249 250 251 252 253 254 255 256 257 258
                        Loader {
                            id:                 yawLoader
                            anchors.left:       yawLabel.right
                            anchors.right:      parent.right
                            height:             ScreenTools.defaultFontPixelHeight
                            width:              100
                            sourceComponent:    axisMonitorDisplayComponent

                            property real defaultTextWidth: ScreenTools.defaultFontPixelWidth
                            property bool mapped:           controller.yawAxisMapped
                            property bool reversed:         controller.yawAxisReversed
                        }
259

Don Gagne's avatar
Don Gagne committed
260 261
                        Connections {
                            target: controller
262

Don Gagne's avatar
Don Gagne committed
263
                            onYawAxisValueChanged: yawLoader.item.axisValue = value
Gregory Dymarek's avatar
Gregory Dymarek committed
264 265

                            onYawAxisDeadbandChanged: yawLoader.item.deadbandValue = value
Don Gagne's avatar
Don Gagne committed
266
                        }
267 268
                    }

Don Gagne's avatar
Don Gagne committed
269 270 271
                    Item {
                        width:  parent.width
                        height: defaultTextHeight * 2
272

Don Gagne's avatar
Don Gagne committed
273 274 275 276 277
                        QGCLabel {
                            id:     throttleLabel
                            width:  defaultTextWidth * 10
                            text:   qsTr("Throttle")
                        }
278

Don Gagne's avatar
Don Gagne committed
279 280 281 282 283 284 285 286 287 288 289 290
                        Loader {
                            id:                 throttleLoader
                            anchors.left:       throttleLabel.right
                            anchors.right:      parent.right
                            height:             ScreenTools.defaultFontPixelHeight
                            width:              100
                            sourceComponent:    axisMonitorDisplayComponent

                            property real defaultTextWidth: ScreenTools.defaultFontPixelWidth
                            property bool mapped:           controller.throttleAxisMapped
                            property bool reversed:         controller.throttleAxisReversed
                        }
291

Don Gagne's avatar
Don Gagne committed
292 293
                        Connections {
                            target: controller
294

Don Gagne's avatar
Don Gagne committed
295
                            onThrottleAxisValueChanged: throttleLoader.item.axisValue = value
Gregory Dymarek's avatar
Gregory Dymarek committed
296 297

                            onThrottleAxisDeadbandChanged: throttleLoader.item.deadbandValue = value
Don Gagne's avatar
Don Gagne committed
298
                        }
299
                    }
Don Gagne's avatar
Don Gagne committed
300
                } // Column - Attitude Control labels
301

Don Gagne's avatar
Don Gagne committed
302 303 304
                // Command Buttons
                Row {
                    spacing: 10
305
                    visible: _activeJoystick.requiresCalibration
Don Gagne's avatar
Don Gagne committed
306 307 308 309

                    QGCButton {
                        id:     skipButton
                        text:   qsTr("Skip")
310

Don Gagne's avatar
Don Gagne committed
311
                        onClicked: controller.skipButtonClicked()
312 313
                    }

Don Gagne's avatar
Don Gagne committed
314 315 316
                    QGCButton {
                        id:     cancelButton
                        text:   qsTr("Cancel")
317

Don Gagne's avatar
Don Gagne committed
318 319
                        onClicked: controller.cancelButtonClicked()
                    }
320

Don Gagne's avatar
Don Gagne committed
321 322 323 324
                    QGCButton {
                        id:         nextButton
                        primary:    true
                        text:       qsTr("Calibrate")
325

Don Gagne's avatar
Don Gagne committed
326 327 328
                        onClicked: controller.nextButtonClicked()
                    }
                } // Row - Buttons
329

Don Gagne's avatar
Don Gagne committed
330 331 332 333 334
                // Status Text
                QGCLabel {
                    id:         statusText
                    width:      parent.width
                    wrapMode:   Text.WordWrap
335 336
                }

Don Gagne's avatar
Don Gagne committed
337 338 339 340 341
                Rectangle {
                    width:          parent.width
                    height:         1
                    border.color:   qgcPal.text
                    border.width:   1
342 343
                }

Don Gagne's avatar
Don Gagne committed
344 345 346 347
                // Settings
                Row {
                    width:      parent.width
                    spacing:    ScreenTools.defaultFontPixelWidth
348

Don Gagne's avatar
Don Gagne committed
349
                    // Left column settings
350
                    Column {
Don Gagne's avatar
Don Gagne committed
351
                        width:      parent.width / 2
352 353
                        spacing:    ScreenTools.defaultFontPixelHeight

Don Gagne's avatar
Don Gagne committed
354
                        QGCLabel { text: qsTr("Additional Joystick settings:") }
355

Don Gagne's avatar
Don Gagne committed
356 357 358
                        Column {
                            width:      parent.width
                            spacing:    ScreenTools.defaultFontPixelHeight
359 360


Don Gagne's avatar
Don Gagne committed
361 362 363 364
                            QGCCheckBox {
                                enabled:    checked || _activeJoystick.calibrated
                                text:       _activeJoystick.calibrated ? qsTr("Enable joystick input") : qsTr("Enable not allowed (Calibrate First)")
                                checked:    _activeVehicle.joystickEnabled
365

Don Gagne's avatar
Don Gagne committed
366
                                onClicked:  _activeVehicle.joystickEnabled = checked
367 368
                            }

Don Gagne's avatar
Don Gagne committed
369 370 371
                            Row {
                                width:      parent.width
                                spacing:    ScreenTools.defaultFontPixelWidth
372

Don Gagne's avatar
Don Gagne committed
373 374 375 376 377
                                QGCLabel {
                                    id:                 activeJoystickLabel
                                    anchors.baseline:   joystickCombo.baseline
                                    text:               qsTr("Active joystick:")
                                }
378

Don Gagne's avatar
Don Gagne committed
379 380 381 382 383 384 385 386 387 388 389 390 391 392
                                QGCComboBox {
                                    id:                 joystickCombo
                                    width:              parent.width - activeJoystickLabel.width - parent.spacing
                                    model:              joystickManager.joystickNames

                                    onActivated: joystickManager.activeJoystickName = textAt(index)

                                    Component.onCompleted: {
                                        var index = joystickCombo.find(joystickManager.activeJoystickName)
                                        if (index == -1) {
                                            console.warn(qsTr("Active joystick name not in combo"), joystickManager.activeJoystickName)
                                        } else {
                                            joystickCombo.currentIndex = index
                                        }
393 394
                                    }
                                }
395 396
                            }

Don Gagne's avatar
Don Gagne committed
397 398 399
                            Column {
                                spacing: ScreenTools.defaultFontPixelHeight / 3
                                visible: _activeVehicle.supportsThrottleModeCenterZero
400

Don Gagne's avatar
Don Gagne committed
401
                                ExclusiveGroup { id: throttleModeExclusiveGroup }
402

Don Gagne's avatar
Don Gagne committed
403 404 405 406
                                QGCRadioButton {
                                    exclusiveGroup: throttleModeExclusiveGroup
                                    text:           qsTr("Center stick is zero throttle")
                                    checked:        _activeJoystick.throttleMode == 0
407

Don Gagne's avatar
Don Gagne committed
408 409
                                    onClicked: _activeJoystick.throttleMode = 0
                                }
410

411
                                Row {
Gregory Dymarek's avatar
Gregory Dymarek committed
412
                                    x:          20
413 414 415 416 417 418 419
                                    width:      parent.width
                                    spacing:    ScreenTools.defaultFontPixelWidth
                                    visible:    _activeJoystick.throttleMode == 0

                                    QGCCheckBox {
                                        id:         accumulator
                                        checked:    _activeJoystick.accumulator
Gregory Dymarek's avatar
Gregory Dymarek committed
420
                                        text:       qsTr("Spring loaded throttle smoothing")
421 422 423 424 425

                                        onClicked:  _activeJoystick.accumulator = checked
                                    }
                                }

Don Gagne's avatar
Don Gagne committed
426 427 428 429
                                QGCRadioButton {
                                    exclusiveGroup: throttleModeExclusiveGroup
                                    text:           qsTr("Full down stick is zero throttle")
                                    checked:        _activeJoystick.throttleMode == 1
430

Don Gagne's avatar
Don Gagne committed
431 432
                                    onClicked: _activeJoystick.throttleMode = 1
                                }
433 434
                            }

Don Gagne's avatar
Don Gagne committed
435 436
                            Column {
                                spacing: ScreenTools.defaultFontPixelHeight / 3
437

Don Gagne's avatar
Don Gagne committed
438 439 440 441
                                QGCCheckBox {
                                    id:         exponential
                                    checked:    _activeJoystick.exponential
                                    text:       qsTr("Use exponential curve on roll, pitch, yaw")
442

Don Gagne's avatar
Don Gagne committed
443 444
                                    onClicked:  _activeJoystick.exponential = checked
                                }
445 446
                            }

Don Gagne's avatar
Don Gagne committed
447 448 449 450
                            QGCCheckBox {
                                id:         advancedSettings
                                checked:    _activeVehicle.joystickMode != 0
                                text:       qsTr("Advanced settings (careful!)")
451

Don Gagne's avatar
Don Gagne committed
452 453 454 455
                                onClicked: {
                                    if (!checked) {
                                        _activeVehicle.joystickMode = 0
                                    }
456 457 458
                                }
                            }

Don Gagne's avatar
Don Gagne committed
459 460 461 462 463 464 465 466 467 468
                            Row {
                                width:      parent.width
                                spacing:    ScreenTools.defaultFontPixelWidth
                                visible:    advancedSettings.checked

                                QGCLabel {
                                    id:                 joystickModeLabel
                                    anchors.baseline:   joystickModeCombo.baseline
                                    text:               qsTr("Joystick mode:")
                                }
469

Don Gagne's avatar
Don Gagne committed
470 471 472 473 474
                                QGCComboBox {
                                    id:             joystickModeCombo
                                    currentIndex:   _activeVehicle.joystickMode
                                    width:          ScreenTools.defaultFontPixelWidth * 20
                                    model:          _activeVehicle.joystickModes
475

Don Gagne's avatar
Don Gagne committed
476 477
                                    onActivated: _activeVehicle.joystickMode = index
                                }
478
                            }
479 480 481 482 483 484 485 486 487 488 489 490 491 492

                            Row {
                                width:      parent.width
                                spacing:    ScreenTools.defaultFontPixelWidth
                                visible:    advancedSettings.checked

                                QGCCheckBox {
                                    id:         deadband
                                    checked:    controller.deadbandToggle
                                    text:       qsTr("Deadbands")

                                    onClicked:  controller.deadbandToggle = checked
                                }
                            }
493
                        }
Don Gagne's avatar
Don Gagne committed
494
                    } // Column - left column
495

Don Gagne's avatar
Don Gagne committed
496 497 498 499
                    // Right column settings
                    Column {
                        width:      parent.width / 2
                        spacing:    ScreenTools.defaultFontPixelHeight
500

Don Gagne's avatar
Don Gagne committed
501 502
                        Connections {
                            target: _activeJoystick
503

Don Gagne's avatar
Don Gagne committed
504 505 506 507 508 509 510
                            onRawButtonPressedChanged: {
                                if (buttonActionRepeater.itemAt(index)) {
                                    buttonActionRepeater.itemAt(index).pressed = pressed
                                }
                                if (jsButtonActionRepeater.itemAt(index)) {
                                    jsButtonActionRepeater.itemAt(index).pressed = pressed
                                }
511
                            }
512 513
                        }

Don Gagne's avatar
Don Gagne committed
514
                        QGCLabel { text: qsTr("Button actions:") }
515

Don Gagne's avatar
Don Gagne committed
516 517 518
                        Column {
                            width:      parent.width
                            spacing:    ScreenTools.defaultFontPixelHeight / 3
519

Don Gagne's avatar
Don Gagne committed
520 521 522
                            QGCLabel {
                                visible: _activeVehicle.manualControlReservedButtonCount != 0
                                text: qsTr("Buttons 0-%1 reserved for firmware use").arg(reservedButtonCount)
523

Don Gagne's avatar
Don Gagne committed
524 525
                                property int reservedButtonCount: _activeVehicle.manualControlReservedButtonCount == -1 ? _activeJoystick.totalButtonCount : _activeVehicle.manualControlReservedButtonCount
                            }
526

Don Gagne's avatar
Don Gagne committed
527 528 529
                            Repeater {
                                id:     buttonActionRepeater
                                model:  _activeJoystick.totalButtonCount
530

Don Gagne's avatar
Don Gagne committed
531 532 533
                                Row {
                                    spacing: ScreenTools.defaultFontPixelWidth
                                    visible: (_activeVehicle.manualControlReservedButtonCount == -1 ? false : modelData >= _activeVehicle.manualControlReservedButtonCount) && !_activeVehicle.supportsJSButton
534

Don Gagne's avatar
Don Gagne committed
535
                                    property bool pressed
536

Don Gagne's avatar
Don Gagne committed
537 538 539
                                    QGCCheckBox {
                                        anchors.verticalCenter:     parent.verticalCenter
                                        checked:                    _activeJoystick.buttonActions[modelData] != ""
540

Don Gagne's avatar
Don Gagne committed
541 542
                                        onClicked: _activeJoystick.setButtonAction(modelData, checked ? buttonActionCombo.textAt(buttonActionCombo.currentIndex) : "")
                                    }
543

Don Gagne's avatar
Don Gagne committed
544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559
                                    Rectangle {
                                        anchors.verticalCenter:     parent.verticalCenter
                                        width:                      ScreenTools.defaultFontPixelHeight * 1.5
                                        height:                     width
                                        border.width:               1
                                        border.color:               qgcPal.text
                                        color:                      pressed ? qgcPal.buttonHighlight : qgcPal.button


                                        QGCLabel {
                                            anchors.fill:           parent
                                            color:                  pressed ? qgcPal.buttonHighlightText : qgcPal.buttonText
                                            horizontalAlignment:    Text.AlignHCenter
                                            verticalAlignment:      Text.AlignVCenter
                                            text:                   modelData
                                        }
560 561
                                    }

Don Gagne's avatar
Don Gagne committed
562 563 564 565
                                    QGCComboBox {
                                        id:             buttonActionCombo
                                        width:          ScreenTools.defaultFontPixelWidth * 20
                                        model:          _activeJoystick.actions
566

Don Gagne's avatar
Don Gagne committed
567 568 569
                                        onActivated:            _activeJoystick.setButtonAction(modelData, textAt(index))
                                        Component.onCompleted:  currentIndex = find(_activeJoystick.buttonActions[modelData])
                                    }
570
                                }
Don Gagne's avatar
Don Gagne committed
571
                            } // Repeater
572 573 574

                            Row {
                                spacing: ScreenTools.defaultFontPixelWidth
575
                                visible: _activeVehicle.supportsJSButton
576

Don Gagne's avatar
Don Gagne committed
577 578 579 580
                                QGCLabel {
                                    horizontalAlignment:    Text.AlignHCenter
                                    width:                  ScreenTools.defaultFontPixelHeight * 1.5
                                    text:                   qsTr("#")
581 582
                                }

Don Gagne's avatar
Don Gagne committed
583 584 585
                                QGCLabel {
                                    width:                  ScreenTools.defaultFontPixelWidth * 15
                                    text:                   qsTr("Function: ")
586 587
                                }

Don Gagne's avatar
Don Gagne committed
588 589 590
                                QGCLabel {
                                    width:                  ScreenTools.defaultFontPixelWidth * 15
                                    text:                   qsTr("Shift Function: ")
591 592
                                }
                            } // Row
593

Don Gagne's avatar
Don Gagne committed
594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642
                            Repeater {
                                id:     jsButtonActionRepeater
                                model:  _activeJoystick.totalButtonCount

                                Row {
                                    spacing: ScreenTools.defaultFontPixelWidth
                                    visible: _activeVehicle.supportsJSButton

                                    property bool pressed

                                    Rectangle {
                                        anchors.verticalCenter:     parent.verticalCenter
                                        width:                      ScreenTools.defaultFontPixelHeight * 1.5
                                        height:                     width
                                        border.width:               1
                                        border.color:               qgcPal.text
                                        color:                      pressed ? qgcPal.buttonHighlight : qgcPal.button


                                        QGCLabel {
                                            anchors.fill:           parent
                                            color:                  pressed ? qgcPal.buttonHighlightText : qgcPal.buttonText
                                            horizontalAlignment:    Text.AlignHCenter
                                            verticalAlignment:      Text.AlignVCenter
                                            text:                   modelData
                                        }
                                    }

                                    FactComboBox {
                                        id:         mainJSButtonActionCombo
                                        width:      ScreenTools.defaultFontPixelWidth * 15
                                        fact:       controller.parameterExists(-1, "BTN"+index+"_FUNCTION") ? controller.getParameterFact(-1, "BTN" + index + "_FUNCTION") : null;
                                        indexModel: false
                                    }

                                    FactComboBox {
                                        id:         shiftJSButtonActionCombo
                                        width:      ScreenTools.defaultFontPixelWidth * 15
                                        fact:       controller.parameterExists(-1, "BTN"+index+"_SFUNCTION") ? controller.getParameterFact(-1, "BTN" + index + "_SFUNCTION") : null;
                                        indexModel: false
                                    }
                                } // Row
                            } // Repeater
                        } // Column
                    } // Column - right setting column
                } // Row - Settings
            } // Column - Left Main Column

            // Right side column
643
            Column {
Don Gagne's avatar
Don Gagne committed
644 645 646
                id:             rightColumn
                anchors.top:    parent.top
                anchors.right:  parent.right
647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662
                width:          Math.min(joystickPage.defaultTextWidth * 35, availableWidth * 0.4)
                spacing:        ScreenTools.defaultFontPixelHeight / 2

                Row {
                    spacing: ScreenTools.defaultFontPixelWidth

                    ExclusiveGroup { id: modeGroup }

                    QGCLabel {
                        text: "TX Mode:"
                    }

                    QGCRadioButton {
                        exclusiveGroup: modeGroup
                        text:           "1"
                        checked:        controller.transmitterMode == 1
663
                        enabled:        !controller.calibrating
664 665 666 667 668 669 670 671

                        onClicked: controller.transmitterMode = 1
                    }

                    QGCRadioButton {
                        exclusiveGroup: modeGroup
                        text:           "2"
                        checked:        controller.transmitterMode == 2
672
                        enabled:        !controller.calibrating
673 674 675 676 677 678 679 680

                        onClicked: controller.transmitterMode = 2
                    }

                    QGCRadioButton {
                        exclusiveGroup: modeGroup
                        text:           "3"
                        checked:        controller.transmitterMode == 3
681
                        enabled:        !controller.calibrating
682 683 684 685 686 687 688 689

                        onClicked: controller.transmitterMode = 3
                    }

                    QGCRadioButton {
                        exclusiveGroup: modeGroup
                        text:           "4"
                        checked:        controller.transmitterMode == 4
690
                        enabled:        !controller.calibrating
691 692 693 694

                        onClicked: controller.transmitterMode = 4
                    }
                }
Don Gagne's avatar
Don Gagne committed
695 696

                Image {
697
                    width:      parent.width
Don Gagne's avatar
Don Gagne committed
698 699 700 701
                    fillMode:   Image.PreserveAspectFit
                    smooth:     true
                    source:     controller.imageHelp
                }
702

Don Gagne's avatar
Don Gagne committed
703 704 705 706
                // Axis monitor
                Column {
                    width:      parent.width
                    spacing:    5
707

Don Gagne's avatar
Don Gagne committed
708
                    QGCLabel { text: qsTr("Axis Monitor") }
709

Don Gagne's avatar
Don Gagne committed
710 711 712 713 714 715 716
                    Connections {
                        target: controller

                        onAxisValueChanged: {
                            if (axisMonitorRepeater.itemAt(axis)) {
                                axisMonitorRepeater.itemAt(axis).loader.item.axisValue = value
                            }
717 718 719
                        }
                    }

Don Gagne's avatar
Don Gagne committed
720 721 722 723
                    Repeater {
                        id:     axisMonitorRepeater
                        model:  _activeJoystick.axisCount
                        width:  parent.width
724

Don Gagne's avatar
Don Gagne committed
725 726
                        Row {
                            spacing:    5
727

Don Gagne's avatar
Don Gagne committed
728 729
                            // Need this to get to loader from Connections above
                            property Item loader: theLoader
730

Don Gagne's avatar
Don Gagne committed
731 732 733 734
                            QGCLabel {
                                id:     axisLabel
                                text:   modelData
                            }
735

Don Gagne's avatar
Don Gagne committed
736 737 738 739 740 741 742 743 744 745 746
                            Loader {
                                id:                     theLoader
                                anchors.verticalCenter: axisLabel.verticalCenter
                                height:                 ScreenTools.defaultFontPixelHeight
                                width:                  200
                                sourceComponent:        axisMonitorDisplayComponent

                                property real defaultTextWidth:     ScreenTools.defaultFontPixelWidth
                                property bool mapped:               true
                                readonly property bool reversed:    false
                            }
747 748
                        }
                    }
Don Gagne's avatar
Don Gagne committed
749
                } // Column - Axis Monitor
750

Don Gagne's avatar
Don Gagne committed
751 752 753 754
                // Button monitor
                Column {
                    width:      parent.width
                    spacing:    ScreenTools.defaultFontPixelHeight
755

Don Gagne's avatar
Don Gagne committed
756
                    QGCLabel { text: qsTr("Button Monitor") }
757

Don Gagne's avatar
Don Gagne committed
758 759
                    Connections {
                        target: _activeJoystick
760

Don Gagne's avatar
Don Gagne committed
761 762 763 764
                        onRawButtonPressedChanged: {
                            if (buttonMonitorRepeater.itemAt(index)) {
                                buttonMonitorRepeater.itemAt(index).pressed = pressed
                            }
765 766 767
                        }
                    }

Don Gagne's avatar
Don Gagne committed
768 769 770
                    Flow {
                        width:      parent.width
                        spacing:    -1
771

Don Gagne's avatar
Don Gagne committed
772 773 774
                        Repeater {
                            id:     buttonMonitorRepeater
                            model:  _activeJoystick.totalButtonCount
775

Don Gagne's avatar
Don Gagne committed
776 777 778 779 780 781
                            Rectangle {
                                width:          ScreenTools.defaultFontPixelHeight * 1.2
                                height:         width
                                border.width:   1
                                border.color:   qgcPal.text
                                color:          pressed ? qgcPal.buttonHighlight : qgcPal.button
782

Don Gagne's avatar
Don Gagne committed
783
                                property bool pressed
784

Don Gagne's avatar
Don Gagne committed
785 786 787 788 789 790 791
                                QGCLabel {
                                    anchors.fill:           parent
                                    color:                  pressed ? qgcPal.buttonHighlightText : qgcPal.buttonText
                                    horizontalAlignment:    Text.AlignHCenter
                                    verticalAlignment:      Text.AlignVCenter
                                    text:                   modelData
                                }
792
                            }
Don Gagne's avatar
Don Gagne committed
793 794 795 796 797 798 799
                        } // Repeater
                    } // Row
                } // Column - Axis Monitor
            } // Column - Right Column
        } // Item
    } // Component - pageComponent
} // SetupPage
Gregory Dymarek's avatar
Gregory Dymarek committed
800 801